首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Circom中以未知的迭代次数运行循环?

如何在Circom中以未知的迭代次数运行循环?
EN

Stack Overflow用户
提问于 2022-02-05 00:24:58
回答 1查看 261关注 0票数 0

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

代码语言:javascript
复制
pragma circom 2.0.0;

template MAIN() {

    signal len;
    len <== 32;

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

}

component main = MAIN();

我收到一个错误:

代码语言:javascript
复制
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是一个信号?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-23 23:33:14

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70994314

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档