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