0

我在Circom cicuit 编译器中有以下电路:

pragma circom 2.0.0;

template MAIN() {

    signal len;
    len <== 32;

    for (k = 0; k < maplen; k++) { 
        // do something
    }

}

component main = MAIN();

我收到一个错误:

error[T2005]: Typing error found
    ┌─ "/Users/ilia/compiling/main-circom/circuits/main.circom":118:17
    │
118 │     for (k = 0; k < len; k++) {
    │                 ^^^^^^^ There are constraints depending on the value of the condition and it can be unknown during the constraint generation phase

如何以一种可以迭代信号的len时间的方式编写此循环len

4

1 回答 1

0

LessThan您需要决定您的循环可以有多少次最大迭代(迭代预算),然后使用组件丢弃所有不需要的迭代。您还可以使用选择所需的迭代结果QuinSelector

于 2022-02-23T23:33:14.853 回答