A tutorial where you prove things without revealing things, and yes, the math actually maths.
Here's something the internet doesn't want you to know: you overshare every single time you prove something.
Prove you're over 21 at a bar? You hand over a card with your name, your address, your height, and your terrible 2019 haircut. Prove your income to a landlord? Here's every transaction I've made since college, please don't judge the 3am food delivery.
We built the entire digital world on a verification model that boils down to "here's everything, trust me bro."
Not anymore. There's a branch of cryptography that lets you prove a statement is true while revealing nothing else. It sounds fake. It's called a zero knowledge proof, and by the end of this article you'll understand one well enough to check it with Python. Then we'll look at Midnight, a blockchain that turned this party trick into a developer platform.
Let's go. ๐
๐ชช The Trust Me Bro Problem
Every verification system you use today works by disclosure. You prove things by showing the underlying data:
- Prove your age โก๏ธ show your whole ID
- Prove you can pay โก๏ธ show your bank statements
- Prove you're a real user โก๏ธ solve a CAPTCHA and sacrifice your data to the algorithm gods
The data doesn't just get seen. It gets stored, and eventually it gets breached, and then a guy named xX_darkweb_Xx is selling your identity for the price of a burrito.
The verifier never needed the data. They needed one bit of information: true or false. Everything else was collateral damage.
In short: we've been answering yes or no questions with our entire life story.
๐ต๏ธ The Party Trick That Started It All
Zero knowledge proofs let a prover convince a verifier that a statement is true without revealing why it's true.
The classic example is Where's Waldo. Say I claim I found Waldo on the page and you don't believe me (fair, you've seen my code reviews). I could point at him, but then I've revealed the answer and ruined the puzzle.
Instead, I take a giant piece of cardboard, way bigger than the book, cut a tiny Waldo shaped hole in it, and slide the page underneath so only Waldo shows through the hole.
You see Waldo. โ You learn I found him. โ You learn absolutely nothing about where he is on the page, because the cardboard hides all of it. โ
That's a zero knowledge proof. Every real ZK system, no matter how much math it's wearing, is doing the cardboard trick.
The formal version has three properties, and knowing these three words will let you nod convincingly in any crypto conversation:
- Completeness: if the statement is true, an honest prover convinces the verifier. The demo works.
- Soundness: if the statement is false, no amount of galaxy brain trickery convinces the verifier. You can't fake it.
- Zero knowledge: the verifier learns the statement is true and nothing else. The cardboard stays intact.
Good job, concept unlocked! ๐ช Now let's earn the "I understand the math" badge.
๐งฎ The Math (This Is Where You Start Feeling Smart)
Don't close the tab. The math is genuinely simple, it's just wearing a trench coat.
Everything runs on clock math, which mathematicians call modular arithmetic to keep it gatekept. On a 12 hour clock, 9 + 4 = 1. You wrap around. We write that as 9 + 4 โก 1 (mod 12). That's it. That's the whole trench coat.
Here's the fun part. Pick a prime p and a number g. Computing y = g^x mod p is easy, your laptop does it instantly. But going backwards, finding x when you only know y, is called the discrete logarithm problem, and for big numbers it's computationally hopeless. Multiplying is easy, unmultiplying is a research career.
So: x can be a secret, and y can be public. Think of x as a private key and y as a public key. Now I'll prove I know x without ever showing it, using a protocol cryptographers named after Claus Schnorr (cryptographers name everything after themselves, it's their love language).
The protocol is a three message dance between Peggy (Prover) and Victor (Verifier):
- Commit. Peggy picks a random number k and sends r = g^k mod p. This locks her in, like pushing a commit before the standup so everyone knows you did something.
- Challenge. Victor sends back a random number c. This is the crucial part: Peggy couldn't predict it.
- Respond. Peggy sends s = k + c ยท x. Her secret x is in there, but it's blended with the random k, like a password inside a hash. Unrecoverable.
Victor then checks one equation:
g^s โก r ยท y^c (mod p)
If Peggy really knows x, the algebra works out perfectly every time (completeness). If she's bluffing, she'd need to answer a random challenge she couldn't predict, and she gets caught (soundness). And Victor only ever sees r, c, and s, which are statistically just noise (zero knowledge).
Let's run it with real numbers, because "trust me bro" would be ironic here.
- Setup: p = 23, g = 5. Peggy's secret: x = 6. Public value: y = 5โถ mod 23 = 8.
- Commit: Peggy picks k = 3, sends r = 5ยณ mod 23 = 10.
- Challenge: Victor sends c = 4.
- Respond: s = 3 + 4 ยท 6 = 27.
- Victor checks: is 5ยฒโท mod 23 equal to 10 ยท 8โด mod 23?
Open a Python shell and verify it yourself:
>>> pow(5, 27, 23)
20
>>> (10 * pow(8, 4, 23)) % 23
20
20 == 20. The math is mathing. Victor is convinced Peggy knows x, and if you scroll back, x = 6 never appeared in anything Victor saw. ๐คฏ
If you've made it this far you are a superstar โญ๏ธ and you now understand more actual cryptography than 99% of the people posting candle charts. Few understand this. You do.
๐ From Party Trick to zkSNARK
Our dance has two problems for the real world. Victor had to be online to throw challenges, and we only proved one tiny algebra fact.
Modern systems fix both:
- Kill the back and forth. Instead of Victor picking the challenge, Peggy generates it by hashing her own commitment (the Fiat Shamir transform). The hash function becomes an incorruptible robot Victor. Now the proof is a single message anyone can verify, anytime.
- Prove anything. Any computation can be compiled into a giant system of equations like our little one. Your program becomes a circuit, and you prove "I ran this code correctly on secret inputs" the same way Peggy proved she knew x.
Bundle that up and you get a zkSNARK: a proof that's succinct (a few hundred bytes even if the computation was enormous) and verifiable in milliseconds.
"It works on my machine" finally has a fix. With a zkSNARK it provably works on every machine, and you don't even have to show anyone the machine. ๐ณ
In short: you can now hand someone a receipt that proves a computation happened correctly, without showing the inputs. Which raises a question with billion dollar implications: what happens when you put that on a blockchain?
๐ Enter Midnight
Public blockchains have a privacy model best described as the "this is fine" dog sitting calmly in a burning room, laptop open to every transaction you've ever made, public, forever.
Radical transparency is great for verifying money and terrible for literally everything else. No company is putting payroll on a public ledger. No hospital is putting your records there. Transparency was blockchain's superpower and its adoption ceiling at the same time.
Midnight is a blockchain built to fix exactly this. It's a partner chain in the Cardano ecosystem designed around data protection: smart contracts where zero knowledge proofs are not an exotic bolt on, they're the default way state gets updated. Your data stays on your device. The chain sees proofs.
The part I love as a developer: you don't write moon math. You write Compact, a TypeScript flavored language, and the toolchain compiles your logic into ZK circuits. Here's the vibe (simplified for the article, real syntax lives in their docs):
// the witness lives on YOUR device, never on chain
witness birthYear(): Uint<16>;
export circuit proveAdult(currentYear: Uint<16>): [] {
assert(currentYear - birthYear() >= 18, "must be an adult");
}
The chain learns "this person is an adult: true." Your birth year stays home. Peggy would be proud.
What does that unlock? The use cases write themselves:
- โ Age and identity checks that don't photocopy your life. Prove "over 18" or "licensed doctor" as one bit, not one dossier.
- โ Financial privacy with receipts. Prove solvency to a lender or an exchange without opening your books to the whole internet.
- โ Healthcare eligibility. Prove "vaccinated" or "matches this trial" while the medical record never leaves the building.
- โ Compliance without surveillance. Selective disclosure means a regulator with the right keys can audit you, while everyone else sees nothing. Regulated and private, which used to be a contradiction.
- โ Private voting and DAOs. Prove your vote counted without revealing it. Governance without vote buying.
- โ Enterprise logic on chain. Supply chains and business rules where the correctness is public but the trade secrets aren't.
Notice the pattern. Every one of these is a yes or no question we currently answer with a full data dump. ZK flips the default: share the conclusion, keep the evidence.
๐ Try It Yourself
The best part is you can actually build with this today:
- Docs: docs.midnight.network has the full developer guide and the Compact language reference.
- Write a circuit: the tutorial walks you through your first contract, and it genuinely feels like TypeScript, not like a math PhD hazing ritual.
- Go deeper: the node itself is open source at github.com/midnightntwrk/midnight-node. I've been contributing there lately and the codebase is a great read if you want to see how a privacy chain actually ships.
That's it! We're done yay ๐
๐งพ The Recap
- Current verification = trust me bro + oversharing.
- Zero knowledge proofs = the Waldo cardboard: prove the claim, hide everything else.
- You personally verified a Schnorr proof with two lines of Python. Flex accordingly.
- zkSNARKs make it succinct and universal.
- Midnight makes it programmable in a TypeScript flavored language, with use cases that read like a list of everything Web2 got wrong about data.
The cryptographers spent forty years building the cardboard. The chains are finally cheap and the tooling finally speaks TypeScript. The only missing ingredient is developers who see the use case sitting in their own industry.
So: what can you prove?
If you build something with this, I genuinely want to hear about it. Drop a comment or find me on GitHub as wbaxterh.
Peace out,
Wes
Top comments (0)