mirror of
https://github.com/arnaucube/circom.git
synced 2026-02-06 18:56:40 +01:00
Optimize optimization and fix out<==in
This commit is contained in:
@@ -59,4 +59,9 @@ describe("Sum test", () => {
|
||||
assert(witness[1].equals(bigInt(37)));
|
||||
assert(witness[2].equals(bigInt(6)));
|
||||
});
|
||||
it("Should compile a code with compute", async () => {
|
||||
const cirDef = await compiler(path.join(__dirname, "circuits", "inout.circom"));
|
||||
|
||||
assert.equal(cirDef.constraints.length, 1);
|
||||
});
|
||||
});
|
||||
|
||||
75
test/circuits/circuit.json
Normal file
75
test/circuits/circuit.json
Normal file
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"mainCode": "{\n}\n",
|
||||
"signalName2Idx": {
|
||||
"one": 0,
|
||||
"main.in": 2,
|
||||
"main.out": 1,
|
||||
"main.internal.in": 2,
|
||||
"main.internal.out": 2
|
||||
},
|
||||
"components": [
|
||||
{
|
||||
"name": "main",
|
||||
"params": {},
|
||||
"template": "InOut",
|
||||
"inputSignals": 1
|
||||
},
|
||||
{
|
||||
"name": "main.internal",
|
||||
"params": {},
|
||||
"template": "Internal",
|
||||
"inputSignals": 1
|
||||
}
|
||||
],
|
||||
"componentName2Idx": {
|
||||
"main": 0,
|
||||
"main.internal": 1
|
||||
},
|
||||
"signals": [
|
||||
{
|
||||
"names": [
|
||||
"one"
|
||||
],
|
||||
"triggerComponents": []
|
||||
},
|
||||
{
|
||||
"names": [
|
||||
"main.out"
|
||||
],
|
||||
"triggerComponents": []
|
||||
},
|
||||
{
|
||||
"names": [
|
||||
"main.in",
|
||||
"main.internal.in",
|
||||
"main.internal.out"
|
||||
],
|
||||
"triggerComponents": [
|
||||
0,
|
||||
1
|
||||
]
|
||||
}
|
||||
],
|
||||
"constraints": [
|
||||
[
|
||||
{},
|
||||
{},
|
||||
{
|
||||
"1": "21888242871839275222246405745257275088548364400416034343698204186575808495616",
|
||||
"2": "1"
|
||||
}
|
||||
]
|
||||
],
|
||||
"templates": {
|
||||
"Internal": "function(ctx) {\n ctx.setSignal(\"out\", [], ctx.getSignal(\"in\", []));\n}\n",
|
||||
"InOut": "function(ctx) {\n ctx.setPin(\"internal\", [], \"in\", [], ctx.getSignal(\"in\", []));\n ctx.setSignal(\"out\", [], ctx.getPin(\"internal\", [], \"out\", []));\n}\n"
|
||||
},
|
||||
"functions": {},
|
||||
"nPrvInputs": 0,
|
||||
"nPubInputs": 1,
|
||||
"nInputs": 1,
|
||||
"nOutputs": 1,
|
||||
"nVars": 3,
|
||||
"nConstants": 0,
|
||||
"nSignals": 3
|
||||
}
|
||||
18
test/circuits/inout.circom
Normal file
18
test/circuits/inout.circom
Normal file
@@ -0,0 +1,18 @@
|
||||
template Internal() {
|
||||
signal input in;
|
||||
signal output out;
|
||||
|
||||
out <== in;
|
||||
}
|
||||
|
||||
template InOut() {
|
||||
signal input in;
|
||||
signal output out;
|
||||
|
||||
component internal = Internal();
|
||||
|
||||
internal.in <== in;
|
||||
internal.out ==> out;
|
||||
}
|
||||
|
||||
component main = InOut();
|
||||
Reference in New Issue
Block a user