[英]How to run a loop with unknown number of iterations in Circom?
我在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
是一個信號?
您需要決定您的循環可以有多少次最大迭代(迭代預算),然后使用LessThan
組件丟棄您不需要的所有迭代。 您還可以使用QuinSelector
迭代所需的結果
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.