Skip to content
commit-reveal Source  →

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

  1. 01 Commit phase: each voter commits to their choice with H(choice ‖ salt).
  2. 02 Reveal phase: voters reveal (choice, salt) to be tallied by the timing-safe check.
  3. 03 Optional: with use_zkp=True, a voter can produce a Schnorr proof of knowledge tied to the commitment.
  4. 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)