Skip to content

Commit

Permalink
pedersen2 adapted
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaylina committed Dec 13, 2019
1 parent 4117ebc commit a8107ab
Show file tree
Hide file tree
Showing 6 changed files with 22,435 additions and 45 deletions.
6 changes: 3 additions & 3 deletions circuits/pedersen.circom
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ template Segment(nWindows) {
component adders[nWindows-1];
for (i=0; i<nWindows; i++) {
windows[i] = Window4();
for (j=0; j<4; j++) {
windows[i].in[j] <== in[4*i+j];
}
if (i==0) {
windows[i].base[0] <== e2m.out[0];
windows[i].base[1] <== e2m.out[1];
Expand All @@ -153,9 +156,6 @@ template Segment(nWindows) {
adders[i-1].in2[0] <== windows[i].out[0];
adders[i-1].in2[1] <== windows[i].out[1];
}
for (j=0; j<4; j++) {
windows[i].in[j] <== in[4*i+j];
}
}

component m2e = Montgomery2Edwards();
Expand Down
8 changes: 4 additions & 4 deletions src/pedersenHash.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ function pedersenHash(msg) {
let acc = bigInt.one;
for (let b=0; ((b<windowSize-1)&&(o<bits.length)) ; b++) {
if (bits[o]) {
acc = acc.add( bigInt.one.shl(b) );
acc = acc.add( bigInt.one.shiftLeft(b) );
}
o++;
}
if (o<bits.length) {
if (bits[o]) {
acc = acc.neg();
acc = bigInt.zero.minus(acc);
}
o++;
}
escalar = escalar.add(acc.mul(exp));
exp = exp.shl(windowSize+1);
escalar = escalar.add(acc.times(exp));
exp = exp.shiftLeft(windowSize+1);
}

if (escalar.lesser(bigInt.zero)) {
Expand Down
3 changes: 0 additions & 3 deletions test/binsub.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
const chai = require("chai");
const path = require("path");

const assert = chai.assert;

const bigInt = require("big-integer");
const tester = require("circom").tester;

Expand Down
Loading

0 comments on commit a8107ab

Please sign in to comment.