diff --git a/circuits/barry.jaz b/circuits/barry.jaz deleted file mode 100644 index 3a22548..0000000 --- a/circuits/barry.jaz +++ /dev/null @@ -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(); diff --git a/circuits/sha256/gates.jaz b/circuits/gates.circom similarity index 100% rename from circuits/sha256/gates.jaz rename to circuits/gates.circom diff --git a/circuits/jose.jaz b/circuits/jose.jaz deleted file mode 100644 index 28b9aff..0000000 --- a/circuits/jose.jaz +++ /dev/null @@ -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(); diff --git a/circuits/multiplexer.jaz b/circuits/multiplexer.circom similarity index 100% rename from circuits/multiplexer.jaz rename to circuits/multiplexer.circom diff --git a/circuits/sha256/binsum.jaz b/circuits/sha256/binsum.circom similarity index 100% rename from circuits/sha256/binsum.jaz rename to circuits/sha256/binsum.circom diff --git a/circuits/sha256/bitify.jaz b/circuits/sha256/bitify.circom similarity index 100% rename from circuits/sha256/bitify.jaz rename to circuits/sha256/bitify.circom diff --git a/circuits/sha256/constants.jaz b/circuits/sha256/constants.circom similarity index 100% rename from circuits/sha256/constants.jaz rename to circuits/sha256/constants.circom diff --git a/circuits/sha256/input_h0.json b/circuits/sha256/input_h0.json deleted file mode 100644 index 602c80c..0000000 --- a/circuits/sha256/input_h0.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "in": "0xd807aa98" -} diff --git a/circuits/sha256/main.jaz b/circuits/sha256/main.circom similarity index 100% rename from circuits/sha256/main.jaz rename to circuits/sha256/main.circom diff --git a/circuits/sha256/rotate.jaz b/circuits/sha256/rotate.circom similarity index 100% rename from circuits/sha256/rotate.jaz rename to circuits/sha256/rotate.circom diff --git a/circuits/sha256/sha256_2.jaz b/circuits/sha256/sha256_2.circom similarity index 100% rename from circuits/sha256/sha256_2.jaz rename to circuits/sha256/sha256_2.circom diff --git a/circuits/sha256/sha256compression.jaz b/circuits/sha256/sha256compression.circom similarity index 100% rename from circuits/sha256/sha256compression.jaz rename to circuits/sha256/sha256compression.circom diff --git a/circuits/sha256/sigma.jaz b/circuits/sha256/sigma.circom similarity index 100% rename from circuits/sha256/sigma.jaz rename to circuits/sha256/sigma.circom diff --git a/circuits/sha256/sigmaplus.jaz b/circuits/sha256/sigmaplus.circom similarity index 100% rename from circuits/sha256/sigmaplus.jaz rename to circuits/sha256/sigmaplus.circom diff --git a/circuits/sha256/t1.jaz b/circuits/sha256/t1.circom similarity index 100% rename from circuits/sha256/t1.jaz rename to circuits/sha256/t1.circom diff --git a/circuits/sha256/t2.jaz b/circuits/sha256/t2.circom similarity index 100% rename from circuits/sha256/t2.jaz rename to circuits/sha256/t2.circom diff --git a/circuits/tobin.jaz b/circuits/tobin.circom similarity index 100% rename from circuits/tobin.jaz rename to circuits/tobin.circom diff --git a/circuits/sha256/constants_test.jaz b/test/circuits/constants_test.circom similarity index 82% rename from circuits/sha256/constants_test.jaz rename to test/circuits/constants_test.circom index 1712b84..61d392d 100644 --- a/circuits/sha256/constants_test.jaz +++ b/test/circuits/constants_test.circom @@ -1,4 +1,4 @@ -include "constants.jaz" +include "../../circuits/sha256/constants.circom" template A() { signal input in; diff --git a/test/circuits/constants_test.jaz b/test/circuits/constants_test.jaz deleted file mode 100644 index 8170ae3..0000000 --- a/test/circuits/constants_test.jaz +++ /dev/null @@ -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(); diff --git a/test/circuits/sum_test.jaz b/test/circuits/sum_test.circom similarity index 83% rename from test/circuits/sum_test.jaz rename to test/circuits/sum_test.circom index 7d3467c..9ab2b70 100644 --- a/test/circuits/sum_test.jaz +++ b/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() { signal private input a; diff --git a/circuits/sha256/input_sum_test.json b/test/input_sum_test.json similarity index 100% rename from circuits/sha256/input_sum_test.json rename to test/input_sum_test.json diff --git a/test/sha256.js b/test/sha256.js index 00d33c3..8393896 100644 --- a/test/sha256.js +++ b/test/sha256.js @@ -9,7 +9,7 @@ const assert = chai.assert; describe("SHA256 test", () => { 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); const circuit = new zkSnark.Circuit(cirDef); @@ -19,4 +19,18 @@ describe("SHA256 test", () => { assert(witness[0].equals(zkSnark.bigInt(1))); 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"))); + }); + + });