1 |
|
2 |
|
3 | import { assert, u8aToU8a } from '@polkadot/util';
|
4 | import { vrfVerify } from '@polkadot/wasm-crypto';
|
5 | const EMPTY_U8A = new Uint8Array();
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | export function sr25519VrfVerify(message, signOutput, publicKey, context = EMPTY_U8A, extra = EMPTY_U8A) {
|
12 | const publicKeyU8a = u8aToU8a(publicKey);
|
13 | const proofU8a = u8aToU8a(signOutput);
|
14 | assert(publicKeyU8a.length === 32, 'Invalid publicKey, expected 32-bytes');
|
15 | assert(proofU8a.length === 96, 'Invalid vrfSign output, expected 96 bytes');
|
16 | return vrfVerify(publicKeyU8a, u8aToU8a(context), u8aToU8a(message), u8aToU8a(extra), proofU8a);
|
17 | } |
\ | No newline at end of file |