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