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.

42 lines
1.2 KiB

5 years ago
5 years ago
  1. /*
  2. Copyright 2019 0KIMS association.
  3. This file is part of websnark (Web Assembly zkSnark Prover).
  4. websnark is a free software: you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. websnark is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  11. License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with websnark. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. /* globals window */
  16. const buildGroth16 = require("./src/groth16.js");
  17. buildGroth16().then( (groth16) => {
  18. window.groth16 = groth16;
  19. window.genZKSnarkProof = function(witness, provingKey, cb) {
  20. const p = groth16.proof(witness, provingKey);
  21. if (cb) {
  22. p.then( (proof) => {
  23. cb(null, proof);
  24. }, (err) => {
  25. cb(err);
  26. });
  27. } else {
  28. return p;
  29. }
  30. };
  31. });