flâneur — a map of the web's best reading

Scoping - Circom 2 Documentation

docs.circom.io · 408 words · saved by 1 readers

Circom has static scoping like C and Rust. However, we have that signals and components must have global scoping and hence they should be defined at the top-level block of the template that defines them. Signal out2 must be declared at the top-level block. The next compilation error is produced: "out2 is outside the initial scope". Since circom 2.1.5, signals and components can be now declared inside if blocks, but only if the condition is known at compilation time. In the previous example, the condition i < n is known at compilation time, and then the declaration of signal out is allowed. However, if the condition where in < n, it is not known at compilation time and we output an error, because the declaration in this case is not allowed. Regarding visibility, a signal x of component c is also visible in the template t that has declared c, using the notation c.x. No access to signals of nested sub-components is allowed. For instance, if c is built using another component d, the signal

Scoping Circom has static scoping like C and Rust. However, we have that signals, buses and components must have global scoping and hence they should be defined at the top-level block of the template that defines them or, since circom 2.1.5, inside (nested) if blocks, but only if conditions are known at compilation time. pragma circom 2.1.5; template Cubes (N) { //Declaration of signals. signal input in[N]; signal output out[N]; //Statements. for (var i = 0; i < N; i++) { signal aux; aux <== in[i]*in[i]; out[i] <== aux*in[i]; } } component main = Cubes(5); Signal aux cannot be declared in the

Explore this link on the map →

related reading