Week 7
Privacy And Zero-Knowledge
- Decentralized systems from zero, week 7
- Prove a fact without showing the data behind it.
Last week
Recap Of Week 6: Identity
- Identity means showing who you are without a central registry.
- Keys and signatures prove control of an account.
- Credentials are claims issued by one party and checked by another.
- Showing a full credential reveals more than the verifier needs.
Outcomes
What You Will Be Able To Do
- Explain what a zero-knowledge proof proves.
- Retell the cave analogy with the right roles.
- Build a hash commitment in Python.
- Name SNARKs and STARKs and one trade-off.
- Describe MACI-style private voting.
Vocabulary
Three Kinds Of Privacy
- Confidentiality hides the content of data.
- Anonymity hides who performed an action.
- Unlinkability hides that two actions share an author.
- Public ledgers expose all three by default.
Motivation
The Proof Problem
- A verifier needs to trust a claim.
- The prover owns data that supports the claim.
- Sharing the data creates a leak.
- A proof can carry the claim without the data.
Core idea
Roles In A Proof
- Prover holds the secret witness.
- Verifier holds the public statement.
- Prover sends a proof message.
- Verifier answers accept or reject.
statement: hash(w) == H (public)
witness: w (secret)
proof: pi = Prove(w, H)
check: Verify(H, pi) -> accept / reject
Core idea
Three Properties
- Completeness: true statements are accepted.
- Soundness: false statements are rejected, almost always.
- Zero-knowledge: nothing beyond truth is revealed.
- All three must hold together.
Story
The Cave Analogy
- A ring cave with a magic door at the back.
- Peggy enters and picks a path out of Victor's sight.
- Victor names the side she must exit from.
- Knowing the word lets her always comply.
entrance
/ \
left right
\ door /
(secret word)Story
Why Repetition Convinces
- A cheater guesses the side half the time.
- Twenty rounds leave about one in a million.
- Victor never hears the secret word.
- He cannot replay the transcript to convince others.
Building block
Commitments
- A commitment is a sealed envelope.
- Hiding: the envelope reveals nothing.
- Binding: the value cannot change after sealing.
- A salt keeps small value sets from being guessed.
import hashlib, secrets
salt = secrets.token_hex(16)
c = hashlib.sha256((salt + 'yes').encode()).hexdigest()
print(c)
Non-interactive
From Conversation To One Proof
- The cave needs many rounds of talk.
- Modern systems publish a single proof.
- Anyone can verify it at any time.
- Challenges come from a hash of the commitment.
Names to know
SNARKs
- Succinct Non-interactive ARgument of Knowledge.
- Proofs are tiny and fast to check.
- Many need a trusted setup ceremony.
- One honest ceremony participant is enough.
Names to know
STARKs
- Scalable Transparent ARgument of Knowledge.
- Transparent: no trusted setup needed.
- Built on hash functions.
- Proofs are larger than SNARK proofs.
| SNARK | STARK |
|---|
| Proof size | Small | Larger |
| Trusted setup | Often | No |
| Built on | Curves | Hashes |
How developers work
From Statement To Circuit
- Write the claim as arithmetic constraints.
- Tools such as Circom and Noir help.
- A proving library turns a witness into a proof.
- A small verifier contract checks it on chain.
Application
MACI: Private Voting
- Voters publish encrypted messages on chain.
- A coordinator decrypts and counts off chain.
- A zero-knowledge proof shows the count is correct.
- Voters may re-vote to override earlier messages.
voter -> encrypted vote -> chain
chain -> messages -> coordinator
coordinator -> tally + proof -> contract
contract verifies proof -> result
Summary
Recap
- A ZK proof shows truth and hides the secret.
- Commitments seal values and bind the sender.
- SNARKs are small with setup, STARKs are transparent.
- MACI makes bribery checks impossible.
Coming up
Next Week: DAOs And On-Chain Governance
- What a DAO is and how it votes.
- Delegation and treasuries.
- How governance fails in practice.
Wrap up
Questions And Exercise
- Exercise: build and test a hash commitment.
- Bring one idea for a narrow fact worth proving.
- Read the Quisquater cave paper or Green's primer.