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.

62 lines
2.1 KiB

5 years ago
5 years ago
5 years ago
  1. /*
  2. Copyright 2018 0kims association
  3. This file is part of zksnark javascript library.
  4. zksnark javascript library is free software: you can redistribute it and/or modify
  5. it 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. zksnark javascript library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>.
  14. */
  15. const bigInt = require("big-integer");
  16. const F1Field = require("./f1field");
  17. const F2Field = require("./f1field");
  18. const C = {
  19. // Module of the field
  20. q : bigInt("21888242871839275222246405745257275088696311157297823662689037894645226208583"),
  21. // Order of the group
  22. r : bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617"),
  23. g1 : [ bigInt(1), bigInt(2) ],
  24. g2 :
  25. [
  26. [
  27. bigInt("10857046999023057135944570762232829481370756359578518086990519993285655852781"),
  28. bigInt("11559732032986387107991004021392285783925812861821192530917403151452391805634")
  29. ],
  30. [
  31. bigInt("8495653923123431417604973247489272438418190587263600148770280649306958101930"),
  32. bigInt("4082367875863433681332203403145435568316851327593401208105741076214120093531")
  33. ]
  34. ],
  35. f2nonResidue: bigInt("21888242871839275222246405745257275088696311157297823662689037894645226208582"),
  36. f6nonResidue: [ bigInt("9"), bigInt("1") ],
  37. f12nonResidue: [
  38. ]
  39. };
  40. const F1 = new F1Field(C.q);
  41. const F2 = new F2Field(C.q);
  42. C.two_inv= F1.inverse(bigInt(2));
  43. C.coef_b = bigInt(3);
  44. C.twist = [bigInt(9) , bigInt(1)];
  45. C.twist_coeff_b = F2.mulScalar( F2.inverse(C.twist), C.coef_b );
  46. module.exports = C;