Browse Source

Adapted circuits to the construction fase refactorization

master
Jordi Baylina 4 years ago
parent
commit
4f11565ca4
No known key found for this signature in database GPG Key ID: 7480C80C1BE43112
21 changed files with 28 additions and 28 deletions
  1. +1
    -1
      circuits/babyjub.circom
  2. +1
    -1
      circuits/eddsa.circom
  3. +1
    -1
      circuits/eddsamimc.circom
  4. +1
    -1
      circuits/eddsamimcsponge.circom
  5. +1
    -1
      circuits/eddsaposeidon.circom
  6. +1
    -1
      circuits/escalarmul.circom
  7. +1
    -1
      circuits/escalarmulw4table.circom
  8. +1
    -1
      circuits/mimc.circom
  9. +1
    -1
      circuits/mimcsponge.circom
  10. +1
    -1
      circuits/pedersen.circom
  11. +1
    -1
      circuits/pedersen_old.circom
  12. +2
    -2
      circuits/poseidon.circom
  13. +2
    -2
      circuits/sha256/constants.circom
  14. +1
    -1
      src/poseidon.js
  15. +1
    -1
      test/binsum.js
  16. +1
    -1
      test/circuits/escalarmul_test.circom
  17. +2
    -2
      test/circuits/escalarmul_test_min.circom
  18. +2
    -2
      test/circuits/escalarmulfix_test.circom
  19. +1
    -1
      test/circuits/escalarmulw4table.circom
  20. +2
    -2
      test/circuits/escalarmulw4table_test.circom
  21. +3
    -3
      test/circuits/escalarmulw4table_test3.circom

+ 1
- 1
circuits/babyjub.circom

