arnaucube
arnaucube/snarkjsPublic Self-hosted repository
snarkjs/src/constants.js
src/constants.jsRaw
 1/*
 2    Copyright 2018 0kims association
 3
 4    This file is part of zksnark javascript library.
 5
 6    zksnark javascript library is free software: you can redistribute it and/or modify
 7    it under the terms of the GNU General Public License as published by
 8    the Free Software Foundation, either version 3 of the License, or
 9    (at your option) any later version.
10
11    zksnark javascript library is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15
16    You should have received a copy of the GNU General Public License
17    along with zksnark javascript library.  If not, see <https://www.gnu.org/licenses/>.
18*/
19const bigInt = require("big-integer");
20
21const F1Field = require("./f1field");
22const F2Field = require("./f1field");
23
24const C = {
25
26    // Module of the field
27    q : bigInt("21888242871839275222246405745257275088696311157297823662689037894645226208583"),
28
29    // Order of the group
30    r : bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617"),
31
32    g1 : [ bigInt(1), bigInt(2) ],
33    g2 :
34        [
35            [
36                bigInt("10857046999023057135944570762232829481370756359578518086990519993285655852781"),
37                bigInt("11559732032986387107991004021392285783925812861821192530917403151452391805634")
38            ],
39            [
40                bigInt("8495653923123431417604973247489272438418190587263600148770280649306958101930"),
41                bigInt("4082367875863433681332203403145435568316851327593401208105741076214120093531")
42            ]
43        ],
44
45    f2nonResidue: bigInt("21888242871839275222246405745257275088696311157297823662689037894645226208582"),
46    f6nonResidue: [ bigInt("9"), bigInt("1") ],
47    f12nonResidue: [
48    ]
49};
50
51const F1 = new F1Field(C.q);
52const F2 = new F2Field(C.q);
53
54C.two_inv= F1.inverse(bigInt(2));
55
56C.coef_b = bigInt(3);
57C.twist = [bigInt(9) , bigInt(1)];
58C.twist_coeff_b = F2.mulScalar(  F2.inverse(C.twist), C.coef_b  );
59
60
61module.exports = C;
62