mirror of
https://github.com/arnaucube/circom_tester.git
synced 2026-02-07 11:26:41 +01:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
458ab087d7 | ||
|
|
2cd741bdff | ||
|
|
799d71ff34 | ||
|
|
daf3b0e0c0 | ||
|
|
8580d8cc0f | ||
|
|
2d852d7a8f | ||
|
|
30f12bf326 | ||
|
|
a7db09fba9 |
106
package-lock.json
generated
106
package-lock.json
generated
@@ -1,19 +1,19 @@
|
||||
{
|
||||
"name": "circom_tester",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.5",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "circom_tester",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.5",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"chai": "^4.3.4",
|
||||
"child_process": "^1.0.2",
|
||||
"ffjavascript": "^0.2.38",
|
||||
"fnv-plus": "^1.3.1",
|
||||
"r1csfile": "^0.0.32",
|
||||
"r1csfile": "0.0.16",
|
||||
"tmp-promise": "^3.0.2",
|
||||
"util": "^0.12.4"
|
||||
}
|
||||
@@ -23,15 +23,6 @@
|
||||
"resolved": "https://registry.npmjs.org/@iden3/bigarray/-/bigarray-0.0.2.tgz",
|
||||
"integrity": "sha512-Xzdyxqm1bOFF6pdIsiHLLl3HkSLjbhqJHVyqaTxXt3RqXBEnmsUmEW47H7VOi/ak7TdkRpNkxjyK5Zbkm+y52g=="
|
||||
},
|
||||
"node_modules/@iden3/binfileutils": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@iden3/binfileutils/-/binfileutils-0.0.8.tgz",
|
||||
"integrity": "sha512-/GqTsujUssGuQY+sd/XaLrA+OiCwzm+6yH28C57QQDWCHET2Logry9fGxU10n6XKdhCQBjZ7T/YMQkLwwkpRTQ==",
|
||||
"dependencies": {
|
||||
"fastfile": "0.0.19",
|
||||
"ffjavascript": "^0.2.30"
|
||||
}
|
||||
},
|
||||
"node_modules/assertion-error": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz",
|
||||
@@ -196,9 +187,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/fastfile": {
|
||||
"version": "0.0.19",
|
||||
"resolved": "https://registry.npmjs.org/fastfile/-/fastfile-0.0.19.tgz",
|
||||
"integrity": "sha512-tz9nWR5KYb6eR2odFQ7oxqEkx8F3YQZ6NBJoJR92YEG3DqYOqyxMck8PKvTVNKx3uwvOqGnLXNScnqpdHRdHGQ=="
|
||||
"version": "0.0.18",
|
||||
"resolved": "https://registry.npmjs.org/fastfile/-/fastfile-0.0.18.tgz",
|
||||
"integrity": "sha512-q03PTKc+wptis4WmuFOwPNQx2p5myFUrl/dMgRlW9mymc1Egyc14JPHgiGnWK+sJ0+dBl2Vwtfh5GfSQltYOpw=="
|
||||
},
|
||||
"node_modules/ffjavascript": {
|
||||
"version": "0.2.38",
|
||||
@@ -610,24 +601,32 @@
|
||||
}
|
||||
},
|
||||
"node_modules/r1csfile": {
|
||||
"version": "0.0.32",
|
||||
"resolved": "https://registry.npmjs.org/r1csfile/-/r1csfile-0.0.32.tgz",
|
||||
"integrity": "sha512-DkRXeOg0iRmfhgIuWICvdkOiLHpyb7+AcUd/WHpqBJEUp27pe7wKXBR4Jr3TPYCT4sTV9a/F3bovyAC4wystnQ==",
|
||||
"version": "0.0.16",
|
||||
"resolved": "https://registry.npmjs.org/r1csfile/-/r1csfile-0.0.16.tgz",
|
||||
"integrity": "sha512-A2jRVWzGgmXeG2lVAc0H4suJmzt50it5UvBnycJgBCpMXM3tH/M6RguP7nvs6suY/yYnkN6jX6iTScSiDUF3FA==",
|
||||
"dependencies": {
|
||||
"@iden3/bigarray": "0.0.2",
|
||||
"@iden3/binfileutils": "0.0.8",
|
||||
"fastfile": "0.0.19",
|
||||
"ffjavascript": "0.2.35"
|
||||
"fastfile": "0.0.18",
|
||||
"ffjavascript": "0.2.22"
|
||||
}
|
||||
},
|
||||
"node_modules/r1csfile/node_modules/ffjavascript": {
|
||||
"version": "0.2.35",
|
||||
"resolved": "https://registry.npmjs.org/ffjavascript/-/ffjavascript-0.2.35.tgz",
|
||||
"integrity": "sha512-xnC51tWbi0ah4SH+02jEfJyO+P+NiZWnxQrLDLtBYY1Dv3QM5ydxzd+gxnLEfWdT8i1bMM5pIh5P25l6fNCaVQ==",
|
||||
"version": "0.2.22",
|
||||
"resolved": "https://registry.npmjs.org/ffjavascript/-/ffjavascript-0.2.22.tgz",
|
||||
"integrity": "sha512-EsVqap2Txm17bKW0z/jXCX3M7rQ++nQUAJY8alWDpyhjRj90xjl6GLeVSKZQ8rOFDQ/SFFXcEB8w9X8Boxid+w==",
|
||||
"dependencies": {
|
||||
"big-integer": "^1.6.48",
|
||||
"wasmcurves": "0.0.14",
|
||||
"web-worker": "^1.0.0"
|
||||
"wasmcurves": "0.0.12",
|
||||
"worker-threads": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/r1csfile/node_modules/wasmcurves": {
|
||||
"version": "0.0.12",
|
||||
"resolved": "https://registry.npmjs.org/wasmcurves/-/wasmcurves-0.0.12.tgz",
|
||||
"integrity": "sha512-1Jl9mkatyHSNj80ILjf85SZUNuZQBCkTjJlhzqHnZQXUmIimCIWkugaVaYNjozLs1Gun4h/keZe1MBeBN0sRpg==",
|
||||
"dependencies": {
|
||||
"big-integer": "^1.6.42",
|
||||
"blakejs": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/rimraf": {
|
||||
@@ -802,6 +801,11 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/worker-threads": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/worker-threads/-/worker-threads-1.0.0.tgz",
|
||||
"integrity": "sha512-vK6Hhvph8oLxocEJIlc3YfGAZhm210uGzjZsXSu+JYLAQ/s/w4Tqgl60JrdH58hW8NSGP4m3bp8a92qPXgX05w=="
|
||||
},
|
||||
"node_modules/wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
@@ -814,15 +818,6 @@
|
||||
"resolved": "https://registry.npmjs.org/@iden3/bigarray/-/bigarray-0.0.2.tgz",
|
||||
"integrity": "sha512-Xzdyxqm1bOFF6pdIsiHLLl3HkSLjbhqJHVyqaTxXt3RqXBEnmsUmEW47H7VOi/ak7TdkRpNkxjyK5Zbkm+y52g=="
|
||||
},
|
||||
"@iden3/binfileutils": {
|
||||
"version": "0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@iden3/binfileutils/-/binfileutils-0.0.8.tgz",
|
||||
"integrity": "sha512-/GqTsujUssGuQY+sd/XaLrA+OiCwzm+6yH28C57QQDWCHET2Logry9fGxU10n6XKdhCQBjZ7T/YMQkLwwkpRTQ==",
|
||||
"requires": {
|
||||
"fastfile": "0.0.19",
|
||||
"ffjavascript": "^0.2.30"
|
||||
}
|
||||
},
|
||||
"assertion-error": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz",
|
||||
@@ -948,9 +943,9 @@
|
||||
}
|
||||
},
|
||||
"fastfile": {
|
||||
"version": "0.0.19",
|
||||
"resolved": "https://registry.npmjs.org/fastfile/-/fastfile-0.0.19.tgz",
|
||||
"integrity": "sha512-tz9nWR5KYb6eR2odFQ7oxqEkx8F3YQZ6NBJoJR92YEG3DqYOqyxMck8PKvTVNKx3uwvOqGnLXNScnqpdHRdHGQ=="
|
||||
"version": "0.0.18",
|
||||
"resolved": "https://registry.npmjs.org/fastfile/-/fastfile-0.0.18.tgz",
|
||||
"integrity": "sha512-q03PTKc+wptis4WmuFOwPNQx2p5myFUrl/dMgRlW9mymc1Egyc14JPHgiGnWK+sJ0+dBl2Vwtfh5GfSQltYOpw=="
|
||||
},
|
||||
"ffjavascript": {
|
||||
"version": "0.2.38",
|
||||
@@ -1227,24 +1222,32 @@
|
||||
"integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ=="
|
||||
},
|
||||
"r1csfile": {
|
||||
"version": "0.0.32",
|
||||
"resolved": "https://registry.npmjs.org/r1csfile/-/r1csfile-0.0.32.tgz",
|
||||
"integrity": "sha512-DkRXeOg0iRmfhgIuWICvdkOiLHpyb7+AcUd/WHpqBJEUp27pe7wKXBR4Jr3TPYCT4sTV9a/F3bovyAC4wystnQ==",
|
||||
"version": "0.0.16",
|
||||
"resolved": "https://registry.npmjs.org/r1csfile/-/r1csfile-0.0.16.tgz",
|
||||
"integrity": "sha512-A2jRVWzGgmXeG2lVAc0H4suJmzt50it5UvBnycJgBCpMXM3tH/M6RguP7nvs6suY/yYnkN6jX6iTScSiDUF3FA==",
|
||||
"requires": {
|
||||
"@iden3/bigarray": "0.0.2",
|
||||
"@iden3/binfileutils": "0.0.8",
|
||||
"fastfile": "0.0.19",
|
||||
"ffjavascript": "0.2.35"
|
||||
"fastfile": "0.0.18",
|
||||
"ffjavascript": "0.2.22"
|
||||
},
|
||||
"dependencies": {
|
||||
"ffjavascript": {
|
||||
"version": "0.2.35",
|
||||
"resolved": "https://registry.npmjs.org/ffjavascript/-/ffjavascript-0.2.35.tgz",
|
||||
"integrity": "sha512-xnC51tWbi0ah4SH+02jEfJyO+P+NiZWnxQrLDLtBYY1Dv3QM5ydxzd+gxnLEfWdT8i1bMM5pIh5P25l6fNCaVQ==",
|
||||
"version": "0.2.22",
|
||||
"resolved": "https://registry.npmjs.org/ffjavascript/-/ffjavascript-0.2.22.tgz",
|
||||
"integrity": "sha512-EsVqap2Txm17bKW0z/jXCX3M7rQ++nQUAJY8alWDpyhjRj90xjl6GLeVSKZQ8rOFDQ/SFFXcEB8w9X8Boxid+w==",
|
||||
"requires": {
|
||||
"big-integer": "^1.6.48",
|
||||
"wasmcurves": "0.0.14",
|
||||
"web-worker": "^1.0.0"
|
||||
"wasmcurves": "0.0.12",
|
||||
"worker-threads": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"wasmcurves": {
|
||||
"version": "0.0.12",
|
||||
"resolved": "https://registry.npmjs.org/wasmcurves/-/wasmcurves-0.0.12.tgz",
|
||||
"integrity": "sha512-1Jl9mkatyHSNj80ILjf85SZUNuZQBCkTjJlhzqHnZQXUmIimCIWkugaVaYNjozLs1Gun4h/keZe1MBeBN0sRpg==",
|
||||
"requires": {
|
||||
"big-integer": "^1.6.42",
|
||||
"blakejs": "^1.1.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1374,6 +1377,11 @@
|
||||
"is-typed-array": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"worker-threads": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/worker-threads/-/worker-threads-1.0.0.tgz",
|
||||
"integrity": "sha512-vK6Hhvph8oLxocEJIlc3YfGAZhm210uGzjZsXSu+JYLAQ/s/w4Tqgl60JrdH58hW8NSGP4m3bp8a92qPXgX05w=="
|
||||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "circom_tester",
|
||||
"version": "0.0.2",
|
||||
"version": "0.0.5",
|
||||
"description": "Tools for testing circom circuits.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
@@ -27,7 +27,7 @@
|
||||
"child_process": "^1.0.2",
|
||||
"ffjavascript": "^0.2.38",
|
||||
"fnv-plus": "^1.3.1",
|
||||
"r1csfile": "^0.0.32",
|
||||
"r1csfile": "0.0.16",
|
||||
"tmp-promise": "^3.0.2",
|
||||
"util": "^0.12.4"
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ const Fr = new F1Field(exports.p);
|
||||
|
||||
const assert = chai.assert;
|
||||
|
||||
describe("Exponentioation test", function () {
|
||||
describe("Simple test", function () {
|
||||
this.timeout(100000);
|
||||
|
||||
it("Should generate the Exponentiation table in k=0", async () => {
|
||||
it("Checking the compilation of simple circuit", async () => {
|
||||
|
||||
const circuit = await wasm_tester(path.join(__dirname, "Multiplier2.circom"));
|
||||
const w = await circuit.calculateWitness({a: 2, b: 4});
|
||||
|
||||
@@ -52,7 +52,9 @@ async function compile (fileName, options) {
|
||||
if (options.json) flags += "--json ";
|
||||
if (options.output) flags += "--output " + options.output + " ";
|
||||
|
||||
await exec("circom " + flags + fileName);
|
||||
b = await exec("circom " + flags + fileName);
|
||||
assert(b.stderr == "",
|
||||
"circom compiler error \n" + b.stderr);
|
||||
}
|
||||
|
||||
class WasmTester {
|
||||
|
||||
@@ -80,19 +80,22 @@ class WitnessCalculator {
|
||||
this.version = this.instance.exports.getVersion();
|
||||
this.n32 = this.instance.exports.getFieldNumLen32();
|
||||
|
||||
// Not needed
|
||||
// this.instance.exports.getRawPrime();
|
||||
// const arr = new Array(this.n32);
|
||||
// for (let i=0; i<this.n32; i++) {
|
||||
// arr[this.n32-1-i] = this.instance.exports.readSharedRWMemory(i);
|
||||
// }
|
||||
// this.prime = utils.fromArray32(arr);
|
||||
this.instance.exports.getRawPrime();
|
||||
const arr = new Array(this.n32);
|
||||
for (let i=0; i<this.n32; i++) {
|
||||
arr[this.n32-1-i] = this.instance.exports.readSharedRWMemory(i);
|
||||
}
|
||||
this.prime = utils.fromArray32(arr);
|
||||
|
||||
this.witnessSize = this.instance.exports.getWitnessSize();
|
||||
|
||||
this.sanityCheck = sanityCheck;
|
||||
}
|
||||
|
||||
circom_version() {
|
||||
return this.instance.exports.getVersion();
|
||||
}
|
||||
|
||||
async _doCalculateWitness(input, sanityCheck) {
|
||||
//input is assumed to be a map from signals to arrays of bigints
|
||||
this.instance.exports.init((this.sanityCheck || sanityCheck) ? 1 : 0);
|
||||
|
||||
Reference in New Issue
Block a user