Questions tagged [zk-snark]
23 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…

Shreyan Manher
- 21
- 1
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
0 answers
Is zk-snarks implementable in this use case-scenario?
I want to do something similar to a pet popularity contest dapp. From what I understand, it would involve non-interactive zero-knowledge proof.
There is an application with a list of pets competing in a popularity contest. Each pet has a popularity…

AndrewHoover898
- 159
- 1
- 9
2
votes
2 answers
How to create a ZkSync account?
The ZkSync documentation states that a deposit has to be made from an existing Ethereum account to a non-existing ZkSync account counterfactually in order to create a new account.
However, the method that is used to make the deposit already takes a…

Kevvv
- 3,655
- 10
- 44
- 90
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
0 answers
How to implement a >=0 check in gnark for unsigned integers when a can be any integer (negative or positive) in the clear?
I have the following block of code in golang in the clear.
for i := 0; i < 10; i++ {
if val[i]>=0{
postcheck[i] = val[i]
bitpostcheck[i] = 1
} else {
postcheck[i] = 0
bitpostcheck[i] = 0
}
}
val[i] can…

stateless
- 19
- 2
1
vote
1 answer
how to use gnark v0.8.0 to do MIMC verification?
Can anyone tell me how to do MIMC verification with gnark v0.8.0 and gnark-crypto v0.9.1?
my code as fllow
package main
import (
"fmt"
"github.com/consensys/gnark-crypto/ecc"
bn254 "github.com/consensys/gnark-crypto/ecc/bn254/fr/mimc"
…

YurunChen
- 11
- 2