Skip to content

Commit

Permalink
Extend snarkjs testing
Browse files Browse the repository at this point in the history
This PR adds a test invoking all of the commands in `snarkjs --help`.

The new files in `snark_js/circom_files` were generated by Circom v2.1.5 (not
the latest release, but close enough).  I have considered the possibility that
Circom & Snarkjs undergo an update, introducing errors in the test script from
our outdated serializations in `circom_files/`.  Informally, I'd estimate the
likelihood is low.  I've never encountered or heard about snarkjs breaking
changes.  There are enough Circom circuits in production use cases out there, I
suspect they develop around backwards compatibility

Since the test script generates so many intermediate files - I created
`/tmp/snarkjs` at the beginning of the script and remove it at the end.  There
are plenty of subdirectories added to this folder, but I never bother to delete
them.  I let the recursive flag handle all that at the end.  Just pointing this
out in case there is a reason not to do that (if `test.sh` ends early, many
intermediate files are left).

Merges #6
  • Loading branch information
katiemckeon authored Feb 25, 2024
1 parent c797059 commit 51f7bbc
Show file tree
Hide file tree
Showing 7 changed files with 464 additions and 0 deletions.
18 changes: 18 additions & 0 deletions images/snarkjs/circom-files/circuit.circom
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
pragma circom 2.0.0;

template Multiplier(n) {
signal input a;
signal input b;
signal output c;

signal int[n];

int[0] <== a*a + b;
for (var i=1; i<n; i++) {
int[i] <== int[i-1]*int[i-1] + b;
}

c <== int[n-1];
}

