|
1 | 1 | <!DOCTYPE html>
|
2 | 2 | <html lang="en">
|
3 |
| - |
4 |
| -<head> |
5 |
| - <meta charset="UTF-8"> |
6 |
| - <meta http-equiv="X-UA-Compatible" |
7 |
| - content="IE=edge"> |
8 |
| - <meta name="viewport" |
9 |
| - content="width=device-width, initial-scale=1.0"> |
| 3 | + <head> |
| 4 | + <meta charset="UTF-8" /> |
| 5 | + <meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
| 6 | + <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
10 | 7 | <script src="./dist/browser/umd/index.js"></script>
|
11 | 8 | <title>Test</title>
|
12 |
| -</head> |
| 9 | + </head> |
13 | 10 |
|
14 |
| -<body> |
| 11 | + <body> |
15 | 12 | Test browser
|
16 |
| -</body> |
17 |
| -<script> |
18 |
| - // Function to convert hex to base64 |
19 |
| - function base64FromHex(hex) { |
20 |
| - hex = hex.replace(/^0x/, ''); |
21 |
| - hex = hex.length % 2 != 0 ? '0' + hex : hex; |
22 |
| - const buffer = new Uint8Array(hex.match(/.{1,2}/g).map((byte) => parseInt(byte, 16))); |
23 |
| - return btoa(String.fromCharCode(...buffer)); |
24 |
| - } |
25 |
| - |
26 |
| - const { poseidon, PrivateKey, Signature, utils, ffUtils, Hex } = IdenJsCrypto; |
| 13 | + </body> |
| 14 | + <script> |
| 15 | + const { PrivateKey, Signature, utils, ffUtils, Hex } = IdenJsCrypto; |
27 | 16 | const msgBuf = Hex.decodeString('000102030405060708090000');
|
28 | 17 | const msg = ffUtils.leBuff2int(msgBuf);
|
29 | 18 |
|
30 |
| - const skBuff = Hex.decodeString('0001020304050607080900010203040506070809000102030405060708090001'); |
| 19 | + const skBuff = Hex.decodeString( |
| 20 | + '0001020304050607080900010203040506070809000102030405060708090001' |
| 21 | + ); |
31 | 22 |
|
32 | 23 | const privateKey = new PrivateKey(skBuff);
|
33 | 24 |
|
|
38 | 29 |
|
39 | 30 | const signature = privateKey.signPoseidon(msg);
|
40 | 31 |
|
41 |
| - |
42 | 32 | const pSignature = signature.compress();
|
43 | 33 |
|
44 | 34 | const uSignature = Signature.newFromCompressed(pSignature);
|
45 | 35 |
|
46 | 36 | console.assert(pubKey.verifyPoseidon(msg, uSignature));
|
47 |
| -</script> |
48 |
| - |
| 37 | + </script> |
49 | 38 | </html>
|
0 commit comments