Browse Source

Readme, License Fixes and another test added

wasm
Jordi Baylina 6 years ago
parent
commit
296defda85
No known key found for this signature in database GPG Key ID: 7480C80C1BE43112
22 changed files with 18 additions and 79 deletions
  1. +0
    -43
      circuits/barry.jaz
  2. +0
    -0
      circuits/gates.circom
  3. +0
    -11
      circuits/jose.jaz
  4. +0
    -0
      circuits/multiplexer.circom
  5. +0
    -0
      circuits/sha256/binsum.circom
  6. +0
    -0
      circuits/sha256/bitify.circom
  7. +0
    -0
      circuits/sha256/constants.circom
  8. +0
    -3
      circuits/sha256/input_h0.json
  9. +0
    -0
      circuits/sha256/main.circom
  10. +0
    -0
      circuits/sha256/rotate.circom
  11. +0
    -0
      circuits/sha256/sha256_2.circom
  12. +0
    -0
      circuits/sha256/sha256compression.circom
  13. +0
    -0
      circuits/sha256/sigma.circom
  14. +0
    -0
      circuits/sha256/sigmaplus.circom
  15. +0
    -0
      circuits/sha256/t1.circom
  16. +0
    -0
      circuits/sha256/t2.circom
  17. +0
    -0
      circuits/tobin.circom
  18. +1
    -1
      test/circuits/constants_test.circom
  19. +0
    -18
      test/circuits/constants_test.jaz
  20. +2
    -2
      test/circuits/sum_test.circom
  21. +0
    -0
      test/input_sum_test.json
  22. +15
    -1
      test/sha256.js

+ 0
- 43
circuits/barry.jaz

@ -1,43 +0,0 @@
template AND() {
signal input a;
signal input b;
signal output c;
c <== a*b;
}
template AND3() {
signal input in1;
signal input in2;
signal input in3;
signal output out;
component and1 = AND();
component and2 = AND();
in1 ==> and1.a;
in2 ==> and1.b;
in3 ==> and2.a;
and1.c ==> and2.b;
and2.c ==> out;
}
template ToBin() {
signal input in;
signal output out[32];
var lc = 0;
for (var i=0; i<32; i++) {
out[i] <-- (in >> i) & 1;
lc = lc + out[i] * 2**i;
out[i]*(out[i]-1) === 0;
}
lc === in;
}
component main = ToBin();

circuits/sha256/gates.jaz → circuits/gates.circom


+ 0
- 11
circuits/jose.jaz

@ -1,11 +0,0 @@
template AND() {
signal input s1;
signal input s2;
signal output s3;
s3 <== s1*s2;
s1*(s1-1) === 0;
s2*(s2-1) === 0;
}
component main = AND();

circuits/multiplexer.jaz → circuits/multiplexer.circom


circuits/sha256/binsum.jaz → circuits/sha256/binsum.circom


circuits/sha256/bitify.jaz → circuits/sha256/bitify.circom


circuits/sha256/constants.jaz → circuits/sha256/constants.circom


+ 0
- 3
circuits/sha256/input_h0.json

@ -1,3 +0,0 @@
{
"in": "0xd807aa98"
}

circuits/sha256/main.jaz → circuits/sha256/main.circom


circuits/sha256/rotate.jaz → circuits/sha256/rotate.circom


circuits/sha256/sha256_2.jaz → circuits/sha256/sha256_2.circom


circuits/sha256/sha256compression.jaz → circuits/sha256/sha256compression.circom


circuits/sha256/sigma.jaz → circuits/sha256/sigma.circom


circuits/sha256/sigmaplus.jaz → circuits/sha256/sigmaplus.circom


circuits/sha256/t1.jaz → circuits/sha256/t1.circom


circuits/sha256/t2.jaz → circuits/sha256/t2.circom


circuits/tobin.jaz → circuits/tobin.circom


circuits/sha256/constants_test.jaz → test/circuits/constants_test.circom

@ -1,4 +1,4 @@
include "constants.jaz"
include "../../circuits/sha256/constants.circom"
template A() { template A() {
signal input in; signal input in;

+ 0
- 18
test/circuits/constants_test.jaz

@ -1,18 +0,0 @@
include "../../circuits/sha256/constants.jaz"
template A() {
signal input in;
component h0;
h0 = K(8);
var lc = 0;
var e = 1;
for (var i=0; i<32; i++) {
lc = lc + e*h0.out[i];
e *= 2;
}
lc === in;
}
component main = A();

test/circuits/sum_test.jaz → test/circuits/sum_test.circom

@ -1,5 +1,5 @@
include "bitify.jaz"
include "binsum.jaz"
include "../../circuits/sha256/bitify.circom"
include "../../circuits/sha256/binsum.circom"
template A() { template A() {
signal private input a; signal private input a;

circuits/sha256/input_sum_test.json → test/input_sum_test.json


+ 15
- 1
test/sha256.js

@ -9,7 +9,7 @@ const assert = chai.assert;
describe("SHA256 test", () => { describe("SHA256 test", () => {
it("Should create a constant circuit", async () => { it("Should create a constant circuit", async () => {
const cirDef = await compiler(path.join(__dirname, "circuits", "constants_test.jaz"));
const cirDef = await compiler(path.join(__dirname, "circuits", "constants_test.circom"));
assert.equal(cirDef.nVars, 2); assert.equal(cirDef.nVars, 2);
const circuit = new zkSnark.Circuit(cirDef); const circuit = new zkSnark.Circuit(cirDef);
@ -19,4 +19,18 @@ describe("SHA256 test", () => {
assert(witness[0].equals(zkSnark.bigInt(1))); assert(witness[0].equals(zkSnark.bigInt(1)));
assert(witness[1].equals(zkSnark.bigInt("0xd807aa98"))); assert(witness[1].equals(zkSnark.bigInt("0xd807aa98")));
}); });
it("Should create a sum circuit", async () => {
const cirDef = await compiler(path.join(__dirname, "circuits", "sum_test.circom"));
assert.equal(cirDef.nVars, 101);
const circuit = new zkSnark.Circuit(cirDef);
const witness = circuit.calculateWitness({ "a": "111", "b": "222" });
assert(witness[0].equals(zkSnark.bigInt(1)));
assert(witness[1].equals(zkSnark.bigInt("333")));
});
}); });

Loading…
Cancel
Save