What are zk-SNARK Circuits ?
In this section, we will explore what zk-SNARK circuits are, their role in zero-knowledge proofs, and how they are used to define computations that can be proven without revealing sensitive data.
zk-SNARK circuits are mathematical models used to prove computations without revealing data. In Poseidon, these circuits are written in Circom and saved as .circom
files.
Key Components of zk-SNARK Circuits:
Inputs:
Public: Visible to both the prover and verifier (e.g., a public key).
Private: Known only to the prover (e.g., a secret password).
Example: Proving that you know a secret number without revealing it.
Constraints:
Logical conditions that ensure the computation is correct.
These are the rules that must be satisfied for the proof to be valid.
Example: Verifying that a sum of two numbers equals a known result without revealing the numbers.
Outputs:
The result of the computation that needs to be proven.
This shows that the prover knows the valid solution, without disclosing how it was derived.
Example: Proving that you know a solution to a cryptographic puzzle.
Process:

Write Circuit: Define inputs, constraints, and outputs using the Circom language in a
.circom
file. This represents the logic you want to prove.Compile Circuit: Convert the written circuit into an R1CS (Rank-1 Constraint System), along with a
.wasm
file and witness generator for proof generation.Trusted Setup (Powers of Tau): Perform a one-time cryptographic setup to generate secure parameters (e.g.,
.tau
files). This phase ensures the integrity and trustworthiness of the zk-SNARK system.Key Generation: Use the R1CS and setup data to generate:
A proving key (e.g.,
circuit_final.zkey
) used to create zk-proofs.A verification key used to verify proofs.
Generate Proof: Provide valid inputs and use the proving key and compiled circuit to generate a zk-proof (
.proof
and.wtns
files).Verify Proof: Use the verification key to confirm the validity of the proof without learning the private inputs.
Example Workflow:
Circuit Definition: Prove you know two numbers
x
andy
such thatx + y = 10
.Inputs:
x
,y
(private)Constraint:
x + y = 10
(logic)Output: Prove the sum without revealing
x
ory
.
Once compiled, the circuit generates an R1CS, which is used to create a zk-proof that can be verified by anyone without knowing the values of x
and y
.
Last updated