mirror of
https://github.com/arnaucube/circomlib.git
synced 2026-02-07 03:06:44 +01:00
first commit
This commit is contained in:
33
test/multiplexer.js
Normal file
33
test/multiplexer.js
Normal file
@@ -0,0 +1,33 @@
|
||||
const chai = require("chai");
|
||||
const path = require("path");
|
||||
const zkSnark = require("zksnark");
|
||||
const compiler = require("circom");
|
||||
|
||||
const assert = chai.assert;
|
||||
|
||||
const bigInt = require("big-integer");
|
||||
|
||||
|
||||
describe("Mux4 test", () => {
|
||||
it("Should create a constant multiplexer", async () => {
|
||||
|
||||
const cirDef = await compiler(path.join(__dirname, "circuits", "mux4_1.circom"));
|
||||
|
||||
// console.log(JSON.stringify(cirDef, null, 1));
|
||||
|
||||
// assert.equal(cirDef.nVars, 2);
|
||||
|
||||
const circuit = new zkSnark.Circuit(cirDef);
|
||||
|
||||
console.log("NConstrains: " + circuit.nConstraints);
|
||||
|
||||
for (i=0; i<16; i++) {
|
||||
const w = circuit.calculateWitness({ "selector": zkSnark.bigInt(i).toString() });
|
||||
|
||||
assert(w[0].equals(zkSnark.bigInt(1)));
|
||||
|
||||
console.log(i + " -> " + w[circuit.getSignalIdx("main.out")].toString());
|
||||
// assert(w[circuit.getSignalIdx("main.out")].equals(zkSnark.bigInt("100").add(zkSnark.bigInt(i))));
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user