@ -87,7 +87,7 @@ template BabyPbk() {
signal output Ax;
signal output Ay;
var BASE8 = [
var BASE8[2] = [
5299619240641551281634865583518297030282874472190772894086521144482721001553,
16950150798460657717958625567821834550301663161624707787222815936182638968203
];

+ 1
- 1
circuits/eddsa.circom

@ -122,7 +122,7 @@ template EdDSAVerifier(n) {
// Calculate left side of equation left = S*B8
var BASE8 = [
var BASE8[2] = [
5299619240641551281634865583518297030282874472190772894086521144482721001553,
16950150798460657717958625567821834550301663161624707787222815936182638968203
];

+ 1
- 1
circuits/eddsamimc.circom

@ -100,7 +100,7 @@ template EdDSAMiMCVerifier() {
// Calculate left side of equation left = S*B8
var BASE8 = [
var BASE8[2] = [
5299619240641551281634865583518297030282874472190772894086521144482721001553,
16950150798460657717958625567821834550301663161624707787222815936182638968203
];

+ 1
- 1
circuits/eddsamimcsponge.circom

@ -100,7 +100,7 @@ template EdDSAMiMCSpongeVerifier() {
// Calculate left side of equation left = S*B8
var BASE8 = [
var BASE8[2] = [
5299619240641551281634865583518297030282874472190772894086521144482721001553,
16950150798460657717958625567821834550301663161624707787222815936182638968203
];

+ 1
- 1
circuits/eddsaposeidon.circom

@ -99,7 +99,7 @@ template EdDSAPoseidonVerifier() {
// Calculate left side of equation left = S*B8
var BASE8 = [
var BASE8[2] = [
5299619240641551281634865583518297030282874472190772894086521144482721001553,
16950150798460657717958625567821834550301663161624707787222815936182638968203
];

+ 1
- 1
circuits/escalarmul.circom

@ -71,7 +71,7 @@ template EscalarMulWindow(base, k) {
signal input sel[4];
signal output out[2];
var table;
var table[16][2];
component mux;
component adder;

+ 1
- 1
circuits/escalarmulw4table.circom

@ -33,7 +33,7 @@ function EscalarMulW4Table(base, k) {
var i;
var p[2];
var dbl = base;
var dbl[2] = base;
for (i=0; i<k*4; i++) {
dbl = pointAdd(dbl[0], dbl[1], dbl[0], dbl[1]);

+ 1
- 1
circuits/mimc.circom

@ -22,7 +22,7 @@ template MiMC7(nrounds) {
signal input k;
signal output out;
var c = [
var c[91] = [
0,
20888961410941983456478427210666206549300505294776164667214940546594746570981,
15265126113435022738560151911929040668591755459209400716467504685752745317193,

+ 1
- 1
circuits/mimcsponge.circom

@ -42,7 +42,7 @@ template MiMCFeistel(nrounds) {
signal output xR_out;
// doesn't contain the first and last round constants, which are always zero
var c_partial = [
var c_partial[218] = [
7120861356467848435263064379192047478074060781135320967663101236819528304084,
5024705281721889198577876690145313457398658950011302225525409148828000436681,
17980351014018068290387269214713820287804403312720763401943303895585469787384,

+ 1
- 1
circuits/pedersen.circom

@ -176,7 +176,7 @@ template Pedersen(n) {
signal input in[n];
signal output out[2];
var BASE = [
var BASE[10][2] = [
[10457101036533406547632367118273992217979173478358440826365724437999023779287,19824078218392094440610104313265183977899662750282163392862422243483260492317],
[2671756056509184035029146175565761955751135805354291559563293617232983272177,2663205510731142763556352975002641716101654201788071096152948830924149045094],
[5802099305472655231388284418920769829666717045250560929368476121199858275951,5980429700218124965372158798884772646841287887664001482443826541541529227896],

+ 1
- 1
circuits/pedersen_old.circom

@ -28,7 +28,7 @@ template Pedersen(n) {
component escalarMuls[nexps];
var PBASE = [
var PBASE[10][2] = [
[10457101036533406547632367118273992217979173478358440826365724437999023779287,19824078218392094440610104313265183977899662750282163392862422243483260492317],
[2671756056509184035029146175565761955751135805354291559563293617232983272177,2663205510731142763556352975002641716101654201788071096152948830924149045094],
[5802099305472655231388284418920769829666717045250560929368476121199858275951,5980429700218124965372158798884772646841287887664001482443826541541529227896],

+ 2
- 2
circuits/poseidon.circom

@ -43,7 +43,7 @@ template Mix(t, M) {
template Poseidon(nInputs, t, nRoundsF, nRoundsP) {
var C = [
var C[65] = [
14397397413755236225575615486459253198602422701513067526754101844196324375522,
10405129301473404666785234951972711717481302463898292859783056520670200613128,
5179144822360023508491245509308555580251733042407187134628755730783052214509,
@ -111,7 +111,7 @@ template Poseidon(nInputs, t, nRoundsF, nRoundsP) {
10635360132728137321700090133109897687122647659471659996419791842933639708516
];
var M = [
var M[6][6] = [
[
19167410339349846567561662441069598364702008768579734801591448511131028229281,
14183033936038168803360723133013092560869148726790180682363054735190196956789,

+ 2
- 2
circuits/sha256/constants.circom

@ -19,7 +19,7 @@
template H(x) {
signal output out[32];
var c = [0x6a09e667,
var c[8] = [0x6a09e667,
0xbb67ae85,
0x3c6ef372,
0xa54ff53a,
@ -35,7 +35,7 @@ template H(x) {
template K(x) {
signal output out[32];
var c = [
var c[64] = [
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,

+ 1
- 1
src/poseidon.js

@ -50,7 +50,7 @@ exports.getMatrix = (t, seed, nRounds) => {
for (let i=0; i<t; i++) {
M[i] = new Array(t);
for (let j=0; j<t; j++) {
M[i][j] = F.normalize(F.inverse(F.sub(cmatrix[i], cmatrix[t+j])));
M[i][j] = F.normalize(F.inv(F.sub(cmatrix[i], cmatrix[t+j])));
}
}
return M;

+ 1
- 1
test/binsum.js

@ -7,7 +7,7 @@ const bigInt = require("big-integer");
const assert = chai.assert;
describe("Sum test", function () {
describe("Binary sum test", function () {
this.timeout(100000000);

+ 1
- 1
test/circuits/escalarmul_test.circom

@ -6,7 +6,7 @@ template Main() {
signal input in;
signal output out[2];
var base = [5299619240641551281634865583518297030282874472190772894086521144482721001553,
var base[2] = [5299619240641551281634865583518297030282874472190772894086521144482721001553,
16950150798460657717958625567821834550301663161624707787222815936182638968203];

+ 2
- 2
test/circuits/escalarmul_test_min.circom

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

+ 2
- 2
test/circuits/escalarmulfix_test.circom

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

+ 1
- 1
test/circuits/escalarmulw4table.circom

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

+ 2
- 2
test/circuits/escalarmulw4table_test.circom

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

+ 3
- 3
test/circuits/escalarmulw4table_test3.circom

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

Loading…
Cancel
Save