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