Book a free call

Zero-Knowledge Proof Smart Contracts: How They Work

A zero-knowledge proof smart contract checks a private fact on chain without revealing it. The proof says the fact is true, and the contract acts on it.

Hertiv engineering teamReviewed by a senior engineer
5 min read
Zero-Knowledge Proof Smart Contracts: How They Work
On this page

Short answer

A zero-knowledge proof smart contract is a smart contract that accepts a cryptographic proof that a statement is true, without the proof revealing the underlying data. The contract checks the proof on chain, and if it is valid, the contract runs its logic. Private inputs stay off chain, while the proof and the outcome are public and checkable by anyone.

What is a zero-knowledge proof smart contract?

A zero-knowledge proof smart contract is a contract that verifies a proof instead of reading the data itself. In a normal contract, the data is on chain for everyone to see. In a zero-knowledge contract, the sensitive data stays with its owner, and a proof is sent to the chain that says, in effect, 'this statement about the data is true, and here is the proof'.

The contract runs a verifier, a small piece of code that checks the proof against a public statement, such as 'this person is over 18' or 'this payment is valid and the sender has enough balance'. If the proof checks out, the contract continues. If it does not, the transaction fails. The data behind the statement is never published.

This matters because blockchains are public by default. Anything written to a chain can be read by anyone, forever. Zero-knowledge proofs let a contract use private facts without publishing them. For the wider set of uses, see zero-knowledge proof use cases.

How does the proof work?

A zero-knowledge proof works in three roles: the prover, the verifier and the statement. The prover holds the private data and builds a proof that a statement about it is true. The verifier, here the smart contract, checks the proof. The statement is public, for example 'the voter is on the roll' or 'the balance covers the payment'.

Building the proof happens off chain, where the private data lives. The prover runs a program that takes the private inputs and produces a short proof, usually a few hundred bytes. The contract then runs the verifier, which is a cheap check: it confirms the proof is valid for the public statement without learning the inputs.

Two properties make the proof useful. It is sound, meaning a false statement cannot produce a valid proof, and it is private, meaning the proof reveals nothing about the data beyond the statement itself. Those two properties are what let a public contract act on private facts.

What can a contract check without seeing the data?

A contract can check many kinds of statements without seeing the data behind them. The pattern is always the same: the private fact stays off chain, the proof goes on chain, and the contract acts on the result.

Private fact What the contract learns Example use
Age and identity Person meets the age rule Access to an age-gated service
Account balance Balance covers the payment Private payment or loan
Vote choice Vote is valid and counted Private on-chain voting
Document content Document meets the rule Compliance check
Credit score Score is above the threshold Underwriting without sharing data

The limit is that the contract only learns the statement, not the reason. If the statement is 'the score is above 700', the contract cannot also learn the score itself. Teams design the statement carefully, because anything not in the statement stays hidden.

Where are they used today?

Zero-knowledge proof smart contracts are used where privacy and public verification must coexist. Private payments are the oldest case: a payment contract checks that the sender has enough balance and the amounts add up, without publishing who paid whom or how much. Identity is another: a contract checks that a person holds a credential without seeing the credential itself.

Voting and compliance are growing uses. A voting contract can count votes and prove each one came from an eligible voter, without linking a vote to a person. A compliance contract can check that a transaction passed a sanctions screen without publishing the screened data. Rollups also use the same proofs to show that a batch of transactions was processed correctly. See what a ZK rollup is for that pattern.

The common thread is a public record that must stay private in parts. If the whole record can be public, a normal contract is simpler and cheaper. Zero-knowledge contracts earn their complexity only when privacy is a real requirement.

Example (hypothetical): a private payment between two firms

Example (hypothetical): two firms settle invoices on chain, but neither wants its payment amounts visible to competitors. Each payment is 40,000 in a stablecoin, and each firm holds a balance of 200,000. A normal contract would publish both numbers.

With a zero-knowledge contract, the payer builds a proof that says 'my balance covers this payment and the amounts add up', without revealing the balance or the amount. The contract checks the proof, updates the private balances, and records only that a valid payment happened. The public record shows a payment occurred, not who paid what.

The cost is the proof itself: building it takes seconds and a small amount of computing, and the contract must pay for the verification. For a firm settling 10 payments a day, that cost is small next to the value of keeping amounts private. For a firm settling thousands a second, the proof cost becomes the main question.

What are the common mistakes?

The most common zero-knowledge contract mistakes are using proofs where a normal contract would do, and writing a statement that proves less than the team thinks.

  • Adding proofs for public data. If the data can be public, a normal contract is simpler, cheaper and easier to audit.
  • A weak statement. A proof that says 'the voter is eligible' does not also prove the vote was counted once. Check what the statement actually covers.
  • Ignoring proof cost. Building proofs takes time and computing. Measure it before promising a fast user experience.
  • Trusting the setup. Some proof systems need a trusted setup. Know who ran it and whether it can be audited.
  • No fallback. If proof generation fails, the user needs a clear error and a way forward, not a stuck transaction.

How should a team start?

A team should start with a zero-knowledge proof smart contract only after confirming that privacy is a real requirement, then build the smallest proof that covers one statement.

  1. Write the statement first. State in one sentence what the contract must learn without seeing the data.
  2. Pick a proof system. Choose a well-used system with audited tooling, and check its setup and cost.
  3. Build the proof off chain. Write the program that takes the private inputs and produces the proof.
  4. Write a small verifier contract. Deploy the verifier alone first and test it with true and false statements.
  5. Add the business logic. Only after the verifier works, add the logic that acts on the result. For contract builds, see smart contract development.

Key takeaways

  • A ZK proof contract checks a proof on chain and never sees the private data
  • The proof is sound and private: false statements fail, and inputs stay hidden
  • Use them where privacy and public verification must coexist
  • Proofs cost time and computing, so measure before promising speed
  • Write the statement first, and test the verifier with a false statement

Frequently asked questions

What is the difference between a ZK proof and a ZK rollup?

A ZK proof is the cryptographic tool: a short proof that a statement is true without revealing the data. A ZK rollup is a system that uses such proofs to show that a batch of off-chain transactions was processed correctly. The rollup posts the proof to the main chain, and the chain checks it instead of re-running every transaction.

Are zero-knowledge proofs really private?

A sound proof reveals nothing about the private inputs beyond the statement itself. The privacy depends on the statement: if the statement is 'the balance is exactly 40,000', the proof reveals the balance. Teams design the statement to reveal as little as possible, such as 'the balance covers the payment'.

Why not put all contract data on chain?

Because blockchains are public by default. Anything written to a chain can be read by anyone, forever. For personal data, business amounts or votes, that permanence is a problem. Zero-knowledge proofs let the contract use the fact without publishing it.

How much does proof verification cost?

Verification on chain is usually cheap, while building the proof off chain takes seconds and computing power. The exact cost depends on the proof system and the size of the statement. Measure both before committing to a design, since proof cost is the main trade-off.

Do ZK proof contracts need a trusted setup?

Some proof systems do and some do not. A trusted setup creates the parameters the system uses, and if it is done badly the system can be broken. Use a system with a well-documented setup, or one that needs no trusted setup at all, and check the audit history.

Can a ZK proof contract be audited?

Yes, and it should be. Auditors check the statement, the circuit that builds the proof, and the verifier contract. The most common failures are statements that prove less than the team thinks, so the audit should focus on what the statement actually covers.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: blockchain systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Building a contract that must check private facts?

A senior engineer replies within one business day. Or see our Smart Contract Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call