plugins/midnight-core-concepts/skills/zero-knowledge/SKILL.md
Use when asking about zero-knowledge proofs, ZK SNARKs, circuit compilation, witness data, prover/verifier roles, constraints, or how Midnight uses ZK for privacy.
npx skillsauth add aaronbassett/midnight-knowledgebase midnight-core-concepts:zero-knowledgeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
4 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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 | | Non-interactive | 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
constraint: a * b = c
public input: c = 42
witness (private): a = 6, b = 7
// This Compact code...
export circuit guess(guess: Field): Void {
const product = guess * other_factor;
assert product == ledger.target;
}
// ...compiles to constraints that prove:
// 1. guess * other_factor equals target
// 2. Without revealing guess or other_factor values
| Scenario | What's Proven | What's Hidden | |----------|---------------|---------------| | Age verification | Age ≥ 18 | Exact birthdate | | Balance check | Balance ≥ amount | Actual balance | | Membership | In authorized set | Which member | | Vote validity | Eligible voter, hasn't voted | Voter identity |
// Prove knowledge of factors without revealing them
export circuit proveFactors(
secret_a: Field, // Private witness
secret_b: Field // Private witness
): Void {
// Constraint: factors multiply to public target
assert secret_a * secret_b == ledger.public_target;
}
Private inputs the prover knows. Never revealed, used only to generate proof.
Values visible to everyone. Proof verified against these.
Checking a proof is fast (milliseconds) regardless of original computation complexity.
Computationally infeasible to create valid proof without knowing witness.
| Operation | Cost | |-----------|------| | Circuit compilation | One-time, expensive | | Proof generation | Seconds to minutes (depends on circuit size) | | Proof verification | Milliseconds | | Proof size | ~200-300 bytes (constant) |
For detailed technical information:
references/snark-internals.md - Elliptic curves, pairings, trusted setupreferences/circuit-construction.md - How Compact compiles to circuitsWorking patterns:
examples/circuit-patterns.compact - Common proof patternstools
Use when setting up Midnight development environment, installing Compact compiler and developer tools, configuring proof server, verifying prerequisites, or getting started with Midnight development.
tools
--- name: midnight-tooling:midnight-debugging description: Use when encountering Midnight errors like "compact: command not found", "ERR_UNSUPPORTED_DIR_IMPORT", version mismatches, proof server failures, "@midnight-ntwrk" package errors, or compilation failures. --- # Midnight Environment Debugging Expert knowledge for identifying and resolving common Midnight development toolchain issues. ## Diagnostic Approach When encountering Midnight-related errors, follow this systematic approach: 1.
tools
Use when checking Midnight version compatibility, understanding pragma language_version, verifying compiler and runtime version relationships, or troubleshooting version mismatch errors between Midnight components.
tools
Use when setting up CI/CD for Midnight projects, configuring GitHub Actions for Compact contract compilation, running TypeScript tests in CI, validating version consistency, or automating contract builds.