mirror of
https://github.com/arnaucube/circom_tester.git
synced 2026-02-07 19:36:42 +01:00
Compare commits
1 Commits
main
...
fix/check-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
89bcaf436e |
21
c/tester.js
21
c/tester.js
@@ -11,8 +11,6 @@ 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) {
|
||||||
@@ -83,7 +81,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 await readBinWitnessFile(wtnsFile);
|
return readBinaryFile(wtnsFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadSymbols() {
|
async loadSymbols() {
|
||||||
@@ -204,15 +202,24 @@ function check_versions ( v1, v2 ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function compiler_above_version(v) {
|
async function compiler_above_version(v) {
|
||||||
let output = await exec('circom --version').toString();
|
let output = (await exec('circom --version')).stdout;
|
||||||
let compiler_version = version_to_list(output.slice(output.search(/\d/),-1));
|
let compiler_version = version_to_list(output.slice(output.search(/\d/),-1));
|
||||||
vlist = version_to_list(v);
|
vlist = version_to_list(v);
|
||||||
return check_versions ( compiler_version, vlist );
|
return check_versions ( compiler_version, vlist );
|
||||||
}
|
}
|
||||||
|
|
||||||
async function readBinWitnessFile(fileName) {
|
function readBinaryFile(fileName) {
|
||||||
const buffWitness = await readWtns(fileName);
|
const buff = fs.readFileSync(fileName);
|
||||||
return buffWitness;
|
const n32 = fromArray8ToUint(buff.slice(24,27));
|
||||||
|
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
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
"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"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ function check_versions ( v1, v2 ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function compiler_above_version(v) {
|
async function compiler_above_version(v) {
|
||||||
let output = await exec('circom --version').toString();
|
let output = (await exec('circom --version')).stdout;
|
||||||
let compiler_version = version_to_list(output.slice(output.search(/\d/),-1));
|
let compiler_version = version_to_list(output.slice(output.search(/\d/),-1));
|
||||||
vlist = version_to_list(v);
|
vlist = version_to_list(v);
|
||||||
return check_versions ( compiler_version, vlist );
|
return check_versions ( compiler_version, vlist );
|
||||||
|
|||||||
Reference in New Issue
Block a user