DAO, governance, and prediction-market designers
Hidden ballots & market resolution
Vote or resolve in secret, prove the reveal is honest.
Voters commit to a choice during voting, then reveal to tally. The same shape resolves prediction markets: a resolver commits to an outcome before it is public, removing the last-look advantage. With the optional Schnorr ZKP, a voter or resolver can prove their reveal matches their commitment without re-publishing it for everyone to inspect during verification.
The problem
Open voting invites vote-copying and last-mover coordination; open market resolution invites resolvers to exploit information others cannot yet see. Committing to a ballot or an outcome hides it during the window; a zero-knowledge proof lets the party demonstrate consistency without the tally or resolution process leaking the value to onlookers.
How commit-reveal does it
- 01 Commit phase: each voter commits to their choice with H(choice ‖ salt).
- 02 Reveal phase: voters reveal (choice, salt) to be tallied by the timing-safe check.
- 03 Optional: with use_zkp=True, a voter can produce a Schnorr proof of knowledge tied to the commitment.
- 04 The proof is verified against the commitment — proving the voter can open it — without exposing the choice to third parties during verification.
The code
scheme = CommitRevealScheme(use_zkp=True)
commitment, salt = scheme.commit("candidate:B")
pub, R, e, s = scheme.create_zkp_proof("candidate:B", salt, commitment)
# a third party confirms the voter can open the commitment,
# without learning the choice at verification time
assert scheme.verify_zkp_proof(commitment, pub, R, e, s) More use cases
Anti-MEV & fair ordering
Front-runners cannot react to orders they cannot yet see.
Verifiable on-chain AI
Independent agents answer without copying each other.
Sealed-bid auctions
No bidder can peek at another’s bid before the deadline.
Fair-launch randomness
Uniform, unmanipulable randomness with no trusted oracle.
Teaching cryptography
A readable, zero-dependency reference you can teach from.