Use when asking about zero-knowledge proofs, ZK SNARKs, circuit compilation, witness data, prover/verifier roles, constraints, or how Midnight uses ZK for privacy.
Zero-knowledge proofs let you prove knowledge of a secret without revealing it. In Midnight, ZK proofs validate that transactions follow contract rules without exposing private data.
A ZK proof proves: "I know values that satisfy these constraints" without revealing the values.
Midnight application: Prove a transaction is valid (correct inputs, authorized user, rules followed) without exposing private state or user secrets.
Midnight uses ZK SNARKs (Zero-Knowledge Succinct Non-interactive Arguments of Knowledge):
| Property | Meaning |
|---|---|
| Zero-Knowledge | Verifier learns nothing beyond validity |
| Succinct | Proof size small regardless of computation complexity |
| No back-and-forth between prover and verifier |
| Argument of Knowledge | Prover must actually know the secret |
Every Midnight transaction contains:
The proof demonstrates: "I know private inputs that, when combined with public data, satisfy the contract's constraints."
Contract logic compiles to circuits - mathematical constraint systems.
Compact Code → Circuit Constraints → ZK Proof
A circuit defines relationships between variables. The proof shows you know variable assignments satisfying all constraints without revealing the assignments.
1. Setup → Generate proving/verification keys (per circuit)
2. Witness → Prover assembles private inputs
3. Prove → Generate proof from witness + circuit
4. Verify → Check proof against public inputs (fast)
When a Compact contract executes:
Circuits express computations as polynomial constraints:
// Conceptual: proving x * y = z without revealing x, y