mirror of
https://github.com/arnaucube/circom_tester.git
synced 2026-02-06 19:06:42 +01:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd01a89971 | ||
|
|
15ddd2a0be | ||
|
|
020cb4d510 |
21
c/tester.js
21
c/tester.js
@@ -11,6 +11,8 @@ const exec = util.promisify(require("child_process").exec);
|
|||||||
const loadR1cs = require("r1csfile").load;
|
const loadR1cs = require("r1csfile").load;
|
||||||
const ZqField = require("ffjavascript").ZqField;
|
const ZqField = require("ffjavascript").ZqField;
|
||||||
|
|
||||||
|
const readWtns = require("snarkjs").wtns.exportJson;
|
||||||
|
|
||||||
module.exports = c_tester;
|
module.exports = c_tester;
|
||||||
|
|
||||||
async function c_tester(circomInput, _options) {
|
async function c_tester(circomInput, _options) {
|
||||||
@@ -46,6 +48,8 @@ async function compile (baseName, fileName, options) {
|
|||||||
if (options.r1cs) flags += "--r1cs ";
|
if (options.r1cs) flags += "--r1cs ";
|
||||||
if (options.json) flags += "--json ";
|
if (options.json) flags += "--json ";
|
||||||
if (options.output) flags += "--output " + options.output + " ";
|
if (options.output) flags += "--output " + options.output + " ";
|
||||||
|
if (options.O === 0) flags += "--O0 "
|
||||||
|
if (options.O === 1) flags += "--O1 "
|
||||||
|
|
||||||
b = await exec("circom " + flags + fileName);
|
b = await exec("circom " + flags + fileName);
|
||||||
assert(b.stderr == "",
|
assert(b.stderr == "",
|
||||||
@@ -79,7 +83,7 @@ class WasmTester {
|
|||||||
});
|
});
|
||||||
await exec("ls " + path.join(this.dir.path, this.baseName+"_cpp/"));
|
await exec("ls " + path.join(this.dir.path, this.baseName+"_cpp/"));
|
||||||
await exec(runc + " " + inputFile + " " + wtnsFile);
|
await exec(runc + " " + inputFile + " " + wtnsFile);
|
||||||
return readBinaryFile(wtnsFile);
|
return await readBinWitnessFile(wtnsFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadSymbols() {
|
async loadSymbols() {
|
||||||
@@ -206,18 +210,9 @@ async function compiler_above_version(v) {
|
|||||||
return check_versions ( compiler_version, vlist );
|
return check_versions ( compiler_version, vlist );
|
||||||
}
|
}
|
||||||
|
|
||||||
function readBinaryFile(fileName) {
|
async function readBinWitnessFile(fileName) {
|
||||||
const buff = fs.readFileSync(fileName);
|
const buffWitness = await readWtns(fileName);
|
||||||
const n32 = fromArray8ToUint(buff.slice(24,27));
|
return buffWitness;
|
||||||
var pos = 28+n32;
|
|
||||||
const ws = fromArray8ToUint(buff.slice(pos,pos+3));
|
|
||||||
pos += 16;
|
|
||||||
const w = [];
|
|
||||||
for (let i=0; i<ws; i++) {
|
|
||||||
w.push(fromArray8(buff.slice(pos,pos+n32-1)));
|
|
||||||
pos += n32;
|
|
||||||
}
|
|
||||||
return w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function fromArray8(arr) { //returns a BigInt
|
function fromArray8(arr) { //returns a BigInt
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "circom_tester",
|
"name": "circom_tester",
|
||||||
"version": "0.0.6",
|
"version": "0.0.7",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "circom_tester",
|
"name": "circom_tester",
|
||||||
"version": "0.0.6",
|
"version": "0.0.7",
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chai": "^4.3.4",
|
"chai": "^4.3.4",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "circom_tester",
|
"name": "circom_tester",
|
||||||
"version": "0.0.6",
|
"version": "0.0.7",
|
||||||
"description": "Tools for testing circom circuits.",
|
"description": "Tools for testing circom circuits.",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -29,6 +29,7 @@
|
|||||||
"fnv-plus": "^1.3.1",
|
"fnv-plus": "^1.3.1",
|
||||||
"r1csfile": "0.0.16",
|
"r1csfile": "0.0.16",
|
||||||
"tmp-promise": "^3.0.2",
|
"tmp-promise": "^3.0.2",
|
||||||
"util": "^0.12.4"
|
"util": "^0.12.4",
|
||||||
|
"snarkjs": "0.4.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ async function compile (fileName, options) {
|
|||||||
if (options.r1cs) flags += "--r1cs ";
|
if (options.r1cs) flags += "--r1cs ";
|
||||||
if (options.json) flags += "--json ";
|
if (options.json) flags += "--json ";
|
||||||
if (options.output) flags += "--output " + options.output + " ";
|
if (options.output) flags += "--output " + options.output + " ";
|
||||||
|
if (options.O === 0) flags += "--O0 "
|
||||||
|
if (options.O === 1) flags += "--O1 "
|
||||||
|
|
||||||
b = await exec("circom " + flags + fileName);
|
b = await exec("circom " + flags + fileName);
|
||||||
assert(b.stderr == "",
|
assert(b.stderr == "",
|
||||||
|
|||||||
Reference in New Issue
Block a user