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
3
votes
3 answers

What exactly Circom circuit constraint a*b proves?

I use this circuit as per official documentation: pragma circom 2.0.0; /*This circuit template checks that c is the multiplication of a and b.*/ template Multiplier2 () { // Declaration of signals. signal input a; signal input b;…
egor10_4
  • 331
  • 2
  • 9
3
votes
1 answer

Pedersen circom/circomlibjs inconsistency?

As a unit test for a larger use case, I am checking that indeed the pedersen hash I am doing in the frontend aligns with the expected hash done through a circom circuit. I am using a simple assert in the circuit and generating a witness and am…
TIZ
  • 131
  • 8
2
votes
0 answers

How to write the constraints for a zk-SNARK circuit

Need help with defining constraints for a zk-SNARK circuit Hi everyone, I am developing a zk rollup SDK and I need help with defining the constraints for the circuit. I do not have access to a cryptography expert at the moment and I am looking for…
2
votes
2 answers

Number of wires in a ZKP Circom circuit is greater than expected

I compile this simple circuit: pragma circom 2.0.0; template Multiplier2() { signal input a; signal input b; signal output c; c <== a*b; } component main = Multiplier2(); and the compiler says 4 wires: circom 1.circom --r1cs…
egor10_4
  • 331
  • 2
  • 9
2
votes
1 answer

Snarkjs- Proof still validates for incorrect witness

Very new to ZKsnarks. I'm trying to build a simple application to check whether the input number matches a certain predefined number or not. I have followed all the steps mentioned in the SnarkJs doc. Here is the circuit for my use case: pragma…
Razor Sharp
  • 41
  • 1
  • 4
2
votes
1 answer

Circomlib assert fail on simple MimcSponge hash

I am playing around with circom and circomlib. I am using a simple mimcsponge hashing circuit and seeing if I can create a correct input through javascript frontend. The circuit I am running template sponge_test() { signal input l; …
TIZ
  • 131
  • 8
2
votes
1 answer

Error: zkey file is not groth16 in circom

■ Issue Info Cohort3-Week1-Part2-4-1 1.You will encounter an error if you just change snarkjs groth16 setup to snarkjs plonk setup. Resolve this error and answer the following question - How is the process of compiling with PLONK different from…
Tomosuke
  • 19
  • 1
2
votes
0 answers

Input string of variable length in circom?

I would like to show that a user knows a preimage to a sha256 hash in circom. The preimage can be of any length, but realistically between 100-700 bytes. I tried code: template ArbitraryLengthSha256 () { signal input nBits; signal input…
nnsk
  • 93
  • 5
2
votes
2 answers

How to write a constraint that depends on a condition in Circom?

I have code of the following form in Circom circuit compiler template DecodeUint(len) { signal input x; signal input pos; signal output value; signal output nextpos; component getV = GetV(len); if (x <= 23) { value…
Ilia Sidorenko
  • 2,157
  • 3
  • 26
  • 30
2
votes
1 answer

How to access array element with an "Unknown" index in Circom?

I have the following Circom (circuit compiler language) program: pragma circom 2.0.0; template MAIN() { signal input array[2512]; signal output d; signal v; v <== 168; d <== array[v]; } component main = MAIN(); I want to…
Ilia Sidorenko
  • 2,157
  • 3
  • 26
  • 30
1
vote
1 answer

Hashing function Sha256 in Circom

During the hackathon ETH Global Paris Was attempting to integrate a circom circuit with hashing a birthday date to prove that the user know the date following a well known medium tutorial. Here is its code pragma circom 2.0.0; include…
Pavel Fedotov
  • 748
  • 1
  • 7
  • 29
1
vote
2 answers

In Circom, what's the difference between variable and signal, and between function and template?

This might be a newbie question: From the doc, it says that signals are part of the circuit while variables are similar to variables in other programming language. But for verifiable computation, I'd assume that the computations done on variables…
Justin Zhang
  • 4,433
  • 1
  • 12
  • 9
1
vote
1 answer

Node.js circom command not found

Using windows 11 and VS Code. I installed circom and snarkjs: npm install -g circom and npm install -g snarkjs which seemed to install fine. I also installed the extention: circom-highlighting-vscode v0.0.2 Now when I run the command: circom…
spacedog
  • 446
  • 3
  • 13
1
vote
1 answer

confused about Circom LessThan implementation

I am trying to implement a LessThan template which outputs 1 if y is less than x and 0 is x is more than y. Below is the sample code from the circom library and I am trying to understand whats going on this code below. template LessThan(n) { …
djack
  • 73
  • 7
1
vote
1 answer

Out signal based on two other our signals

I am trying to write a circuit to prove that a number is within a specified range. I am using the circomlib library : https://github.com/iden3/circomlib/tree/master/circuits comparators.circuit file. My code till now is this : template…
sonika
  • 239
  • 1
  • 2
  • 9
1
2