1 |
|
2 |
|
3 | import { u8aToU8a } from '@polkadot/util';
|
4 | import { sr25519Agree } from '@polkadot/wasm-crypto';
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | export function sr25519Agreement(secretKey, publicKey) {
|
11 | const secretKeyU8a = u8aToU8a(secretKey);
|
12 | const publicKeyU8a = u8aToU8a(publicKey);
|
13 |
|
14 | if (publicKeyU8a.length !== 32) {
|
15 | throw new Error(`Invalid publicKey, received ${publicKeyU8a.length} bytes, expected 32`);
|
16 | } else if (secretKeyU8a.length !== 64) {
|
17 | throw new Error(`Invalid secretKey, received ${secretKeyU8a.length} bytes, expected 64`);
|
18 | }
|
19 |
|
20 | return sr25519Agree(publicKeyU8a, secretKeyU8a);
|
21 | } |
\ | No newline at end of file |