Compare commits

...

4 Commits

Author SHA1 Message Date
Jordi Baylina
52a1fb895d 0.0.14 2019-08-30 10:38:19 +02:00
Jordi Baylina
1621483d3b deps 2019-08-30 10:38:04 +02:00
Jordi Baylina
425f50a9ed 0.0.13 2019-08-24 19:53:41 +02:00
Jordi Baylina
173c17dedc Change to a standard generator for Baby Jub 2019-08-03 12:46:21 +02:00
23 changed files with 938 additions and 115 deletions

View File

@@ -64,8 +64,8 @@ function generatePoint(S) {
const g = [
bigInt("17777552123799933955779906779655732241715742912184938656739573121738514868268"),
bigInt("2626589144620713026669568689430873010625803728049924121243784502389097019475")];
bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"),
bigInt("16950150798460657717958625567821834550301663161624707787222815936182638968203")];
// Sanity check
if (!babyJub.inCurve(g)) {

View File

@@ -88,8 +88,8 @@ template BabyPbk() {
signal output Ay;
var BASE8 = [
17777552123799933955779906779655732241715742912184938656739573121738514868268,
2626589144620713026669568689430873010625803728049924121243784502389097019475
5299619240641551281634865583518297030282874472190772894086521144482721001553,
16950150798460657717958625567821834550301663161624707787222815936182638968203
];
component pvkBits = Num2Bits(253);

View File

@@ -123,8 +123,8 @@ template EdDSAVerifier(n) {
// Calculate left side of equation left = S*B8
var BASE8 = [
17777552123799933955779906779655732241715742912184938656739573121738514868268,
2626589144620713026669568689430873010625803728049924121243784502389097019475
5299619240641551281634865583518297030282874472190772894086521144482721001553,
16950150798460657717958625567821834550301663161624707787222815936182638968203
];
component mulFix = EscalarMulFix(256, BASE8);
for (i=0; i<256; i++) {

View File

@@ -101,8 +101,8 @@ template EdDSAMiMCVerifier() {
// Calculate left side of equation left = S*B8
var BASE8 = [
17777552123799933955779906779655732241715742912184938656739573121738514868268,
2626589144620713026669568689430873010625803728049924121243784502389097019475
5299619240641551281634865583518297030282874472190772894086521144482721001553,
16950150798460657717958625567821834550301663161624707787222815936182638968203
];
component mulFix = EscalarMulFix(253, BASE8);
for (i=0; i<253; i++) {

View File

@@ -101,8 +101,8 @@ template EdDSAMiMCSpongeVerifier() {
// Calculate left side of equation left = S*B8
var BASE8 = [
17777552123799933955779906779655732241715742912184938656739573121738514868268,
2626589144620713026669568689430873010625803728049924121243784502389097019475
5299619240641551281634865583518297030282874472190772894086521144482721001553,
16950150798460657717958625567821834550301663161624707787222815936182638968203
];
component mulFix = EscalarMulFix(253, BASE8);
for (i=0; i<253; i++) {

View File

@@ -100,8 +100,8 @@ template EdDSAPoseidonVerifier() {
// Calculate left side of equation left = S*B8
var BASE8 = [
17777552123799933955779906779655732241715742912184938656739573121738514868268,
2626589144620713026669568689430873010625803728049924121243784502389097019475
5299619240641551281634865583518297030282874472190772894086521144482721001553,
16950150798460657717958625567821834550301663161624707787222815936182638968203
];
component mulFix = EscalarMulFix(253, BASE8);
for (i=0; i<253; i++) {

111
package-lock.json generated
View File

@@ -1,13 +1,13 @@
{
"name": "circomlib",
"version": "0.0.12",
"version": "0.0.14",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@babel/code-frame": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0.tgz",
"integrity": "sha512-OfC2uemaknXr87bdLUkWog7nYuliM9Ij5HUcajsVcMCpQrcLmtxRbVFTIqmcSkSeYRBFBRxs2FiUqFJDLdiebA==",
"version": "7.5.5",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz",
"integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==",
"requires": {
"@babel/highlight": "^7.0.0"
}
@@ -44,14 +44,14 @@
"integrity": "sha512-QcAKpaO6nhHLlxWBvpc4WeLrTvPqlHOvaj0s5GriKkA1zq+bsFBPpfYCvQhLqLgYlIko8A9YrPdaMHCo5mBcpg=="
},
"acorn": {
"version": "6.2.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.2.0.tgz",
"integrity": "sha512-8oe72N3WPMjA+2zVG71Ia0nXZ8DpQH+QyyHO+p06jT8eg8FGG3FbcUIi8KziHlAfheJQZeoqbvq1mQSQHXKYLw=="
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.3.0.tgz",
"integrity": "sha512-/czfa8BwS88b9gWQVhc8eknunSA2DoJpJyTQkhheIf5E48u1N0R4q/YxxsAeqRrmK9TQ/uYfgLDfZo91UlANIA=="
},
"acorn-jsx": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.1.tgz",
"integrity": "sha512-HJ7CfNHrfJLlNTzIEUTj43LNWGkqpRLxm3YjAlcD0ACydk9XynzYsCBHxut+iqt+1aBXkx9UP/w/ZqMr13XIzg=="
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.0.2.tgz",
"integrity": "sha512-tiNTrP1MP0QrChmD2DdupCr6HWSFeKVw5d/dHTu4Y7rkAkRhU/Dt7dphAfIUyxtHpl/eBVip5uTNSpQJHylpAw=="
},
"aes-js": {
"version": "3.0.0",
@@ -59,9 +59,9 @@
"integrity": "sha1-4h3xCtbCBTKVvLuNq0Cwnb6ofk0="
},
"ajv": {
"version": "6.10.1",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.1.tgz",
"integrity": "sha512-w1YQaVGNC6t2UCPjEawK/vo/dG8OOrVtUmhBT1uJJYxbl5kU2Tj3v6LGqBcsysN1yhuCStJCCA3GqdvKY8sqXQ==",
"version": "6.10.2",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.2.tgz",
"integrity": "sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw==",
"requires": {
"fast-deep-equal": "^2.0.1",
"fast-json-stable-stringify": "^2.0.0",
@@ -1166,14 +1166,17 @@
}
},
"eslint-utils": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.3.1.tgz",
"integrity": "sha512-Z7YjnIldX+2XMcjr7ZkgEsOj/bREONV60qYeB/bjMAqqqZ4zxKyWX+BOUkdmRmA9riiIPVvo5x86m5elviOk0Q=="
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-1.4.2.tgz",
"integrity": "sha512-eAZS2sEUMlIeCjBeubdj45dmBHQwPHWyBcT1VSYB7o9x9WRRqKxyUoiXlRjyAwzN7YEzHJlYg0NmzDRWx6GP4Q==",
"requires": {
"eslint-visitor-keys": "^1.0.0"
}
},
"eslint-visitor-keys": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz",
"integrity": "sha512-qzm/XxIbxm/FHyH341ZrbnMUpe+5Bocte9xkmFMzPMjRaZMcXww+MpBptFvtU+79L362nqiLhekCxCxDPaUMBQ=="
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-1.1.0.tgz",
"integrity": "sha512-8y9YjtM1JBJU/A9Kc+SbaOV4y29sSWckBwMHa+FGtVj5gN/sbnKDf6xJUl+8g7FAij9LVaP8C24DUiH/f/2Z9A=="
},
"espree": {
"version": "5.0.1",
@@ -1207,14 +1210,14 @@
}
},
"estraverse": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz",
"integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM="
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz",
"integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw=="
},
"esutils": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz",
"integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs="
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g=="
},
"eth-ens-namehash": {
"version": "2.0.8",
@@ -1433,9 +1436,9 @@
}
},
"external-editor": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.0.3.tgz",
"integrity": "sha512-bn71H9+qWoOQKyZDo25mOMVpSmXROAsTJVVVYzrrtol3d4y+AsKjf4Iwl2Q+IuT0kFSQ1qo166UuIwqYq7mGnA==",
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz",
"integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==",
"requires": {
"chardet": "^0.7.0",
"iconv-lite": "^0.4.24",
@@ -2989,9 +2992,9 @@
"integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw=="
},
"inquirer": {
"version": "6.4.1",
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.4.1.tgz",
"integrity": "sha512-/Jw+qPZx4EDYsaT6uz7F4GJRNFMRdKNeUZw3ZnKV8lyuUgz/YWRCSUAJMZSVhSq4Ec0R2oYnyi6b3d4JXcL5Nw==",
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-6.5.2.tgz",
"integrity": "sha512-cntlB5ghuB0iuO65Ovoi8ogLHiWGs/5yNrtUcKjFhSSiVeAIVpD7koaSU9RM8mpXw5YDi9RdYXGQMaOURB7ycQ==",
"requires": {
"ansi-escapes": "^3.2.0",
"chalk": "^2.4.2",
@@ -2999,7 +3002,7 @@
"cli-width": "^2.0.0",
"external-editor": "^3.0.3",
"figures": "^2.0.0",
"lodash": "^4.17.11",
"lodash": "^4.17.12",
"mute-stream": "0.0.7",
"run-async": "^2.2.0",
"rxjs": "^6.4.0",
@@ -3393,9 +3396,9 @@
}
},
"lodash": {
"version": "4.17.11",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg=="
"version": "4.17.15",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
},
"make-iterator": {
"version": "1.0.1",
@@ -4700,15 +4703,29 @@
}
},
"snarkjs": {
"version": "0.1.11",
"resolved": "https://registry.npmjs.org/snarkjs/-/snarkjs-0.1.11.tgz",
"integrity": "sha512-NoMNn03Uwbt18V340ZlHSZscyfIu8F6fMOL7LT9Xr1zQY/nmzScM8442ATyJfzSI5bDTAz1QQGbCerP2BCKljA==",
"version": "0.1.18",
"resolved": "https://registry.npmjs.org/snarkjs/-/snarkjs-0.1.18.tgz",
"integrity": "sha512-JWZMBvPPIL424+QCY0PtreIiHTRoX4h4qYvKv3nqKPVZl0T7sw3B/ZeizrCVRz7Jr9vrwZxmzJ0XIg6D1yC8Mg==",
"requires": {
"big-integer": "^1.6.35",
"chai": "^4.1.2",
"big-integer": "^1.6.43",
"chai": "^4.2.0",
"escape-string-regexp": "^1.0.5",
"eslint": "^5.3.0",
"yargs": "^12.0.2"
"eslint": "^5.16.0",
"keccak": "^2.0.0",
"yargs": "^12.0.5"
},
"dependencies": {
"keccak": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/keccak/-/keccak-2.0.0.tgz",
"integrity": "sha512-rKe/lRr0KGhjoz97cwg+oeT1Rj/Y4cjae6glArioUC8JBF9ROGZctwIaaruM7d7naovME4Q8WcQSO908A8qcyQ==",
"requires": {
"bindings": "^1.2.1",
"inherits": "^2.0.3",
"nan": "^2.2.1",
"safe-buffer": "^5.1.0"
}
}
}
},
"source-map": {
@@ -4904,12 +4921,12 @@
}
},
"table": {
"version": "5.4.1",
"resolved": "https://registry.npmjs.org/table/-/table-5.4.1.tgz",
"integrity": "sha512-E6CK1/pZe2N75rGZQotFOdmzWQ1AILtgYbMAbAjvms0S1l5IDB47zG3nCnFGB/w+7nB3vKofbLXCH7HPBo864w==",
"version": "5.4.6",
"resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz",
"integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==",
"requires": {
"ajv": "^6.9.1",
"lodash": "^4.17.11",
"ajv": "^6.10.2",
"lodash": "^4.17.14",
"slice-ansi": "^2.1.0",
"string-width": "^3.0.0"
},

View File

@@ -1,6 +1,6 @@
{
"name": "circomlib",
"version": "0.0.12",
"version": "0.0.14",
"description": "Basic circuits library for Circom",
"main": "index.js",
"directories": {
@@ -26,7 +26,7 @@
"dependencies": {
"blake-hash": "^1.1.0",
"blake2b": "^2.1.3",
"snarkjs": "0.1.11",
"snarkjs": "^0.1.18",
"typedarray-to-buffer": "^3.1.5",
"web3": "^1.0.0-beta.55"
},

View File

@@ -7,19 +7,23 @@ exports.inCurve = inCurve;
exports.inSubgroup = inSubgroup;
exports.packPoint = packPoint;
exports.unpackPoint = unpackPoint;
exports.Generator = [
bigInt("995203441582195749578291179787384436505546430278305826713579947235728471134"),
bigInt("5472060717959818805561601436314318772137091100104008585924551046643952123905")
];
exports.Base8 = [
bigInt("17777552123799933955779906779655732241715742912184938656739573121738514868268"),
bigInt("2626589144620713026669568689430873010625803728049924121243784502389097019475")
bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"),
bigInt("16950150798460657717958625567821834550301663161624707787222815936182638968203")
];
exports.order = bigInt("21888242871839275222246405745257275088614511777268538073601725287587578984328");
exports.subOrder = exports.order.shr(3);
exports.p = bn128.r;
exports.A = bigInt("168700");
exports.D = bigInt("168696");
function addPoint(a,b) {
const q = bn128.r;
const cta = bigInt("168700");
const d = bigInt("168696");
const res = [];
@@ -27,8 +31,8 @@ function addPoint(a,b) {
res[0] = bigInt((a[0]*b[1] + b[0]*a[1]) * bigInt(bigInt("1") + d*a[0]*b[0]*a[1]*b[1]).inverse(q)).affine(q);
res[1] = bigInt((a[1]*b[1] - cta*a[0]*b[0]) * bigInt(bigInt("1") - d*a[0]*b[0]*a[1]*b[1]).inverse(q)).affine(q);
*/
res[0] = bigInt((bigInt(a[0]).mul(b[1]).add(bigInt(b[0]).mul(a[1]))).mul(bigInt(bigInt("1").add(d.mul(a[0]).mul(b[0]).mul(a[1]).mul(b[1]))).inverse(q))).affine(q);
res[1] = bigInt((bigInt(a[1]).mul(b[1]).sub(cta.mul(a[0]).mul(b[0]))).mul(bigInt(bigInt("1").sub(d.mul(a[0]).mul(b[0]).mul(a[1]).mul(b[1]))).inverse(q))).affine(q);
res[0] = bigInt((bigInt(a[0]).mul(b[1]).add(bigInt(b[0]).mul(a[1]))).mul(bigInt(bigInt("1").add(exports.D.mul(a[0]).mul(b[0]).mul(a[1]).mul(b[1]))).inverse(q))).affine(q);
res[1] = bigInt((bigInt(a[1]).mul(b[1]).sub(exports.A.mul(a[0]).mul(b[0]))).mul(bigInt(bigInt("1").sub(exports.D.mul(a[0]).mul(b[0]).mul(a[1]).mul(b[1]))).inverse(q))).affine(q);
return res;
}
@@ -58,15 +62,12 @@ function inSubgroup(P) {
function inCurve(P) {
const F = bn128.Fr;
const a = bigInt("168700");
const d = bigInt("168696");
const x2 = F.square(P[0]);
const y2 = F.square(P[1]);
if (!F.equals(
F.add(F.mul(a, x2), y2),
F.add(F.one, F.mul(F.mul(x2, y2), d)))) return false;
F.add(F.mul(exports.A, x2), y2),
F.add(F.one, F.mul(F.mul(x2, y2), exports.D)))) return false;
return true;
}
@@ -92,14 +93,11 @@ function unpackPoint(_buff) {
P[1] = bigInt.leBuff2int(buff);
if (P[1].greaterOrEquals(exports.p)) return null;
const a = bigInt("168700");
const d = bigInt("168696");
const y2 = F.square(P[1]);
let x = F.sqrt(F.div(
F.sub(F.one, y2),
F.sub(a, F.mul(d, y2))));
F.sub(exports.A, F.mul(exports.D, y2))));
if (x == null) return null;

View File

@@ -28,6 +28,16 @@ describe("Baby Jub js test", function () {
assert(out[1].equals(1));
});
it("Should base be 8*generator", () => {
let res;
res = babyjub.addPoint(babyjub.Generator, babyjub.Generator);
res = babyjub.addPoint(res, res);
res = babyjub.addPoint(res, res);
assert(res[0].equals(babyjub.Base8[0]));
assert(res[1].equals(babyjub.Base8[1]));
});
it("Should add 2 same numbers", () => {
const p1 = [

776
test/circuits/circuit.json Normal file
View File

@@ -0,0 +1,776 @@
{
"mainCode": "{\n {\n }\n}\n",
"signalName2Idx": {
"one": 0,
"main.in": 33,
"main.out[0][0]": 1,
"main.out[0][1]": 2,
"main.out[1][0]": 3,
"main.out[1][1]": 4,
"main.out[2][0]": 5,
"main.out[2][1]": 6,
"main.out[3][0]": 7,
"main.out[3][1]": 8,
"main.out[4][0]": 9,
"main.out[4][1]": 10,
"main.out[5][0]": 11,
"main.out[5][1]": 12,
"main.out[6][0]": 13,
"main.out[6][1]": 14,
"main.out[7][0]": 15,
"main.out[7][1]": 16,
"main.out[8][0]": 17,
"main.out[8][1]": 18,
"main.out[9][0]": 19,
"main.out[9][1]": 20,
"main.out[10][0]": 21,
"main.out[10][1]": 22,
"main.out[11][0]": 23,
"main.out[11][1]": 24,
"main.out[12][0]": 25,
"main.out[12][1]": 26,
"main.out[13][0]": 27,
"main.out[13][1]": 28,
"main.out[14][0]": 29,
"main.out[14][1]": 30,
"main.out[15][0]": 31,
"main.out[15][1]": 32,
"main.escalarMul.out[0][0]": 34,
"main.escalarMul.out[0][1]": 35,
"main.escalarMul.out[1][0]": 36,
"main.escalarMul.out[1][1]": 37,
"main.escalarMul.out[2][0]": 38,
"main.escalarMul.out[2][1]": 39,
"main.escalarMul.out[3][0]": 40,
"main.escalarMul.out[3][1]": 41,
"main.escalarMul.out[4][0]": 42,
"main.escalarMul.out[4][1]": 43,
"main.escalarMul.out[5][0]": 44,
"main.escalarMul.out[5][1]": 45,
"main.escalarMul.out[6][0]": 46,
"main.escalarMul.out[6][1]": 47,
"main.escalarMul.out[7][0]": 48,
"main.escalarMul.out[7][1]": 49,
"main.escalarMul.out[8][0]": 50,
"main.escalarMul.out[8][1]": 51,
"main.escalarMul.out[9][0]": 52,
"main.escalarMul.out[9][1]": 53,
"main.escalarMul.out[10][0]": 54,
"main.escalarMul.out[10][1]": 55,
"main.escalarMul.out[11][0]": 56,
"main.escalarMul.out[11][1]": 57,
"main.escalarMul.out[12][0]": 58,
"main.escalarMul.out[12][1]": 59,
"main.escalarMul.out[13][0]": 60,
"main.escalarMul.out[13][1]": 61,
"main.escalarMul.out[14][0]": 62,
"main.escalarMul.out[14][1]": 63,
"main.escalarMul.out[15][0]": 64,
"main.escalarMul.out[15][1]": 65
},
"components": [
{
"name": "main",
"params": {},
"template": "Main",
"inputSignals": 1
},
{
"name": "main.escalarMul",
"params": {
"base": [
"5299619240641551281634865583518297030282874472190772894086521144482721001553",
"16950150798460657717958625567821834550301663161624707787222815936182638968203"
],
"k": "0"
},
"template": "EscalarMulW4Table",
"inputSignals": 0
}
],
"componentName2Idx": {
"main": 0,
"main.escalarMul": 1
},
"signals": [
{
"names": [
"one"
],
"triggerComponents": []
},
{
"names": [
"main.out[0][0]"
],
"triggerComponents": []
},
{
"names": [
"main.out[0][1]"
],
"triggerComponents": []
},
{
"names": [
"main.out[1][0]"
],
"triggerComponents": []
},
{
"names": [
"main.out[1][1]"
],
"triggerComponents": []
},
{
"names": [
"main.out[2][0]"
],
"triggerComponents": []
},
{
"names": [
"main.out[2][1]"
],
"triggerComponents": []
},
{
"names": [
"main.out[3][0]"
],
"triggerComponents": []
},
{
"names": [
"main.out[3][1]"
],
"triggerComponents": []
},
{
"names": [
"main.out[4][0]"
],
"triggerComponents": []
},
{
"names": [
"main.out[4][1]"
],
"triggerComponents": []
},
{
"names": [
"main.out[5][0]"
],
"triggerComponents": []
},
{
"names": [
"main.out[5][1]"
],
"triggerComponents": []
},
{
"names": [
"main.out[6][0]"
],
"triggerComponents": []
},
{
"names": [
"main.out[6][1]"
],
"triggerComponents": []
},
{
"names": [
"main.out[7][0]"
],
"triggerComponents": []
},
{
"names": [
"main.out[7][1]"
],
"triggerComponents": []
},
{
"names": [
"main.out[8][0]"
],
"triggerComponents": []
},
{
"names": [
"main.out[8][1]"
],
"triggerComponents": []
},
{
"names": [
"main.out[9][0]"
],
"triggerComponents": []
},
{
"names": [
"main.out[9][1]"
],
"triggerComponents": []
},
{
"names": [
"main.out[10][0]"
],
"triggerComponents": []
},
{
"names": [
"main.out[10][1]"
],
"triggerComponents": []
},
{
"names": [
"main.out[11][0]"
],
"triggerComponents": []
},
{
"names": [
"main.out[11][1]"
],
"triggerComponents": []
},
{
"names": [
"main.out[12][0]"
],
"triggerComponents": []
},
{
"names": [
"main.out[12][1]"
],
"triggerComponents": []
},
{
"names": [
"main.out[13][0]"
],
"triggerComponents": []
},
{
"names": [
"main.out[13][1]"
],
"triggerComponents": []
},
{
"names": [
"main.out[14][0]"
],
"triggerComponents": []
},
{
"names": [
"main.out[14][1]"
],
"triggerComponents": []
},
{
"names": [
"main.out[15][0]"
],
"triggerComponents": []
},
{
"names": [
"main.out[15][1]"
],
"triggerComponents": []
},
{
"names": [
"main.in"
],
"triggerComponents": [
0
]
},
{
"names": [
"main.escalarMul.out[0][0]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[0][1]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[1][0]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[1][1]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[2][0]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[2][1]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[3][0]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[3][1]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[4][0]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[4][1]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[5][0]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[5][1]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[6][0]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[6][1]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[7][0]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[7][1]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[8][0]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[8][1]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[9][0]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[9][1]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[10][0]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[10][1]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[11][0]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[11][1]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[12][0]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[12][1]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[13][0]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[13][1]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[14][0]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[14][1]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[15][0]"
],
"triggerComponents": []
},
{
"names": [
"main.escalarMul.out[15][1]"
],
"triggerComponents": []
}
],
"constraints": [
[
{},
{
"33": "1"
},
{
"1": "21888242871839275222246405745257275088548364400416034343698204186575808495616"
}
],
[
{},
{},
{
"2": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "1"
}
],
[
{},
{},
{
"3": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "5299619240641551281634865583518297030282874472190772894086521144482721001553"
}
],
[
{},
{},
{
"4": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "16950150798460657717958625567821834550301663161624707787222815936182638968203"
}
],
[
{},
{},
{
"5": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "10031262171927540148667355526369034398030886437092045105752248699557385197826"
}
],
[
{},
{},
{
"6": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "633281375905621697187330766174974863687049529291089048651929454608812697683"
}
],
[
{},
{},
{
"7": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "2763488322167937039616325905516046217694264098671987087929565332380420898366"
}
],
[
{},
{},
{
"8": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "15305195750036305661220525648961313310481046260814497672243197092298550508693"
}
],
[
{},
{},
{
"9": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "12252886604826192316928789929706397349846234911198931249025449955069330867144"
}
],
[
{},
{},
{
"10": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "1286140751908834028607023759717162073146610688084909004843365841635476459484"
}
],
[
{},
{},
{
"11": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "11480966271046430430613841218147196773252373073876138147006741179837832100836"
}
],
[
{},
{},
{
"12": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "15148236048131954717802795400425086368006776860859772698778589175317365693546"
}
],
[
{},
{},
{
"13": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "10483991165196995731760716870725509190315033255344071753161464961897900552628"
}
],
[
{},
{},
{
"14": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "16822899191463256771813724222715007505997804748105685077895991386716774358231"
}
],
[
{},
{},
{
"15": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "20092560661213339045022877747484245238324772779820628739268223482659246842641"
}
],
[
{},
{},
{
"16": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "12112450042127193446189577552007703839818242727902437791835414514847797088033"
}
],
[
{},
{},
{
"17": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "7582035475627193640797276505418002166691739036475590846121162698650004832581"
}
],
[
{},
{},
{
"18": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "7801528930831391612913542953849263092120765287178679640990215688947513841260"
}
],
[
{},
{},
{
"19": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "4705897243203718691035604313913899717760209962238015362153877735592901317263"
}
],
[
{},
{},
{
"20": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "11533909001000295577818857040682494493436124051895563619976413559559984357704"
}
],
[
{},
{},
{
"21": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "153240920024090527149238595127650983736082984617707450012091413752625486998"
}
],
[
{},
{},
{
"22": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "4020276081434545615309760015178511782232038136121596626881988383789905359767"
}
],
[
{},
{},
{
"23": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "21605515851820432880964235241069234202284600780825340516808373216881770219365"
}
],
[
{},
{},
{
"24": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "18856460861531942120859708048677603751294231190189224157283439874962410808705"
}
],
[
{},
{},
{
"25": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "13745444942333935831105476262872495530232646590228527111681360848540626474828"
}
],
[
{},
{},
{
"26": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "12593235468414968750242085888471035041062129592669413010808753916989521208231"
}
],
[
{},
{},
{
"27": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "2645068156583085050795409844793952496341966587935372213947442411891928926825"
}
],
[
{},
{},
{
"28": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "18721023485287444620535873833099074300132272004358512346950884094158923211889"
}
],
[
{},
{},
{
"29": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "6271573312546148160329629673815240458676221818610765478794395550121752710497"
}
],
[
{},
{},
{
"30": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "20729133862440981855920571719405839551572203482913253618619962546642052100217"
}
],
[
{},
{},
{
"31": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "5958787406588418500595239545974275039455545059833263445973445578199987122248"
}
],
[
{},
{},
{
"32": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
"33": "6291453822075498887551694851992571215511219854100590306020486222643399599966"
}
]
],
"templates": {
"EscalarMulW4Table": "function(ctx) {\n ctx.setVar(\"dbl\", [], ctx.getVar(\"base\",[]));\n for (ctx.setVar(\"i\", [], \"0\");bigInt(bigInt(ctx.getVar(\"i\",[])).lt(bigInt(bigInt(ctx.getVar(\"k\",[])).mul(bigInt(\"4\")).mod(__P__))) ? 1 : 0).neq(bigInt(0));(ctx.setVar(\"i\", [], bigInt(ctx.getVar(\"i\",[])).add(bigInt(\"1\")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__)) { \n {\n ctx.setVar(\"dbl\", [], ctx.callFunction(\"pointAdd\", [ctx.getVar(\"dbl\",[\"0\"]),ctx.getVar(\"dbl\",[\"1\"]),ctx.getVar(\"dbl\",[\"0\"]),ctx.getVar(\"dbl\",[\"1\"])]));\n }\n\n }\n ctx.setSignal(\"out\", [\"0\",\"0\"], \"0\");\n ctx.assert(ctx.getSignal(\"out\", [\"0\",\"0\"]), \"0\");\n ctx.setSignal(\"out\", [\"0\",\"1\"], \"1\");\n ctx.assert(ctx.getSignal(\"out\", [\"0\",\"1\"]), \"1\");\n for (ctx.setVar(\"i\", [], \"1\");bigInt(bigInt(ctx.getVar(\"i\",[])).lt(bigInt(\"16\")) ? 1 : 0).neq(bigInt(0));(ctx.setVar(\"i\", [], bigInt(ctx.getVar(\"i\",[])).add(bigInt(\"1\")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__)) { \n {\n ctx.setVar(\"p\", [], ctx.callFunction(\"pointAdd\", [ctx.getSignal(\"out\", [bigInt(ctx.getVar(\"i\",[])).add(__P__).sub(bigInt(\"1\")).mod(__P__),\"0\"]),ctx.getSignal(\"out\", [bigInt(ctx.getVar(\"i\",[])).add(__P__).sub(bigInt(\"1\")).mod(__P__),\"1\"]),ctx.getVar(\"dbl\",[\"0\"]),ctx.getVar(\"dbl\",[\"1\"])]));\n ctx.setSignal(\"out\", [ctx.getVar(\"i\",[]),\"0\"], ctx.getVar(\"p\",[\"0\"]));\n ctx.assert(ctx.getSignal(\"out\", [ctx.getVar(\"i\",[]),\"0\"]), ctx.getVar(\"p\",[\"0\"]));\n ctx.setSignal(\"out\", [ctx.getVar(\"i\",[]),\"1\"], ctx.getVar(\"p\",[\"1\"]));\n ctx.assert(ctx.getSignal(\"out\", [ctx.getVar(\"i\",[]),\"1\"]), ctx.getVar(\"p\",[\"1\"]));\n }\n\n }\n}\n",
"Main": "function(ctx) {\n ctx.setVar(\"base\", [], [\"5299619240641551281634865583518297030282874472190772894086521144482721001553\",\"16950150798460657717958625567821834550301663161624707787222815936182638968203\"]);\n for (ctx.setVar(\"i\", [], \"0\");bigInt(bigInt(ctx.getVar(\"i\",[])).lt(bigInt(\"16\")) ? 1 : 0).neq(bigInt(0));(ctx.setVar(\"i\", [], bigInt(ctx.getVar(\"i\",[])).add(bigInt(\"1\")).mod(__P__))).add(__P__).sub(bigInt(1)).mod(__P__)) { \n {\n ctx.setSignal(\"out\", [ctx.getVar(\"i\",[]),\"0\"], bigInt(ctx.getPin(\"escalarMul\", [], \"out\", [ctx.getVar(\"i\",[]),\"0\"])).mul(bigInt(ctx.getSignal(\"in\", []))).mod(__P__));\n ctx.assert(ctx.getSignal(\"out\", [ctx.getVar(\"i\",[]),\"0\"]), bigInt(ctx.getPin(\"escalarMul\", [], \"out\", [ctx.getVar(\"i\",[]),\"0\"])).mul(bigInt(ctx.getSignal(\"in\", []))).mod(__P__));\n ctx.setSignal(\"out\", [ctx.getVar(\"i\",[]),\"1\"], bigInt(ctx.getPin(\"escalarMul\", [], \"out\", [ctx.getVar(\"i\",[]),\"1\"])).mul(bigInt(ctx.getSignal(\"in\", []))).mod(__P__));\n ctx.assert(ctx.getSignal(\"out\", [ctx.getVar(\"i\",[]),\"1\"]), bigInt(ctx.getPin(\"escalarMul\", [], \"out\", [ctx.getVar(\"i\",[]),\"1\"])).mul(bigInt(ctx.getSignal(\"in\", []))).mod(__P__));\n }\n\n }\n}\n"
},
"functions": {
"pointAdd": {
"params": [
"x1",
"y1",
"x2",
"y2"
],
"func": "function(ctx) {\n ctx.setVar(\"a\", [], \"168700\");\n ctx.setVar(\"d\", [], \"168696\");\n ctx.setVar(\"res\", [\"0\"], bigInt(bigInt(bigInt(ctx.getVar(\"x1\",[])).mul(bigInt(ctx.getVar(\"y2\",[]))).mod(__P__)).add(bigInt(bigInt(ctx.getVar(\"y1\",[])).mul(bigInt(ctx.getVar(\"x2\",[]))).mod(__P__))).mod(__P__)).mul( bigInt(bigInt(\"1\").add(bigInt(bigInt(bigInt(bigInt(bigInt(ctx.getVar(\"d\",[])).mul(bigInt(ctx.getVar(\"x1\",[]))).mod(__P__)).mul(bigInt(ctx.getVar(\"x2\",[]))).mod(__P__)).mul(bigInt(ctx.getVar(\"y1\",[]))).mod(__P__)).mul(bigInt(ctx.getVar(\"y2\",[]))).mod(__P__))).mod(__P__)).inverse(__P__) ).mod(__P__));\n ctx.setVar(\"res\", [\"1\"], bigInt(bigInt(bigInt(ctx.getVar(\"y1\",[])).mul(bigInt(ctx.getVar(\"y2\",[]))).mod(__P__)).add(__P__).sub(bigInt(bigInt(bigInt(ctx.getVar(\"a\",[])).mul(bigInt(ctx.getVar(\"x1\",[]))).mod(__P__)).mul(bigInt(ctx.getVar(\"x2\",[]))).mod(__P__))).mod(__P__)).mul( bigInt(bigInt(\"1\").add(__P__).sub(bigInt(bigInt(bigInt(bigInt(bigInt(ctx.getVar(\"d\",[])).mul(bigInt(ctx.getVar(\"x1\",[]))).mod(__P__)).mul(bigInt(ctx.getVar(\"x2\",[]))).mod(__P__)).mul(bigInt(ctx.getVar(\"y1\",[]))).mod(__P__)).mul(bigInt(ctx.getVar(\"y2\",[]))).mod(__P__))).mod(__P__)).inverse(__P__) ).mod(__P__));\n return ctx.getVar(\"res\",[]);;\n}\n"
}
},
"nPrvInputs": 0,
"nPubInputs": 1,
"nInputs": 1,
"nOutputs": 32,
"nVars": 34,
"nConstants": 32,
"nSignals": 66
}

View File

@@ -7,8 +7,8 @@ template Main() {
var i;
var base = [17777552123799933955779906779655732241715742912184938656739573121738514868268,
2626589144620713026669568689430873010625803728049924121243784502389097019475]
var base = [5299619240641551281634865583518297030282874472190772894086521144482721001553,
16950150798460657717958625567821834550301663161624707787222815936182638968203]
component escalarMul = EscalarMul(256, base);

View File

@@ -6,8 +6,8 @@ template Main() {
signal input in;
signal output out[2];
var base = [17777552123799933955779906779655732241715742912184938656739573121738514868268,
2626589144620713026669568689430873010625803728049924121243784502389097019475]
var base = [5299619240641551281634865583518297030282874472190772894086521144482721001553,
16950150798460657717958625567821834550301663161624707787222815936182638968203]
component n2b = Num2Bits(253);

View File

@@ -7,8 +7,8 @@ template Main() {
var i;
var base = [17777552123799933955779906779655732241715742912184938656739573121738514868268,
2626589144620713026669568689430873010625803728049924121243784502389097019475]
var base = [5299619240641551281634865583518297030282874472190772894086521144482721001553,
16950150798460657717958625567821834550301663161624707787222815936182638968203]
component escalarMul = EscalarMul(256, base);

View File

@@ -6,8 +6,8 @@ template Main() {
signal input e;
signal output out[2];
var base = [17777552123799933955779906779655732241715742912184938656739573121738514868268,
2626589144620713026669568689430873010625803728049924121243784502389097019475]
var base = [5299619240641551281634865583518297030282874472190772894086521144482721001553,
16950150798460657717958625567821834550301663161624707787222815936182638968203]
component n2b = Num2Bits(253);

View File

@@ -1,6 +1,6 @@
include "../../circuits/escalarmulw4table.circom";
var base = [17777552123799933955779906779655732241715742912184938656739573121738514868268,
2626589144620713026669568689430873010625803728049924121243784502389097019475]
var base = [5299619240641551281634865583518297030282874472190772894086521144482721001553,
16950150798460657717958625567821834550301663161624707787222815936182638968203]
component main = EscalarMulW4Table(base, 0);

View File

@@ -1,6 +1,17 @@
include "../../circuits/escalarmulw4table.circom";
var base = [17777552123799933955779906779655732241715742912184938656739573121738514868268,
2626589144620713026669568689430873010625803728049924121243784502389097019475];
component main = EscalarMulW4Table(base, 0);
template Main() {
signal input in;
signal output out[16][2];
var base = [5299619240641551281634865583518297030282874472190772894086521144482721001553,
16950150798460657717958625567821834550301663161624707787222815936182638968203];
component escalarMul = EscalarMulW4Table(base, 0);
for (var i=0; i<16; i++) {
out[i][0] <== escalarMul.out[i][0]*in;
out[i][1] <== escalarMul.out[i][1]*in;
}
}
component main = Main();

View File

@@ -1,6 +1,17 @@
include "../../circuits/escalarmulw4table.circom";
var base = [17777552123799933955779906779655732241715742912184938656739573121738514868268,
2626589144620713026669568689430873010625803728049924121243784502389097019475]
component main = EscalarMulW4Table(base, 3);
template Main() {
signal input in;
signal output out[16][2];
var base = [5299619240641551281634865583518297030282874472190772894086521144482721001553,
16950150798460657717958625567821834550301663161624707787222815936182638968203];
component escalarMul = EscalarMulW4Table(base, 3);
for (var i=0; i<16; i++) {
out[i][0] <== escalarMul.out[i][0]*in;
out[i][1] <== escalarMul.out[i][1]*in;
}
}
component main = Main();

View File

@@ -23,24 +23,24 @@ describe("EdDSA js test", function () {
const pubKey = eddsa.prv2pub(prvKey);
assert.equal(pubKey[0].toString(),
"2610057752638682202795145288373380503107623443963127956230801721756904484787");
"13277427435165878497778222415993513565335242147425444199013288855685581939618");
assert.equal(pubKey[1].toString(),
"16617171478497210597712478520507818259149717466230047843969353176573634386897");
"13622229784656158136036771217484571176836296686641868549125388198837476602820");
const pPubKey = babyJub.packPoint(pubKey);
const signature = eddsa.signMiMC(prvKey, msg);
assert.equal(signature.R8[0].toString(),
"4974729414807584049518234760796200867685098748448054182902488636762478901554");
"11384336176656855268977457483345535180380036354188103142384839473266348197733");
assert.equal(signature.R8[1].toString(),
"18714049394522540751536514815950425694461287643205706667341348804546050128733");
"15383486972088797283337779941324724402501462225528836549661220478783371668959");
assert.equal(signature.S.toString(),
"2171284143457722024136077617757713039502332290425057126942676527240038689549");
"2523202440825208709475937830811065542425109372212752003460238913256192595070");
const pSignature = eddsa.packSignature(signature);
assert.equal(pSignature.toString("hex"), ""+
"5dfb6f843c023fe3e52548ccf22e55c81b426f7af81b4f51f7152f2fcfc65f29"+
"0dab19c5a0a75973cd75a54780de0c3a41ede6f57396fe99b5307fff3ce7cc04");
"dfedb4315d3f2eb4de2d3c510d7a987dcab67089c8ace06308827bf5bcbe02a2"+
"7ed40dab29bf993c928e789d007387998901a24913d44fddb64b1f21fc149405");
const uSignature = eddsa.unpackSignature(pSignature);
assert(eddsa.verifyMiMC(msg, uSignature, pubKey));

View File

@@ -36,10 +36,10 @@ describe("Exponentioation test", () => {
console.log("NConstrains: " + circuit.nConstraints);
const w = circuit.calculateWitness({});
const w = circuit.calculateWitness({in: 1});
let g = [bigInt("17777552123799933955779906779655732241715742912184938656739573121738514868268"),
bigInt("2626589144620713026669568689430873010625803728049924121243784502389097019475")]
let g = [bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"),
bigInt("16950150798460657717958625567821834550301663161624707787222815936182638968203")]
dbl= [bigInt("0"), snarkjs.bigInt("1")];
@@ -72,10 +72,10 @@ describe("Exponentioation test", () => {
console.log("NConstrains: " + circuit.nConstraints);
const w = circuit.calculateWitness({});
const w = circuit.calculateWitness({in: 1});
let g = [snarkjs.bigInt("17777552123799933955779906779655732241715742912184938656739573121738514868268"),
snarkjs.bigInt("2626589144620713026669568689430873010625803728049924121243784502389097019475")]
let g = [snarkjs.bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"),
snarkjs.bigInt("16950150798460657717958625567821834550301663161624707787222815936182638968203")]
for (let i=0; i<12;i++) {
g = addPoint(g,g);
@@ -116,8 +116,8 @@ describe("Exponentioation test", () => {
assert(circuit.checkWitness(w));
let g = [snarkjs.bigInt("17777552123799933955779906779655732241715742912184938656739573121738514868268"),
snarkjs.bigInt("2626589144620713026669568689430873010625803728049924121243784502389097019475")]
let g = [snarkjs.bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"),
snarkjs.bigInt("16950150798460657717958625567821834550301663161624707787222815936182638968203")]
let c = [0n, 1n];

View File

@@ -18,8 +18,8 @@ describe("Escalarmul test", function () {
this.timeout(100000);
let g = [
snarkjs.bigInt("17777552123799933955779906779655732241715742912184938656739573121738514868268"),
snarkjs.bigInt("2626589144620713026669568689430873010625803728049924121243784502389097019475")
snarkjs.bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"),
snarkjs.bigInt("16950150798460657717958625567821834550301663161624707787222815936182638968203")
];
before( async() => {

View File

@@ -54,8 +54,8 @@ describe("Escalarmul test", function () {
const s = bigInt("2351960337287830298912035165133676222414898052661454064215017316447594616519");
const base8 = [
bigInt("17777552123799933955779906779655732241715742912184938656739573121738514868268"),
bigInt("2626589144620713026669568689430873010625803728049924121243784502389097019475")
bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"),
bigInt("16950150798460657717958625567821834550301663161624707787222815936182638968203")
];
const w = circuit.calculateWitness({"e": s});
@@ -74,8 +74,8 @@ describe("Escalarmul test", function () {
it("Should generate scalar mul of the firsts 50 elements", async () => {
const base8 = [
bigInt("17777552123799933955779906779655732241715742912184938656739573121738514868268"),
bigInt("2626589144620713026669568689430873010625803728049924121243784502389097019475")
bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"),
bigInt("16950150798460657717958625567821834550301663161624707787222815936182638968203")
];
for (let i=0; i<50; i++) {

View File

@@ -15,8 +15,8 @@ describe("Montgomery test", function () {
let circuitMDouble;
let g = [
snarkjs.bigInt("17777552123799933955779906779655732241715742912184938656739573121738514868268"),
snarkjs.bigInt("2626589144620713026669568689430873010625803728049924121243784502389097019475")];
snarkjs.bigInt("5299619240641551281634865583518297030282874472190772894086521144482721001553"),
snarkjs.bigInt("16950150798460657717958625567821834550301663161624707787222815936182638968203")];
let mg, mg2, g2, g3, mg3;