Skip to content

Commit e266bd4

Browse files
committed
Fix circuits with 0 inputs
1 parent 1a79b78 commit e266bd4

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

ports/wasm/build_runtime.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,17 @@ module.exports = function buildRuntime(module, builder) {
180180
const c = f.getCodeBuilder();
181181

182182
f.addCode(
183+
// Don't call it again. (It is possoble in the init)
184+
c.i32_store(
185+
c.i32_add(
186+
c.i32_const(builder.pInputSignalsToTrigger),
187+
c.i32_mul(
188+
c.getLocal("component"),
189+
c.i32_const(4)
190+
)
191+
),
192+
c.i32_const(-1)
193+
),
183194
c.call_indirect(
184195
c.getLocal("component"), // Idx in table
185196
c.getLocal("component") // Parameter

test/basiccases.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,5 +328,12 @@
328328
"tv": [
329329
[{}, {"out": [3,4]}]
330330
]
331+
},
332+
{
333+
"name": "poma2",
334+
"circuit": "poma2.circom",
335+
"tv": [
336+
[{}, {}]
337+
]
331338
}
332339
]

test/circuits/poma2.circom

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
3+
template sum() {
4+
signal input in[2];
5+
signal output out;
6+
out <== in[0] + in[1];
7+
}
8+
9+
10+
template Test() {
11+
component hasher = sum();
12+
hasher.in[0] <== 1;
13+
hasher.in[1] <== 2;
14+
}
15+
16+
component main = Test();
17+

0 commit comments

Comments
 (0)