You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.1 KiB

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