component main = Multiplier(300);
Binary file added images/snarkjs/circom-files/circuit.r1cs
Binary file not shown.
303 changes: 303 additions & 0 deletions images/snarkjs/circom-files/circuit.sym
Original file line number Diff line number Diff line change
@@ -0,0 +1,303 @@
1,1,0,main.c
2,2,0,main.a
3,3,0,main.b
4,4,0,main.int[0]
5,5,0,main.int[1]
6,6,0,main.int[2]
7,7,0,main.int[3]
8,8,0,main.int[4]
9,9,0,main.int[5]
10,10,0,main.int[6]
11,11,0,main.int[7]
12,12,0,main.int[8]
13,13,0,main.int[9]
14,14,0,main.int[10]
15,15,0,main.int[11]
16,16,0,main.int[12]
17,17,0,main.int[13]
18,18,0,main.int[14]
19,19,0,main.int[15]
20,20,0,main.int[16]
21,21,0,main.int[17]
22,22,0,main.int[18]
23,23,0,main.int[19]
24,24,0,main.int[20]
25,25,0,main.int[21]
26,26,0,main.int[22]
27,27,0,main.int[23]
28,28,0,main.int[24]
29,29,0,main.int[25]
30,30,0,main.int[26]
31,31,0,main.int[27]
32,32,0,main.int[28]
33,33,0,main.int[29]
34,34,0,main.int[30]
35,35,0,main.int[31]
36,36,0,main.int[32]
37,37,0,main.int[33]
38,38,0,main.int[34]
39,39,0,main.int[35]
40,40,0,main.int[36]
41,41,0,main.int[37]
42,42,0,main.int[38]
43,43,0,main.int[39]
44,44,0,main.int[40]
45,45,0,main.int[41]
46,46,0,main.int[42]
47,47,0,main.int[43]
48,48,0,main.int[44]
49,49,0,main.int[45]
50,50,0,main.int[46]
51,51,0,main.int[47]
52,52,0,main.int[48]
53,53,0,main.int[49]
54,54,0,main.int[50]
55,55,0,main.int[51]
56,56,0,main.int[52]
57,57,0,main.int[53]
58,58,0,main.int[54]
59,59,0,main.int[55]
60,60,0,main.int[56]
61,61,0,main.int[57]
62,62,0,main.int[58]
63,63,0,main.int[59]
64,64,0,main.int[60]
65,65,0,main.int[61]
66,66,0,main.int[62]
67,67,0,main.int[63]
68,68,0,main.int[64]
69,69,0,main.int[65]
70,70,0,main.int[66]
71,71,0,main.int[67]
72,72,0,main.int[68]
73,73,0,main.int[69]
74,74,0,main.int[70]
75,75,0,main.int[71]
76,76,0,main.int[72]
77,77,0,main.int[73]
78,78,0,main.int[74]
79,79,0,main.int[75]
80,80,0,main.int[76]
81,81,0,main.int[77]
82,82,0,main.int[78]
83,83,0,main.int[79]
84,84,0,main.int[80]
85,85,0,main.int[81]
86,86,0,main.int[82]
87,87,0,main.int[83]
88,88,0,main.int[84]
89,89,0,main.int[85]
90,90,0,main.int[86]
91,91,0,main.int[87]
92,92,0,main.int[88]
93,93,0,main.int[89]
94,94,0,main.int[90]
95,95,0,main.int[91]
96,96,0,main.int[92]
97,97,0,main.int[93]
98,98,0,main.int[94]
99,99,0,main.int[95]
100,100,0,main.int[96]
101,101,0,main.int[97]
102,102,0,main.int[98]
103,103,0,main.int[99]
104,104,0,main.int[100]
105,105,0,main.int[101]
106,106,0,main.int[102]
107,107,0,main.int[103]
108,108,0,main.int[104]
109,109,0,main.int[105]
110,110,0,main.int[106]
111,111,0,main.int[107]
112,112,0,main.int[108]
113,113,0,main.int[109]
114,114,0,main.int[110]
115,115,0,main.int[111]
116,116,0,main.int[112]
117,117,0,main.int[113]
118,118,0,main.int[114]
119,119,0,main.int[115]
120,120,0,main.int[116]
121,121,0,main.int[117]
122,122,0,main.int[118]
123,123,0,main.int[119]
124,124,0,main.int[120]
125,125,0,main.int[121]
126,126,0,main.int[122]
127,127,0,main.int[123]
128,128,0,main.int[124]
129,129,0,main.int[125]
130,130,0,main.int[126]
131,131,0,main.int[127]
132,132,0,main.int[128]
133,133,0,main.int[129]
134,134,0,main.int[130]
135,135,0,main.int[131]
136,136,0,main.int[132]
137,137,0,main.int[133]
138,138,0,main.int[134]
139,139,0,main.int[135]
140,140,0,main.int[136]
141,141,0,main.int[137]
142,142,0,main.int[138]
143,143,0,main.int[139]
144,144,0,main.int[140]
145,145,0,main.int[141]
146,146,0,main.int[142]
147,147,0,main.int[143]
148,148,0,main.int[144]
149,149,0,main.int[145]
150,150,0,main.int[146]
151,151,0,main.int[147]
152,152,0,main.int[148]
153,153,0,main.int[149]
154,154,0,main.int[150]
155,155,0,main.int[151]
156,156,0,main.int[152]
157,157,0,main.int[153]
158,158,0,main.int[154]
159,159,0,main.int[155]
160,160,0,main.int[156]
161,161,0,main.int[157]
162,162,0,main.int[158]
163,163,0,main.int[159]
164,164,0,main.int[160]
165,165,0,main.int[161]
166,166,0,main.int[162]
167,167,0,main.int[163]
168,168,0,main.int[164]
169,169,0,main.int[165]
170,170,0,main.int[166]
171,171,0,main.int[167]
172,172,0,main.int[168]
173,173,0,main.int[169]
174,174,0,main.int[170]
175,175,0,main.int[171]
176,176,0,main.int[172]
177,177,0,main.int[173]
178,178,0,main.int[174]
179,179,0,main.int[175]
180,180,0,main.int[176]
181,181,0,main.int[177]
182,182,0,main.int[178]
183,183,0,main.int[179]
184,184,0,main.int[180]
185,185,0,main.int[181]
186,186,0,main.int[182]
187,187,0,main.int[183]
188,188,0,main.int[184]
189,189,0,main.int[185]
190,190,0,main.int[186]
191,191,0,main.int[187]
192,192,0,main.int[188]
193,193,0,main.int[189]
194,194,0,main.int[190]
195,195,0,main.int[191]
196,196,0,main.int[192]
197,197,0,main.int[193]
198,198,0,main.int[194]
199,199,0,main.int[195]
200,200,0,main.int[196]
201,201,0,main.int[197]
202,202,0,main.int[198]
203,203,0,main.int[199]
204,204,0,main.int[200]
205,205,0,main.int[201]
206,206,0,main.int[202]
207,207,0,main.int[203]
208,208,0,main.int[204]
209,209,0,main.int[205]
210,210,0,main.int[206]
211,211,0,main.int[207]
212,212,0,main.int[208]
213,213,0,main.int[209]
214,214,0,main.int[210]
215,215,0,main.int[211]
216,216,0,main.int[212]
217,217,0,main.int[213]
218,218,0,main.int[214]
219,219,0,main.int[215]
220,220,0,main.int[216]
221,221,0,main.int[217]
222,222,0,main.int[218]
223,223,0,main.int[219]
224,224,0,main.int[220]
225,225,0,main.int[221]
226,226,0,main.int[222]
227,227,0,main.int[223]
228,228,0,main.int[224]
229,229,0,main.int[225]
230,230,0,main.int[226]
231,231,0,main.int[227]
232,232,0,main.int[228]
233,233,0,main.int[229]
234,234,0,main.int[230]
235,235,0,main.int[231]
236,236,0,main.int[232]
237,237,0,main.int[233]
238,238,0,main.int[234]
239,239,0,main.int[235]
240,240,0,main.int[236]
241,241,0,main.int[237]
242,242,0,main.int[238]
243,243,0,main.int[239]
244,244,0,main.int[240]
245,245,0,main.int[241]
246,246,0,main.int[242]
247,247,0,main.int[243]
248,248,0,main.int[244]
249,249,0,main.int[245]
250,250,0,main.int[246]
251,251,0,main.int[247]
252,252,0,main.int[248]
253,253,0,main.int[249]
254,254,0,main.int[250]
255,255,0,main.int[251]
256,256,0,main.int[252]
257,257,0,main.int[253]
258,258,0,main.int[254]
259,259,0,main.int[255]
260,260,0,main.int[256]
261,261,0,main.int[257]
262,262,0,main.int[258]
263,263,0,main.int[259]
264,264,0,main.int[260]
265,265,0,main.int[261]
266,266,0,main.int[262]
267,267,0,main.int[263]
268,268,0,main.int[264]
269,269,0,main.int[265]
270,270,0,main.int[266]
271,271,0,main.int[267]
272,272,0,main.int[268]
273,273,0,main.int[269]
274,274,0,main.int[270]
275,275,0,main.int[271]
276,276,0,main.int[272]
277,277,0,main.int[273]
278,278,0,main.int[274]
279,279,0,main.int[275]
280,280,0,main.int[276]
281,281,0,main.int[277]
282,282,0,main.int[278]
283,283,0,main.int[279]
284,284,0,main.int[280]
285,285,0,main.int[281]
286,286,0,main.int[282]
287,287,0,main.int[283]
288,288,0,main.int[284]
289,289,0,main.int[285]
290,290,0,main.int[286]
291,291,0,main.int[287]
292,292,0,main.int[288]
293,293,0,main.int[289]
294,294,0,main.int[290]
295,295,0,main.int[291]
296,296,0,main.int[292]
297,297,0,main.int[293]
298,298,0,main.int[294]
299,299,0,main.int[295]
300,300,0,main.int[296]
301,301,0,main.int[297]
302,302,0,main.int[298]
303,-1,0,main.int[299]
Binary file added images/snarkjs/circom-files/circuit.wasm
Binary file not shown.
1 change: 1 addition & 0 deletions images/snarkjs/circom-files/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"a": 3, "b": 11}
Binary file added images/snarkjs/circom-files/witness.wtns
Binary file not shown.
Loading

0 comments on commit 51f7bbc

Please sign in to comment.