Merge pull request #1 from bellesmarta/master

Changes README, copyright and typos
This commit is contained in:
Jordi Baylina 2018-09-12 11:04:21 +02:00 committed by GitHub
commit d425a48092
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
24 changed files with 272 additions and 326 deletions

2
.gitignore vendored
View File

@ -61,3 +61,5 @@ typings/
.next .next
tmp tmp
.DS_Store

View File

@ -1,20 +1,20 @@
# javascript implementation of zkSnark # JavaScript implementation of zkSNARKs.
This is a javascript implementation of zkSnarks. This is a JavaScript implementation of zkSNARK schemes.
This library allows to do the trusted setup, generate proofs and verify the proofs. This library allows to do the trusted setup, generate proofs and verify the proofs.
This library uses the compiled circuits generated by the jaz compiler. This library uses the compiled circuits generated by the jaz compiler.
## Install ## Install.
``` ```
npm install zkSnark npm install zksnark
``` ```
## Usage ## Usage.
### import ### Import.
``` ```
const zkSnark = require("zksnark"); const zkSnark = require("zksnark");
@ -71,11 +71,11 @@ const circuit = new zkSnark.Circuit(circuitDef);
// input is a key value object where keys are the signal names // input is a key value object where keys are the signal names
// of all the inputs (public and private) // of all the inputs (public and private)
// returns an array of values that represent the witness // returns an array of values representing the witness
circuit.calculateWitness(input) circuit.calculateWitness(input)
``` ```
### Trusted setup ### Trusted setup.
``` ```
const setup = zkSnark.setup(circuit); const setup = zkSnark.setup(circuit);
@ -84,7 +84,7 @@ fs.writeFileSink("myCircuit.vk_verifier", JSON.stringify(setup.vk_verifier), "ut
setup.toxic // Must be discarded. setup.toxic // Must be discarded.
``` ```
### Generate proof ### Generate proof.
``` ```
const circuitDef = JSON.parse(fs.readFileSync("myCircuit.cir", "utf8")); const circuitDef = JSON.parse(fs.readFileSync("myCircuit.cir", "utf8"));
@ -99,7 +99,7 @@ const vk_proof = JSON.parse(fs.readFileSync("myCircuit.vk_proof", "utf8"));
const {proof, publicSignals} = zkSnark.genProof(vk_proof, witness); const {proof, publicSignals} = zkSnark.genProof(vk_proof, witness);
``` ```
### Verifier ### Verifier.
``` ```
const vk_verifier = JSON.parse(fs.readFileSync("myCircuit.vk_verifier", "utf8")); const vk_verifier = JSON.parse(fs.readFileSync("myCircuit.vk_verifier", "utf8"));

View File

@ -1,66 +0,0 @@
const bigInt = require("../src/bigint.js");
const ZqField = require("../src/zqfield.js");
const r = bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");
const s = 28;
const nqr_to_t = bigInt("19103219067921713944291392827692070036145651957329286315305642004821462161904");
const t_minus_1_over_2 = bigInt("40770029410420498293352137776570907027550720424234931066070132305055");
const root_unity = bigInt("19103219067921713944291392827692070036145651957329286315305642004821462161904");
const t = bigInt("81540058820840996586704275553141814055101440848469862132140264610111");
const F = new ZqField(r);
function sqrt(a) {
let v = s;
let z = nqr_to_t;
let w = F.exp(a, t_minus_1_over_2);
let x = F.mul(a, w);
let b = F.mul(x, w);
// compute square root with Tonelli--Shanks
// (does not terminate if not a square!)
while (!F.equals(b, F.one))
{
let m = 0;
let b2m = b;
while (!F.equals(b2m, F.one))
{
/* invariant: b2m = b^(2^m) after entering this loop */
b2m = F.square(b2m);
m += 1;
}
let j = v-m-1;
w = z;
while (j > 0)
{
w = F.square(w);
--j;
} // w = z^2^(v-m-1)
z = F.square(w);
b = F.mul(b, z);
x = F.mul(x, w);
v = m;
}
return x;
}
const p_minus1= F.sub(r,bigInt(1));
const gen = bigInt(bigInt(5));
const twoto28= F.exp(bigInt(2), bigInt(28));
const rem = F.div(p_minus1, twoto28);
const w28 = F.exp(gen, rem);
const one = F.exp(w28, twoto28);
console.log(F.toString(w28));
console.log(w28.toString(10));
console.log(F.toString(one));

View File

@ -1,20 +1,20 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
exports.Circuit = require("./src/circuit.js"); exports.Circuit = require("./src/circuit.js");

View File

@ -1,7 +1,7 @@
{ {
"name": "zksnark", "name": "zksnark",
"version": "0.0.5", "version": "0.0.5",
"description": "zkSnark implementation in javascript", "description": "zkSNARKs implementation in JavaScript",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"test": "mocha" "test": "mocha"

View File

@ -1,20 +1,20 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
/* global BigInt */ /* global BigInt */

View File

@ -1,21 +1,22 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
const bigInt = require("./bigint.js"); const bigInt = require("./bigint.js");
const assert = require("assert"); const assert = require("assert");

View File

@ -1,22 +1,23 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
const bigInt = require("./bigInt");
const bigInt = require("./bigint");
module.exports = calculateWitness; module.exports = calculateWitness;

View File

@ -1,21 +1,22 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
const bigInt = require("./bigint.js"); const bigInt = require("./bigint.js");
const __P__ = bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617"); const __P__ = bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617");

View File

@ -1,21 +1,22 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
const fUtils = require("./futils.js"); const fUtils = require("./futils.js");
class F2Field { class F2Field {

View File

@ -1,21 +1,22 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
const fUtils = require("./futils.js"); const fUtils = require("./futils.js");
class F3Field { class F3Field {

View File

@ -1,21 +1,22 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
const bigInt = require("./bigint.js"); const bigInt = require("./bigint.js");
exports.mulScalar = (F, base, e) =>{ exports.mulScalar = (F, base, e) =>{

View File

@ -1,21 +1,22 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
const fUtils = require("./futils.js"); const fUtils = require("./futils.js");
class GCurve { class GCurve {

View File

@ -1,27 +1,27 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
/* /*
This library do operations on polynomials where their coefficients are in field F This library does operations on polynomials with coefficients in a field F.
The polynomial P(x) = p0 + p1 * x + p2 * x^2 + p3 * x^3, ... A polynomial P(x) = p0 + p1 * x + p2 * x^2 + ... + pn * x^n is represented
is represented by the array [ p0, p1, p2, p3, ... ] by the array [ p0, p1, p2, ... , pn ].
*/ */
const bigInt = require("./bigint.js"); const bigInt = require("./bigint.js");

View File

@ -1,20 +1,20 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
const BN128 = require("./bn128.js"); const BN128 = require("./bn128.js");

View File

@ -1,20 +1,20 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
const fUtils = require("./futils.js"); const fUtils = require("./futils.js");

View File

@ -1,20 +1,20 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
const bigInt = require("./bigint.js"); const bigInt = require("./bigint.js");

View File

@ -1,20 +1,20 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
const BN128 = require("./bn128.js"); const BN128 = require("./bn128.js");

View File

@ -1,20 +1,20 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
const crypto = require("crypto"); const crypto = require("crypto");

View File

@ -1,21 +1,22 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
const chai = require("chai"); const chai = require("chai");
const bigInt = require("../src/bigint.js"); const bigInt = require("../src/bigint.js");
@ -44,7 +45,6 @@ describe("F1 testing", () => {
}); });
}); });
describe("Curve G1 Test", () => { describe("Curve G1 Test", () => {
it("r*one == 0", () => { it("r*one == 0", () => {
const bn128 = new BN128(); const bn128 = new BN128();

View File

@ -1,27 +1,28 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
const chai = require("chai"); const chai = require("chai");
const fs = require("fs"); const fs = require("fs");
const path = require("path"); const path = require("path");
const Circuit = require("../src/circuit.js"); const Circuit = require("../src/circuit.js");
const BN128 = require("../src/BN128.js"); const BN128 = require("../src/bn128.js");
const F1Field = require("../src/zqfield.js"); const F1Field = require("../src/zqfield.js");
const assert = chai.assert; const assert = chai.assert;

View File

@ -1,21 +1,22 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
const chai = require("chai"); const chai = require("chai");
const bigInt = require("../src/bigint.js"); const bigInt = require("../src/bigint.js");
@ -96,7 +97,6 @@ describe("Polynomial field", () => {
assert(PF.equals(a, d)); assert(PF.equals(a, d));
}); });
it("Should div big/small", () => { it("Should div big/small", () => {
const PF = new PolField(new ZqField(r)); const PF = new PolField(new ZqField(r));

View File

@ -1,21 +1,22 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
const chai = require("chai"); const chai = require("chai");
const bigInt = require("../src/bigint.js"); const bigInt = require("../src/bigint.js");

View File

@ -1,21 +1,22 @@
/* /*
Copyright 2018 0kims association Copyright 2018 0kims association.
This file is part of zksnark javascript library. This file is part of zksnark JavaScript library.
zksnark javascript library is free software: you can redistribute it and/or modify zksnark JavaScript library is a free software: you can redistribute it and/or
it under the terms of the GNU General Public License as published by modify it under the terms of the GNU General Public License as published by the
the Free Software Foundation, either version 3 of the License, or Free Software Foundation, either version 3 of the License, or (at your option)
(at your option) any later version. any later version.
zksnark javascript library is distributed in the hope that it will be useful, zksnark JavaScript library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
GNU General Public License for more details. more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License along with
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>. zksnark JavaScript library. If not, see <https://www.gnu.org/licenses/>.
*/ */
const chai = require("chai"); const chai = require("chai");
const fs = require("fs"); const fs = require("fs");
const path = require("path"); const path = require("path");
@ -60,7 +61,7 @@ function unstringifyBigInts(o) {
} }
describe("zkSnark", () => { describe("zkSnark", () => {
it("Load a circuit, create trusted setup, create a proof and validate", () => { it("Load a circuit, create trusted setup, create a proof and validate it", () => {
const cirDef = JSON.parse(fs.readFileSync(path.join(__dirname, "circuit", "sum.json"), "utf8")); const cirDef = JSON.parse(fs.readFileSync(path.join(__dirname, "circuit", "sum.json"), "utf8"));
const cir = new Circuit(cirDef); const cir = new Circuit(cirDef);