-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.html
43 lines (38 loc) · 1.21 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"
content="IE=edge">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<script src="./dist/browser/umd/index.js"></script>
<title>Test Iden3Merkletree</title>
<script type="importmap">
{
"imports": {
"@iden3/js-crypto": "../node_modules/@iden3/js-crypto/dist/browser/esm/index.js"
}
}
</script>
</head>
<body>
Test Iden3Merkletree UMD/ESM script work
</body>
<script type="module">
import * as esm from './dist/browser/esm/index.js';
const run = async (module) => {
const { InMemoryDB, Merkletree, verifyProof, str2Bytes, ZERO_HASH } = module;
const sto = new InMemoryDB(str2Bytes(''));
const mt = new Merkletree(sto, true, 10);
await mt.add(1n, 2n);
await mt.add(33n, 44n);
await mt.add(1234n, 9876n);
const { proof, value } = await mt.generateProof(33n);
console.assert(await verifyProof(await mt.root(), proof, 33n, 44n));
console.log('Proof verified');
};
await run(esm);
await run(Iden3Merkletree);
</script>
</html>