mirror of
https://github.com/arnaucube/snarkjs.git
synced 2026-02-28 22:16:45 +01:00
Spelling fixed
This commit is contained in:
@@ -221,7 +221,7 @@ class RTCtx {
|
||||
const ba = bigInt(a);
|
||||
const bb = bigInt(b);
|
||||
if (!ba.equals(bb)) {
|
||||
throw new Error("Constrain doesn't match: " + ba.toString() + " != " + bb.toString());
|
||||
throw new Error("Constraint doesn't match: " + ba.toString() + " != " + bb.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,13 +32,13 @@ module.exports = class Circuit {
|
||||
this.nSignals = circuitDef.nSignals;
|
||||
this.nConstants = circuitDef.nConstants;
|
||||
|
||||
this.nConstrains = circuitDef.constrains.length;
|
||||
this.nConstraints = circuitDef.constraints.length;
|
||||
|
||||
this.signalName2Idx = circuitDef.signalName2Idx;
|
||||
this.components = circuitDef.components;
|
||||
this.componentName2Idx = circuitDef.componentName2Idx;
|
||||
this.signals = circuitDef.signals;
|
||||
this.constrains = circuitDef.constrains;
|
||||
this.constraints = circuitDef.constraints;
|
||||
|
||||
this.templates = {};
|
||||
for (let t in circuitDef.templates) {
|
||||
@@ -110,15 +110,15 @@ module.exports = class Circuit {
|
||||
return this.signals[ this.getSignalIdx(i) ].names.join(", ");
|
||||
}
|
||||
|
||||
a(constrain, signalIdx) {
|
||||
return bigInt(this.constrains[constrain][0][signalIdx] || 0 );
|
||||
a(constraint, signalIdx) {
|
||||
return bigInt(this.constraints[constraint][0][signalIdx] || 0 );
|
||||
}
|
||||
|
||||
b(constrain, signalIdx) {
|
||||
return bigInt(this.constrains[constrain][1][signalIdx] || 0);
|
||||
b(constraint, signalIdx) {
|
||||
return bigInt(this.constraints[constraint][1][signalIdx] || 0);
|
||||
}
|
||||
|
||||
c(constrain, signalIdx) {
|
||||
return bigInt(this.constrains[constrain][2][signalIdx] || 0);
|
||||
c(constraint, signalIdx) {
|
||||
return bigInt(this.constraints[constraint][2][signalIdx] || 0);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/*
|
||||
Copyright 2018 0kims association
|
||||
|
||||
This file is part of zksnark javascript library.
|
||||
|
||||
zksnark javascript library is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
zksnark javascript library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with zksnark javascript library. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
const bigInt = require("big-integer");
|
||||
|
||||
const F1Field = require("./f1field");
|
||||
const F2Field = require("./f1field");
|
||||
|
||||
const C = {
|
||||
|
||||
// Module of the field
|
||||
q : bigInt("21888242871839275222246405745257275088696311157297823662689037894645226208583"),
|
||||
|
||||
// Order of the group
|
||||
r : bigInt("21888242871839275222246405745257275088548364400416034343698204186575808495617"),
|
||||
|
||||
g1 : [ bigInt(1), bigInt(2) ],
|
||||
g2 :
|
||||
[
|
||||
[
|
||||
bigInt("10857046999023057135944570762232829481370756359578518086990519993285655852781"),
|
||||
bigInt("11559732032986387107991004021392285783925812861821192530917403151452391805634")
|
||||
],
|
||||
[
|
||||
bigInt("8495653923123431417604973247489272438418190587263600148770280649306958101930"),
|
||||
bigInt("4082367875863433681332203403145435568316851327593401208105741076214120093531")
|
||||
]
|
||||
],
|
||||
|
||||
f2nonResidue: bigInt("21888242871839275222246405745257275088696311157297823662689037894645226208582"),
|
||||
f6nonResidue: [ bigInt("9"), bigInt("1") ],
|
||||
f12nonResidue: [
|
||||
]
|
||||
};
|
||||
|
||||
const F1 = new F1Field(C.q);
|
||||
const F2 = new F2Field(C.q);
|
||||
|
||||
C.two_inv= F1.inverse(bigInt(2));
|
||||
|
||||
C.coef_b = bigInt(3);
|
||||
C.twist = [bigInt(9) , bigInt(1)];
|
||||
C.twist_coeff_b = F2.mulScalar( F2.inverse(C.twist), C.coef_b );
|
||||
|
||||
|
||||
module.exports = C;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
This library do operations on polinomials where their coefficients are in field F
|
||||
This library do operations on polynomials where their coefficients are in field F
|
||||
|
||||
The polynomial P(x) = p0 + p1 * x + p2 * x^2 + p3 * x^3, ...
|
||||
is represented by the array [ p0, p1, p2, p3, ... ]
|
||||
|
||||
@@ -95,6 +95,8 @@ module.exports = function genProof(vk_proof, witness) {
|
||||
|
||||
const h = PolF.div(polFull, vk_proof.polZ );
|
||||
|
||||
console.log(h.length + "/" + vk_proof.hExps.length);
|
||||
|
||||
for (let i = 0; i < h.length; i++) {
|
||||
proof.pi_h = G1.add( proof.pi_h, G1.mulScalar( vk_proof.hExps[i], h[i]));
|
||||
}
|
||||
|
||||
20
src/setup.js
20
src/setup.js
@@ -43,7 +43,7 @@ module.exports = function setup(circuit) {
|
||||
toxic: {}
|
||||
};
|
||||
|
||||
calculatePolinomials(setup, circuit);
|
||||
calculatePolynomials(setup, circuit);
|
||||
setup.toxic.t = F.random();
|
||||
calculateEncriptedValuesAtT(setup, circuit);
|
||||
calculateHexps(setup, circuit);
|
||||
@@ -51,8 +51,8 @@ module.exports = function setup(circuit) {
|
||||
return setup;
|
||||
};
|
||||
|
||||
function calculatePolinomials(setup, circuit) {
|
||||
// Calculate the points that must cross each polinomial
|
||||
function calculatePolynomials(setup, circuit) {
|
||||
// Calculate the points that must cross each polynomial
|
||||
|
||||
setup.toxic.aExtra = [];
|
||||
setup.toxic.bExtra = [];
|
||||
@@ -64,7 +64,7 @@ function calculatePolinomials(setup, circuit) {
|
||||
aPoints[s] = [];
|
||||
bPoints[s] = [];
|
||||
cPoints[s] = [];
|
||||
for (let c=0; c<circuit.nConstrains; c++) {
|
||||
for (let c=0; c<circuit.nConstraints; c++) {
|
||||
aPoints[s].push([[bigInt(c), F.one], [circuit.a(c, s), F.one]]);
|
||||
bPoints[s].push([[bigInt(c), F.one], [circuit.b(c, s), F.one]]);
|
||||
cPoints[s].push([[bigInt(c), F.one], [circuit.c(c, s), F.one]]);
|
||||
@@ -73,12 +73,12 @@ function calculatePolinomials(setup, circuit) {
|
||||
setup.toxic.aExtra[s] = F.random();
|
||||
setup.toxic.bExtra[s] = F.random();
|
||||
setup.toxic.cExtra[s] = F.random();
|
||||
aPoints[s].push([[bigInt(circuit.nConstrains), F.one], [setup.toxic.aExtra[s], F.one]]);
|
||||
bPoints[s].push([[bigInt(circuit.nConstrains), F.one], [setup.toxic.aExtra[s], F.one]]);
|
||||
cPoints[s].push([[bigInt(circuit.nConstrains), F.one], [setup.toxic.aExtra[s], F.one]]);
|
||||
aPoints[s].push([[bigInt(circuit.nConstraints), F.one], [setup.toxic.aExtra[s], F.one]]);
|
||||
bPoints[s].push([[bigInt(circuit.nConstraints), F.one], [setup.toxic.aExtra[s], F.one]]);
|
||||
cPoints[s].push([[bigInt(circuit.nConstraints), F.one], [setup.toxic.aExtra[s], F.one]]);
|
||||
}
|
||||
|
||||
// Calculate the polinomials using Lagrange
|
||||
// Calculate the polynomials using Lagrange
|
||||
setup.vk_proof.polsA = [];
|
||||
setup.vk_proof.polsB = [];
|
||||
setup.vk_proof.polsC = [];
|
||||
@@ -94,10 +94,10 @@ function calculatePolinomials(setup, circuit) {
|
||||
|
||||
}
|
||||
|
||||
// Calculate Z polinomial
|
||||
// Calculate Z polynomial
|
||||
// Z = 1
|
||||
setup.vk_proof.polZ = [bigInt(1)];
|
||||
for (let c=0; c<circuit.nConstrains; c++) {
|
||||
for (let c=0; c<circuit.nConstraints; c++) {
|
||||
// Z = Z * (x - p_c)
|
||||
setup.vk_proof.polZ = PolF.mul(
|
||||
setup.vk_proof.polZ,
|
||||
|
||||
Reference in New Issue
Block a user