websnark/example/index.html
example/index.htmlRaw
1<html>
2<header>
3</header>
4<script src="websnark.js"></script>
5<script>
6
7var witness;
8var proving_key;
9
10function onLoad() {
11
12 fetch("proving_key.bin").then( (response) => {
13 return response.arrayBuffer();
14 }).then( (b) => {
15 provingKey = b;
16 });
17
18 fetch("witness.bin").then( (response) => {
19 return response.arrayBuffer();
20 }).then( (b) => {
21 witness = b;
22 });
23}
24
25function calcProof() {
26 const start = new Date().getTime();
27 document.getElementById("time").innerHTML = "processing....";
28 document.getElementById("proof").innerHTML = "";
29
30 window.genZKSnarkProof(witness, provingKey).then((p)=> {
31 const end = new Date().getTime();
32 const time = end - start;
33 document.getElementById("time").innerHTML = `Time to compute: ${time}ms`;
34 document.getElementById("proof").innerHTML = JSON.stringify(p, null, 1);
35 });
36}
37
38</script>
39<body onLoad="onLoad()">
40<h1>iden3</h1>
41<h2>Zero knowledge proof generator</h2>
42<button onClick="calcProof()">Test</button>
43<div id="time"></div>
44<pre id="proof"></pre>
45
46</body>
47</html>