Questions tagged [circom]

Circom is a declarative language for composing and describing complex arithmetic circuits, often used in the field of Zero-Knowledge Proofs (ZKPs). It provides a way to define circuits in a high-level language, which can then be compiled into arithmetic circuit representation, such as a constraint system, for efficient verification.

Use this tag for questions related to using Circom in circuit design, optimization, debugging, and general programming practices. Include specific problem descriptions and, if applicable, any error messages or code snippets to help other community members provide accurate and targeted answers.

24 questions
1
vote
1 answer

How to run a loop with unknown number of iterations in Circom?

I have the following circuit in Circom cicuit compiler: pragma circom 2.0.0; template MAIN() { signal len; len <== 32; for (k = 0; k < maplen; k++) { // do something } } component main = MAIN(); I'm getting an…
Ilia Sidorenko
  • 2,157
  • 3
  • 26
  • 30
1
vote
1 answer

How to use & (AND) operator in a signal in Circom

I'm trying to use & operator on a signal and get another signal in Circom circuit compiler language like so: pragma circom 2.0.0; template MAIN() { signal input a; signal output x; signal v; v <== 168; x <== v &…
Ilia Sidorenko
  • 2,157
  • 3
  • 26
  • 30
1
vote
1 answer

How to pass function argument by reference in Circom?

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; …
Ilia Sidorenko
  • 2,157
  • 3
  • 26
  • 30
0
votes
0 answers

Why does snarkjs running on Node.js throw an instance of std::bal_alloc?

I'm running snarkjs over Node.js on a linux x64 machine with 256GB RAM and I have a zk-SNARK circuit composed by ~28M constraints. I want to execute the command snarkjs zkey new to generate a zkey file from a circuit compiled with circom, but when…
0
votes
0 answers

Writing a Singaporean NRIC Validator in Circom

I am intending to write a Circom circuit to validate a Singaporean NRIC, details on the validation checksum algorithm is found here. In brief, it is a string that contains prefix which is an enum of variants, S, T, G, F and M, suffix, again an enum…
Jim
  • 450
  • 2
  • 10
0
votes
0 answers

Newbie question trying to verify merle tree for a depth of 0 and 1

Following code seems to work for depth = 0 but fails for both depth = 0 and depth = 1. template Spend(depth) { signal input digest; signal input nullifier; signal private input nonce; signal private input sibling[depth]; signal…
Vic K
  • 1
0
votes
1 answer

Conflicting versions of sha256 bit calculation

I'm computing sha256 from two different sources, both ran on bit arrays. In Python, I run from bitarray import bitarray from hashlib import sha256 inbits = bitarray([1,0,1,0,1,0,1,0,1,0]) sha = sha256(inbits) outbits =…
kuco 23
  • 786
  • 5
  • 18
-1
votes
1 answer

How to solve a question about comparing two inputs using `IsEqual` function?

I am working on passing a test for a hackerhouse where I need to compare two inputs using an IsEqual function. Please provide code and explanation of it. Thank you!
Pavel Fedotov
  • 748
  • 1
  • 7
  • 29
-2
votes
2 answers

How to send strings as signals to circom?

I want to create a circuit to measure the length of a string in Circom. There are only numeric data types, how can I do that?
AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210
1
2