How to pass function argument by reference in the circom circuit language ?
I'm trying to do the following:
pragma circom 2.0.0;
function increment(foo) {
foo++;
}
template MyTemplate() {
signal input a;
signal output b;
var foo;
foo = 0;
increment(foo);
log(foo);
// ...
}
component main = MyTemplate();
I expect log(pos)
to output 1, but I'm getting 0. Is there a certain way I need to pass pos
into increment
so that it can modify the variable by reference?
I decided to use the C preprocessor to generate circom code, so now I have:
main.circom:
cpp -P maintpl.circom > main.circom
in my Makefile
and
#define increment(foo) foo++
in my circom code.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.