DEV Community

Arush
Arush

Posted on

What is zero-knowledge actually used for?

TL;DR

  • ZK proofs are used for two very different jobs: privacy (hide the data) and scaling (avoid redoing the work). You'll see five real use cases and learn to spot which job each one is doing.

In Post 1 we built the intuition: a prover convinces a verifier that a statement is true, without revealing the secret witness. Cool party trick. But ...okay, who needs that?

It turns out quite a lot of people do. Let's walk through five real places where ZK proofs are doing work right now, and pull out the pattern behind them.

Intuition: two superpowers

A ZK proof (more precisely, a modern zk-SNARK) gives you two separate superpowers:

  1. Hiding. The verifier doesn't learn the witness. This is the "zero-knowledge" part.
  2. Compression. The proof is tiny and quick to check, even if the computation behind it was huge. This is the "succinct" part, the S in SNARK.

A lot of confusion clears up once you notice that some "ZK" systems mostly use superpower #2 and barely care about #1.

1. Private payments

Problem: On a normal blockchain, every payment is public: sender, receiver, amount, forever. That's like publishing your bank statement on a billboard.

ZK fix: Zcash (launched 2016) was the first big deployment of zk-SNARKs. A shielded transaction proves "I own some coins that exist, I haven't spent them before, and the amounts balance" without revealing which coins, who you are, or how much.

Superpower: hiding.

We'll actually build a mock version of this in 12th Post (foreshadowing), using ideas called notes, commitments and nullifiers.

2. Rollups

Problem: Ethereum can only process a limited number of transactions per second, because every node re-executes every transaction.

ZK fix: A ZK rollup executes thousands of transactions off-chain, then posts a single proof to Ethereum saying "I ran all these transactions correctly, and here's the new state." The chain checks one small proof instead of redoing thousands of transactions. zkSync, Starknet, Scroll and Linea all work this way.

Superpower: compression.

Fun fact: most rollup data is public, so these "ZK" rollups often aren't hiding anything at all. The name stuck anyway.

3. Identity

Problem: To prove you're over 18, you usually show an ID that also reveals your name, address, exact birthday and a very terrible photo (personal experience).

ZK fix: Prove "I hold a valid government-signed credential, and the birthday on it is more than 18 years ago" while revealing nothing else. Projects like zkPassport do this with the chip in real passports, and Semaphore lets you prove "I'm a member of this group" without saying which member.

Superpower: hiding.

4. Voting

Problem: We want two things that seem to conflict. Votes should be anonymous, but each person should vote only once.

ZK fix: You prove "I'm on the voter list" (without saying who you are) and publish a nullifier, a value derived from your secret and the poll ID. If the same nullifier shows up twice, the second vote is rejected. Nobody can link the nullifier back to you.

Superpower: hiding, plus a clever trick for uniqueness. This exact pattern will be in 9th Post, and it's actually one of my favorite ideas in the whole series.

I've already built a ZK backed voting system when I was learning myself. It sure has flaws but the ZK part is good.

5. Proof of solvency

Problem: When an exchange collapses, people discover too late that their deposits weren't backed. Exchanges now publish "proof of reserves", but proving you own $X is only half the story. You also need to prove you owe at most $X.

ZK fix: The exchange builds a Merkle sum tree of every user's balance and proves "the total of all balances is Y, and every balance is non-negative". Each user can check their own balance is included, and nobody learns anyone else's balance.

Superpower: hiding (balances stay private), plus compression.

That "every balance is non-negative" part sounds boring. It isn't. Leaving it out is a real, classic bug, and it's the subject of Post 10.

I've also built a Proof of Solvency earlier myself, and this one is actually one of my strongest project.

The pattern

When I look at a new ZK project now, I ask one question:

Who is the verifier, and what are they not allowed to see (or not willing to redo)?

  • Private payments: the blockchain can't see who paid whom.
  • Rollups: Ethereum doesn't want to re-execute everything.
  • Identity: the website can't see your full ID.
  • Voting: the tallier can't see who voted for what.
  • Solvency: users can't see each other's balances.

Hands-on: spot the superpower

No circuits yet (still on fundamentals). Instead, here's a tiny quiz you can run to check your intuition. Every claim below is real. Decide whether it's mainly hiding, compression, or both:

claims = {
    "I paid you, but nobody else can see the amount":      "hiding",
    "These 5,000 transactions were executed correctly":     "compression",
    "I'm over 18 (and that's all you'll learn)":            "hiding",
    "I'm one of the 300 people allowed to vote":            "hiding",
    "Our users' balances add up to $Y, none are negative":  "both",
}

score = 0
for claim, answer in claims.items():
    guess = input(f'"{claim}"\n  hiding / compression / both? ').strip().lower()
    if guess == answer:
        score += 1
        print("  ✅ yep")
    else:
        print(f"  ❌ it's mostly {answer}")
print(f"\nYou got {score}/{len(claims)}")
Enter fullscreen mode Exit fullscreen mode

Gotcha: "ZK" in the name doesn't guarantee privacy

I myself assumed a "ZK rollup" meant my transactions on it were private. They weren't. On most ZK rollups, transaction data is fully public; the proof is used for correctness, not secrecy.

The lesson: "ZK" in a product name tells you a proof system is involved. It doesn't tell you what is hidden. Always check what's public and what's private before you trust something with your data.

Recap

  • ZK proofs give two superpowers: hiding the witness and compressing verification.
  • Real uses: private payments, rollups, identity, voting, proof of solvency.
  • To understand any ZK system, ask: who's the verifier, and what can't they see or redo?

Next up: almost every example above relied on two building blocks: hashes and Merkle trees. In Post 3, we'll build a tiny Merkle tree in Python and see why it shows up everywhere in ZK.

Further reading

Series codebase

All the code from posts in this series will be in this GitHub repo: Zero-Knowledge from zero knowledge

Top comments (0)