circom/ports/wasm/build_runtime.js
ports/wasm/build_runtime.jsRaw
1const errs = require("./errs");
2
3
4const buildWasmFf = require("ffwasm").buildWasmFf;
5
6
7module.exports = function buildRuntime(module, builder) {
8
9 const pSanityCheck = module.alloc(4);
10
11 function buildInit() {
12 const f = module.addFunction("init");
13 f.addParam("sanityCheck", "i32");
14 f.addLocal("i", "i32");
15
16 const c = f.getCodeBuilder();
17
18 // Set the stack to current memory
19 f.addCode(
20 c.i32_store(
21 c.i32_const(4),
22 c.i32_shl(
23 c.i32_and(
24 c.current_memory(),
25 c.i32_const(0xFFFFFFF8)
26 ),
27 c.i32_const(16)
28 )
29 )
30 );
31
32 // Save Sanity check flag
33 f.addCode(
34 c.i32_store(
35 c.i32_const(pSanityCheck),
36 c.getLocal("sanityCheck")
37 )
38 );
39
40 f.addCode(
41 // i=0
42 c.setLocal("i", c.i32_const(0)),
43 c.block(c.loop(
44 // if (i==NComponents) break
45 c.br_if(1, c.i32_eq(c.getLocal("i"), c.i32_const(builder.header.NComponents))),
46
47 // inputSignalsToTrigger[i] = components[i].nInputSignals
48 c.i32_store(
49 c.i32_add(
50 c.i32_const(builder.pInputSignalsToTrigger),
51 c.i32_mul(
52 c.getLocal("i"),
53 c.i32_const(4)
54 )
55 ),
56 c.i32_load(
57 c.i32_add(
58 c.i32_load(c.i32_const(builder.ppComponents)),
59 c.i32_mul(
60 c.getLocal("i"),
61 c.i32_const(builder.sizeofComponent) // Sizeof component
62 )
63 ),
64 builder.offsetComponentNInputSignals
65 )
66 ),
67
68 // i=i+1
69 c.setLocal(
70 "i",
71 c.i32_add(
72 c.getLocal("i"),
73 c.i32_const(1)
74 )
75 ),
76 c.br(0)
77 ))
78 );
79
80 f.addCode(ifSanityCheck(c,
81 // i=0
82 c.setLocal("i", c.i32_const(0)),
83 c.block(c.loop(
84 // if (i==NSignals) break
85 c.br_if(1, c.i32_eq(c.getLocal("i"), c.i32_const(builder.header.NSignals))),
86
87 // signalsAssigned[i] = false
88 c.i32_store(
89 c.i32_add(
90 c.i32_const(builder.pSignalsAssigned),
91 c.i32_mul(
92 c.getLocal("i"),
93 c.i32_const(4)
94 )
95 ),
96 c.i32_const(0)
97 ),
98
99 // i=i+1
100 c.setLocal(
101 "i",
102 c.i32_add(
103 c.getLocal("i"),
104 c.i32_const(1)
105 )
106 ),
107 c.br(0)
108 ))
109 ));
110
111 f.addCode(
112 c.call(
113 "Fr_copy",
114 c.i32_const(builder.pSignals),
115 c.i32_add(
116 c.i32_load(c.i32_const(builder.ppConstants)),
117 c.i32_const(builder.addConstant(1) * builder.sizeFr)
118 )
119 )
120 );
121 f.addCode(ifSanityCheck(c,
122 c.i32_store(
123 c.i32_const(builder.pSignalsAssigned),
124 c.i32_const(1)
125 )
126 ));
127
128 f.addCode(
129 // i=0
130 c.setLocal("i", c.i32_const(0)),
131 c.block(c.loop(
132 // if (i==NComponents) break
133 c.br_if(1, c.i32_eq(c.getLocal("i"), c.i32_const(builder.header.NComponents))),
134
135 // if (inputSignalsToTrigger[i] == 0) triggerComponent(i)
136 c.if(
137 c.i32_eqz(
138 c.i32_load(
139 c.i32_add(
140 c.i32_const(builder.pInputSignalsToTrigger),
141 c.i32_mul(
142 c.getLocal("i"),
143 c.i32_const(4)
144 )
145 )
146 )
147 ),
148 c.call(
149 "triggerComponent",
150 c.getLocal("i")
151 )
152 ),
153
154 // i=i+1
155 c.setLocal(
156 "i",
157 c.i32_add(
158 c.getLocal("i"),
159 c.i32_const(1)
160 )
161 ),
162 c.br(0)
163 ))
164 );
165
166 }
167
168 function ifSanityCheck(c, ...args) {
169 return c.if(
170 c.i32_load(c.i32_const(pSanityCheck)),
171 [].concat(...[...args])
172 );
173 }
174
175
176 function buildTriggerComponent() {
177 const f = module.addFunction("triggerComponent");
178 f.addParam("component", "i32");
179
180 const c = f.getCodeBuilder();
181
182 f.addCode(
183 c.call_indirect(
184 c.getLocal("component"), // Idx in table
185 c.getLocal("component") // Parameter
186 )
187 );
188
189 }
190
191
192 function buildHash2ComponentEntry() {
193 const f = module.addFunction("hash2ComponentEntry");
194 f.addParam("component", "i32");
195 f.addParam("hash", "i64");
196 f.setReturnType("i32");
197
198 f.addLocal("pComponent", "i32");
199 f.addLocal("pHashTable", "i32");
200 f.addLocal("hIdx", "i32");
201 f.addLocal("h", "i64");
202
203 const c = f.getCodeBuilder();
204
205 f.addCode(
206 c.setLocal(
207 "pComponent",
208 c.i32_add(
209 c.i32_load(c.i32_const(builder.ppComponents)), // pComponents
210 c.i32_mul(
211 c.getLocal("component"),
212 c.i32_const(20) // sizeof(Component)
213 )
214 )
215 ),
216 c.setLocal(
217 "pHashTable",
218 c.i32_load(c.getLocal("pComponent"))
219 ),
220 c.setLocal(
221 "hIdx",
222 c.i32_and(
223 c.i32_wrap_i64(c.getLocal("hash")),
224 c.i32_const(0xFF)
225 )
226 ),
227 c.block(c.loop(
228 c.setLocal(
229 "h",
230 c.i64_load(
231 c.i32_add(
232 c.getLocal("pHashTable"),
233 c.i32_mul(
234 c.getLocal("hIdx"),
235 c.i32_const(12)
236 )
237 )
238 )
239 ),
240 c.br_if(1, c.i64_eq(c.getLocal("h"), c.getLocal("hash"))),
241 c.if(
242 c.i64_eqz(c.getLocal("h")),
243 c.call(
244 "error",
245 c.i32_const(errs.HASH_NOT_FOUND.code),
246 c.i32_const(errs.HASH_NOT_FOUND.pointer),
247 c.i32_const(0),
248 c.i32_const(0),
249 c.i32_const(0),
250 c.i32_const(0)
251 )
252 ),
253 c.setLocal(
254 "hIdx",
255 c.i32_and(
256 c.i32_add(
257 c.getLocal("hIdx"),
258 c.i32_const(1)
259 ),
260 c.i32_const(0xFF)
261 )
262 ),
263 c.br(0)
264 )),
265
266 c.i32_add( // pComponentEntry
267 c.i32_load( // pComponentEntryTable
268 c.i32_add(
269 c.getLocal("pComponent"),
270 c.i32_const(4)
271 )
272 ),
273 c.i32_mul(
274 c.i32_load( // idx to the componentEntry
275 c.i32_add(
276 c.getLocal("pHashTable"),
277 c.i32_mul(
278 c.getLocal("hIdx"),
279 c.i32_const(12)
280 )
281 ),
282 8
283 ),
284 c.i32_const(12)
285 )
286 )
287 );
288 }
289
290 function buildGetFromComponentEntry(fnName, offset, type) {
291 const f = module.addFunction(fnName);
292 f.addParam("pR", "i32");
293 f.addParam("component", "i32");
294 f.addParam("hash", "i64");
295 f.addLocal("pComponentEntry", "i32");
296
297 const c = f.getCodeBuilder();
298
299 f.addCode(
300 c.setLocal(
301 "pComponentEntry",
302 c.call(
303 "hash2ComponentEntry",
304 c.getLocal("component"),
305 c.getLocal("hash")
306 )
307 ),
308 c.if( // If type is not signal
309 c.i32_ne(
310 c.i32_load(
311 c.getLocal("pComponentEntry"),
312 8 // type offset
313 ),
314 c.i32_const(type)
315 ),
316 c.call(
317 "error",
318 c.i32_const(errs.INVALID_TYPE.code),
319 c.i32_const(errs.INVALID_TYPE.pointer),
320 c.i32_const(0),
321 c.i32_const(0),
322 c.i32_const(0),
323 c.i32_const(0)
324 )
325 ),
326 c.i32_store(
327 c.getLocal("pR"),
328 c.i32_load(
329 c.getLocal("pComponentEntry"),
330 offset
331 )
332 )
333 );
334
335 const f2 = module.addFunction(fnName + "32");
336 f2.addParam("pR", "i32");
337 f2.addParam("component", "i32");
338 f2.addParam("hashMSB", "i32");
339 f2.addParam("hashLSB", "i32");
340
341 const c2 = f2.getCodeBuilder();
342
343 f2.addCode(
344 c2.call(
345 fnName,
346 c2.getLocal("pR"),
347 c2.getLocal("component"),
348 c2.i64_or(
349 c2.i64_shl(
350 c2.i64_extend_i32_u(c2.getLocal("hashMSB")),
351 c2.i64_const(32)
352 ),
353 c2.i64_extend_i32_u(c2.getLocal("hashLSB"))
354 )
355 )
356 );
357
358 }
359
360
361 function buildGetSignal() {
362 const f = module.addFunction("getSignal");
363 f.addParam("cIdx", "i32");
364 f.addParam("pR", "i32");
365 f.addParam("component", "i32");
366 f.addParam("signal", "i32");
367
368 const c = f.getCodeBuilder();
369
370 f.addCode(ifSanityCheck(c,
371 c.if(
372 c.i32_eqz(
373 c.i32_load(
374 c.i32_add(
375 c.i32_const(builder.pSignalsAssigned),
376 c.i32_mul(
377 c.getLocal("signal"),
378 c.i32_const(4)
379 )
380 ),
381 )
382 ),
383 c.call(
384 "error",
385 c.i32_const(errs.ACCESSING_NOT_ASSIGNED_SIGNAL.code),
386 c.i32_const(errs.ACCESSING_NOT_ASSIGNED_SIGNAL.pointer),
387 c.getLocal("cIdx"),
388 c.getLocal("component"),
389 c.getLocal("signal"),
390 c.i32_const(0)
391 )
392 )
393 ));
394
395 f.addCode(
396 c.call(
397 "Fr_copy",
398 c.getLocal("pR"),
399 c.i32_add(
400 c.i32_const(builder.pSignals),
401 c.i32_mul(
402 c.getLocal("signal"),
403 c.i32_const(builder.sizeFr)
404 )
405 )
406 )
407 );
408
409 f.addCode(ifSanityCheck(c,
410 c.call("logGetSignal", c.getLocal("signal"), c.getLocal("pR") )
411 ));
412
413 }
414
415 function buildMultiGetSignal() {
416 const f = module.addFunction("multiGetSignal");
417 f.addParam("cIdx", "i32");
418 f.addParam("pR", "i32");
419 f.addParam("component", "i32");
420 f.addParam("signal", "i32");
421 f.addParam("n", "i32");
422 f.addLocal("i", "i32");
423
424 const c = f.getCodeBuilder();
425
426 f.addCode(
427 c.setLocal("i", c.i32_const(0)),
428 c.block(c.loop(
429 c.br_if(1, c.i32_eq(c.getLocal("i"), c.getLocal("n"))),
430 c.call(
431 "getSignal",
432 c.getLocal("cIdx"),
433 c.i32_add(
434 c.getLocal("pR"),
435 c.i32_mul(
436 c.getLocal("i"),
437 c.i32_const(builder.sizeFr)
438 )
439 ),
440 c.getLocal("component"),
441 c.i32_add(
442 c.getLocal("signal"),
443 c.getLocal("i")
444 )
445 ),
446 c.setLocal("i", c.i32_add(c.getLocal("i"), c.i32_const(1))),
447 c.br(0)
448 ))
449 );
450 }
451
452 function buildSetSignal() {
453 const f = module.addFunction("setSignal");
454 f.addParam("cIdx", "i32");
455 f.addParam("component", "i32");
456 f.addParam("signal", "i32");
457 f.addParam("pVal", "i32");
458 f.addLocal("signalsToTrigger", "i32");
459
460 const c = f.getCodeBuilder();
461
462
463 f.addCode(ifSanityCheck(c,
464 c.call("logSetSignal", c.getLocal("signal"), c.getLocal("pVal") ),
465 c.if(
466 c.i32_load(
467 c.i32_add(
468 c.i32_const(builder.pSignalsAssigned),
469 c.i32_mul(
470 c.getLocal("signal"),
471 c.i32_const(4)
472 )
473 ),
474 ),
475 c.call(
476 "error",
477 c.i32_const(errs.SIGNAL_ASSIGNED_TWICE.code),
478 c.i32_const(errs.SIGNAL_ASSIGNED_TWICE.pointer),
479 c.i32_const(0),
480 c.i32_const(0),
481 c.i32_const(0),
482 c.i32_const(0)
483 )
484 ),
485 c.i32_store(
486 c.i32_add(
487 c.i32_const(builder.pSignalsAssigned),
488 c.i32_mul(
489 c.getLocal("signal"),
490 c.i32_const(4)
491 )
492 ),
493 c.i32_const(1)
494 ),
495 ));
496
497 f.addCode(
498 c.call(
499 "Fr_copy",
500 c.i32_add(
501 c.i32_const(builder.pSignals),
502 c.i32_mul(
503 c.getLocal("signal"),
504 c.i32_const(builder.sizeFr)
505 )
506 ),
507 c.getLocal("pVal"),
508 )
509 );
510
511 f.addCode(
512 c.if( // If ( mapIsInput[s >> 5] & (1 << (s & 0x1f)) )
513 c.i32_and(
514 c.i32_load(
515 c.i32_add(
516 c.i32_load(c.i32_const(builder.ppMapIsInput)),
517 c.i32_shl(
518 c.i32_shr_u(
519 c.getLocal("signal"),
520 c.i32_const(5)
521 ),
522 c.i32_const(2)
523 )
524 )
525 ),
526 c.i32_shl(
527 c.i32_const(1),
528 c.i32_and(
529 c.getLocal("signal"),
530 c.i32_const(0x1F)
531 )
532 )
533 ),
534 [
535
536 ...c.setLocal(
537 "signalsToTrigger",
538 c.i32_load(
539 c.i32_add(
540 c.i32_const(builder.pInputSignalsToTrigger),
541 c.i32_mul(
542 c.getLocal("component"),
543 c.i32_const(4)
544 )
545 )
546 )
547 ),
548
549 ...c.if( // if (signalsToTrigger > 0)
550 c.i32_gt_u(
551 c.getLocal("signalsToTrigger"),
552 c.i32_const(0)
553 ),
554 [
555 ...c.setLocal( // signalsToTrigger--
556 "signalsToTrigger",
557 c.i32_sub(
558 c.getLocal("signalsToTrigger"),
559 c.i32_const(1)
560 )
561 ),
562 ...c.i32_store(
563 c.i32_add(
564 c.i32_const(builder.pInputSignalsToTrigger),
565 c.i32_mul(
566 c.getLocal("component"),
567 c.i32_const(4)
568 )
569 ),
570 c.getLocal("signalsToTrigger"),
571 ),
572 ...c.if( // if (signalsToTrigger==0) triggerCompomnent(component)
573 c.i32_eqz(c.getLocal("signalsToTrigger")),
574 c.call(
575 "triggerComponent",
576 c.getLocal("component")
577 )
578 )
579 ],
580 c.call(
581 "error",
582 c.i32_const(errs.MAPISINPUT_DONT_MATCH.code),
583 c.i32_const(errs.MAPISINPUT_DONT_MATCH.pointer),
584 c.getLocal("component"),
585 c.getLocal("signal"),
586 c.i32_const(0),
587 c.i32_const(0)
588 )
589 )
590 ]
591 )
592 );
593 }
594
595 function buildComponentFinished() {
596 const f = module.addFunction("componentFinished");
597 f.addParam("cIdx", "i32");
598
599 const c = f.getCodeBuilder();
600
601 f.addCode(ifSanityCheck(c,
602 c.call("logFinishComponent", c.getLocal("cIdx"))
603 ));
604
605 f.addCode(c.ret([]));
606 }
607
608 function buildComponentStarted() {
609 const f = module.addFunction("componentStarted");
610 f.addParam("cIdx", "i32");
611
612 const c = f.getCodeBuilder();
613
614 f.addCode(ifSanityCheck(c,
615 c.call("logStartComponent", c.getLocal("cIdx"))
616 ));
617
618 f.addCode(c.ret([]));
619 }
620
621 function buildCheckConstraint() {
622 const pTmp = module.alloc(builder.sizeFr);
623 const f = module.addFunction("checkConstraint");
624 f.addParam("cIdx", "i32");
625 f.addParam("pA", "i32");
626 f.addParam("pB", "i32");
627 f.addParam("pStr", "i32");
628
629 const c = f.getCodeBuilder();
630
631 f.addCode(ifSanityCheck(c,
632 c.call(
633 "Fr_eq",
634 c.i32_const(pTmp),
635 c.getLocal("pA"),
636 c.getLocal("pB")
637 ),
638 c.if (
639 c.i32_eqz(
640 c.call(
641 "Fr_isTrue",
642 c.i32_const(pTmp),
643 )
644 ),
645 c.call(
646 "error",
647 c.i32_const(errs.CONSTRAIN_DOES_NOT_MATCH.code),
648 c.i32_const(errs.CONSTRAIN_DOES_NOT_MATCH.pointer),
649 c.getLocal("cIdx"),
650 c.getLocal("pA"),
651 c.getLocal("pB"),
652 c.getLocal("pStr"),
653 )
654 )
655 ));
656 }
657
658 function buildCheckAssert() {
659 const f = module.addFunction("checkAssert");
660 f.addParam("cIdx", "i32");
661 f.addParam("pA", "i32");
662 f.addParam("pStr", "i32");
663
664 const c = f.getCodeBuilder();
665
666 f.addCode(ifSanityCheck(c,
667 c.if (
668 c.i32_eqz(
669 c.call(
670 "Fr_isTrue",
671 c.getLocal("pA"),
672 )
673 ),
674 c.call(
675 "error",
676 c.i32_const(errs.ASSERT_DOES_NOT_MATCH.code),
677 c.i32_const(errs.ASSERT_DOES_NOT_MATCH.pointer),
678 c.getLocal("cIdx"),
679 c.getLocal("pA"),
680 c.getLocal("pStr"),
681 c.i32_const(0)
682 )
683 )
684 ));
685 }
686
687 function buildGetNVars() {
688 const f = module.addFunction("getNVars");
689 f.setReturnType("i32");
690
691 const c = f.getCodeBuilder();
692
693 f.addCode(c.i32_const(builder.header.NVars));
694 }
695
696 function buildGetNPublic() {
697 const f = module.addFunction("getNPublic");
698 f.setReturnType("i32");
699
700 const c = f.getCodeBuilder();
701
702 f.addCode(c.i32_const(builder.header.NPublic));
703 }
704
705 function buildGetFrLen() {
706 const f = module.addFunction("getFrLen");
707 f.setReturnType("i32");
708
709 const c = f.getCodeBuilder();
710
711 f.addCode(
712 c.i32_const(builder.sizeFr));
713 }
714
715 function buildGetPRawPrime() {
716 const f = module.addFunction("getPRawPrime");
717 f.setReturnType("i32");
718
719 const c = f.getCodeBuilder();
720
721 f.addCode(
722 c.i32_const(module.modules["Fr_F1m"].pq));
723 }
724
725 function buildGetPWitness() {
726 const f = module.addFunction("getPWitness");
727 f.addParam("w", "i32");
728 f.addLocal("signal", "i32");
729 f.setReturnType("i32");
730
731 const c = f.getCodeBuilder();
732
733
734 f.addCode(
735 c.setLocal(
736 "signal",
737 c.i32_load( // wit2sig[w]
738 c.i32_add(
739 c.i32_load( c.i32_const(builder.ppWit2sig)),
740 c.i32_mul(
741 c.getLocal("w"),
742 c.i32_const(4)
743 )
744 )
745 )
746 )
747 );
748
749 if (builder.sanityCheck) {
750 f.addCode(
751 c.if(
752 c.i32_eqz(
753 c.i32_load(
754 c.i32_add(
755 c.i32_const(builder.pSignalsAssigned),
756 c.i32_mul(
757 c.getLocal("signal"),
758 c.i32_const(4)
759 )
760 ),
761 )
762 ),
763 c.call(
764 "error",
765 c.i32_const(errs.ACCESSING_NOT_ASSIGNED_SIGNAL.code),
766 c.i32_const(errs.ACCESSING_NOT_ASSIGNED_SIGNAL.pointer),
767 c.i32_const(0),
768 c.i32_const(0),
769 c.i32_const(0),
770 c.i32_const(0)
771 )
772 )
773 );
774 }
775
776 f.addCode(
777 c.i32_add(
778 c.i32_const(builder.pSignals),
779
780 c.i32_mul(
781 c.getLocal("signal"),
782 c.i32_const(builder.sizeFr)
783 )
784 )
785 );
786 }
787
788 function buildGetWitnessBuffer() {
789 const f = module.addFunction("getWitnessBuffer");
790 f.setReturnType("i32");
791 f.addLocal("i", "i32");
792 f.addLocal("pSrc", "i32");
793 f.addLocal("pDst", "i32");
794
795 const c = f.getCodeBuilder();
796
797 f.addCode(
798 c.setLocal("i", c.i32_const(0)),
799 c.block(c.loop(
800 // if (i==NComponents) break
801 c.br_if(1, c.i32_eq(c.getLocal("i"), c.i32_const(builder.header.NVars))),
802
803 c.setLocal(
804 "pSrc",
805 c.call(
806 "getPWitness",
807 c.getLocal("i"),
808 )
809 ),
810
811 c.call(
812 "Fr_toLongNormal",
813 c.getLocal("pSrc")
814 ),
815
816 c.setLocal(
817 "pDst",
818 c.i32_add(
819 c.i32_const(builder.pOutput),
820 c.i32_mul(
821 c.getLocal("i"),
822 c.i32_const(builder.sizeFr-8)
823 )
824 )
825 ),
826
827 c.call(
828 "Fr_F1m_copy",
829 c.i32_add(c.getLocal("pSrc"), c.i32_const(8)),
830 c.getLocal("pDst")
831 ),
832
833 // i=i+1
834 c.setLocal(
835 "i",
836 c.i32_add(
837 c.getLocal("i"),
838 c.i32_const(1)
839 )
840 ),
841 c.br(0)
842 )),
843
844 c.i32_const(builder.pOutput)
845 );
846
847 }
848
849
850 const fError = module.addIimportFunction("error", "runtime");
851 fError.addParam("code", "i32");
852 fError.addParam("pStr", "i32");
853 fError.addParam("param1", "i32");
854 fError.addParam("param2", "i32");
855 fError.addParam("param3", "i32");
856 fError.addParam("param4", "i32");
857
858 const fLogSetSignal = module.addIimportFunction("logSetSignal", "runtime");
859 fLogSetSignal.addParam("signal", "i32");
860 fLogSetSignal.addParam("val", "i32");
861
862 const fLogGetSignal = module.addIimportFunction("logGetSignal", "runtime");
863 fLogGetSignal.addParam("signal", "i32");
864 fLogGetSignal.addParam("val", "i32");
865
866 const fLogFinishComponent = module.addIimportFunction("logFinishComponent", "runtime");
867 fLogFinishComponent.addParam("cIdx", "i32");
868
869 const fLogStartComponent = module.addIimportFunction("logStartComponent", "runtime");
870 fLogStartComponent.addParam("cIdx", "i32");
871
872 const fLog = module.addIimportFunction("log", "runtime");
873 fLog.addParam("code", "i32");
874
875 buildWasmFf(module, "Fr", builder.header.P);
876
877 builder.pSignals=module.alloc(builder.header.NSignals*builder.sizeFr);
878 builder.pOutput=module.alloc(builder.header.NVars*(builder.sizeFr-8));
879 builder.pInputSignalsToTrigger=module.alloc(builder.header.NComponents*4);
880 builder.pSignalsAssigned=module.alloc(builder.header.NSignals*4);
881
882 buildHash2ComponentEntry();
883
884 buildTriggerComponent();
885 buildInit();
886
887 buildGetFromComponentEntry("getSubComponentOffset", 0 /* offset */, builder.TYPE_COMPONENT);
888 buildGetFromComponentEntry("getSubComponentSizes", 4 /* offset */, builder.TYPE_COMPONENT);
889
890 buildGetFromComponentEntry("getSignalOffset", 0 /* offset */, builder.TYPE_SIGNAL);
891 buildGetFromComponentEntry("getSignalSizes", 4 /* offset */, builder.TYPE_SIGNAL);
892
893 buildGetSignal();
894 buildSetSignal();
895 buildMultiGetSignal();
896
897 buildComponentStarted();
898 buildComponentFinished();
899
900 buildCheckConstraint();
901 buildCheckAssert();
902
903 buildGetNVars();
904 buildGetNPublic();
905 buildGetFrLen();
906 buildGetPWitness();
907 buildGetPRawPrime();
908 buildGetWitnessBuffer();
909
910// buildFrToInt();
911
912 module.exportFunction("init");
913 module.exportFunction("getNVars");
914 module.exportFunction("getNPublic");
915 module.exportFunction("getFrLen");
916 module.exportFunction("getSignalOffset32");
917 module.exportFunction("setSignal");
918 module.exportFunction("multiGetSignal");
919 module.exportFunction("getPWitness");
920 module.exportFunction("Fr_toInt");
921 module.exportFunction("getPRawPrime");
922 module.exportFunction("getWitnessBuffer");
923
924};