Skip to content

Repository files navigation

commit-reveal

A fairness primitive for the agent economy: commit-reveal schemes with Schnorr zero-knowledge proofs. Pure Python. Zero dependencies.

PyPI versionPython versionsLicense: MITCIcodecovCode style: blacktype-checked: mypysecurity: bandit

🌐 Site · 📚 Docs · 📦 PyPI package · 🗺️ Roadmap · 🔬 Cryptuon Research


Why this matters in 2026

Most of the money lost or extracted on public chains comes from one root cause: someone sees your action before it is final and reacts to it. Front-running, sandwich attacks, copy-trading bots, and oracle games are all timing attacks on information that leaked too early. Commit-reveal is the oldest, smallest, most auditable fix for that class of problem — you bind to a value now and announce it later, so nobody can act on what they cannot yet see.

That primitive is having a moment. The narratives driving crypto in 2026 — agentic payments, verifiable on-chain AI, prediction markets, MEV mitigation, and intent-based DEXs — all need cheap, verifiable fairness at their core:

  • Anti-MEV / fair ordering — order intents commit during a sealed window, then reveal for matching. Front-runners cannot react to orders they have not yet seen.
  • Sealed-bid auctions — bidders publish commitments; nobody, not even the auctioneer, reads a bid before the reveal deadline. The natural settlement layer for RWA and NFT auctions.
  • Commit-reveal randomness — many parties commit to seeds, then reveal; the result is a hash of all reveals, uniform and unmanipulable as long as one participant is honest.
  • Verifiable AI — in networks where independent agents (e.g. DFPN-style inference or forecasting nodes) must submit answers without copying each other, each agent commits to its output first and reveals after the window closes. The Schnorr ZKP then lets an agent prove "this reveal matches my commitment" without re-broadcasting the payload.
  • Prediction-market resolution — resolvers commit to an outcome before it is public, removing the last-look advantage.

commit-reveal is a small, dependency-free primitive you drop into that infrastructure. It is a library, not a network — it computes and verifies commitments and proofs; it does not run consensus, hold funds, or settle on-chain by itself. What ships on-chain is your choice: the reference path to a minimal on-chain verifier is laid out in ROADMAP.md.

Highlights

  • Multi-algorithm commitments — SHA-256, SHA-512, SHA-3, BLAKE2b/2s
  • Schnorr zero-knowledge proofs on secp256k1 (same curve as Bitcoin)
  • Tamper-evident audit trail with cryptographic integrity verification
  • Secure CLI that never stores plaintext values on disk
  • Zero external dependencies — stdlib only
  • 90%+ test coverage, mypy strict, property-based testing with Hypothesis

Installation

pip install commit-reveal

Or with Poetry:

poetry add commit-reveal

Quick Start

Basic commit-reveal

fromcommit_revealimportCommitRevealSchemescheme=CommitRevealScheme()
# Commit phase — share the commitment, keep the salt secretcommitment, salt=scheme.commit("my secret value")
# Reveal phase — prove you committed to this valueassertscheme.reveal("my secret value", salt, commitment) # Trueassertnotscheme.reveal("wrong value", salt, commitment) # False

With zero-knowledge proofs

scheme=CommitRevealScheme(use_zkp=True)
commitment, salt=scheme.commit("secret")
public_key, R_compressed, challenge, response=scheme.create_zkp_proof(
"secret", salt, commitment
)
# Anyone can verify you know the secret — without learning itassertscheme.verify_zkp_proof(
commitment, public_key, R_compressed, challenge, response
)

CLI

# Commit to a value (prompts securely, no echo)
commit-reveal-secure commit my-secret
# Verify the value later
commit-reveal-secure reveal my-secret
# List stored commitments
commit-reveal-secure list

Supported Hash Algorithms

AlgorithmOutputNotes
sha25632 bytesDefault, widely compatible
sha38448 bytes
sha51264 bytesHigher security margin
sha3_25632 bytesNIST post-quantum family
sha3_38448 bytes
sha3_51264 bytes
blake2b64 bytesFast on 64-bit platforms
blake2s32 bytesFast on 32-bit platforms

API at a Glance

classCommitRevealScheme:
def__init__(self, hash_algorithm='sha256', use_zkp=False, enable_audit=True): ...
defcommit(value, salt=None) ->tuple[bytes, bytes]: ...
defreveal(value, salt, commitment) ->bool: ...
defverify(value, salt, commitment) ->bool: ... # alias for reveal# Zero-knowledge proofs (requires use_zkp=True)defcreate_zkp_proof(value, salt, commitment) ->tuple: ...
defverify_zkp_proof(commitment, public_key, R_compressed, challenge, response) ->bool: ...
defverify_commitment_consistency(value, salt, commitment, public_key) ->bool: ...

Exceptions:ValidationError for invalid input, SecurityError for insecure operations (e.g., MD5/SHA-1).

Full API reference: documentation

CLI Tools

CommandDescription
commit-reveal-secureProduction CLI — never stores plaintext
commit-reveal-migrateMigrate from legacy to secure format
commit-revealLegacy CLI (deprecated)

Enable ZKP for any command with --zkp:

commit-reveal-secure --zkp commit my-secret
commit-reveal-secure --zkp verify-proof my-secret

Where this fits in 2026 infrastructure

NarrativeThe unfairness it removesHow commit-reveal helps
MEV mitigation / fair orderingSearchers front-run and sandwich pending transactionsCommit intents in a sealed window; reveal for matching. No peeking, no reordering advantage.
Verifiable on-chain AIAgents copy each other's answers instead of computing independentlyEach agent commits to its output first; reveals after the window; proves consistency with a Schnorr ZKP.
Sealed-bid auctions (RWA, NFTs)Late bidders read earlier bidsBids are commitments until the deadline; the auctioneer cannot read them either.
On-chain randomnessA single party biases the seedMulti-party commit-reveal RNG; honest-minority safe.
Prediction-market resolutionResolvers exploit last-look informationResolvers commit to an outcome before it is public.

For the full "where it fits and how to get to production" picture, see ROADMAP.md.

Scope, stated plainly: commit-reveal is a primitive library, not a sequencer, a mempool, or an L2. It gives you the cryptographic core (bind, reveal, prove) that fairness-preserving systems are built from. The system design — who commits, when the window closes, where reveals are posted — is yours.

Documentation

Full documentation available at docs.cryptuon.com/commit-reveal.

Development

# Install with dev dependencies
poetry install --with dev
# Run tests
poetry run pytest
# Type checking
poetry run mypy commit_reveal/ --strict
# Formatting
poetry run black commit_reveal/ tests/
# Security scan
poetry run bandit -r commit_reveal/

Security

See SECURITY.md for the full security policy, threat model, and vulnerability reporting process.

License

MIT © 2025 Dipankar Sarkar


Part of Cryptuon Research

commit-reveal is one of 20 open-source blockchain-infrastructure projects from Cryptuon Research — blockchain theory, shipped as protocols.

Related projects:blockchain-compression · StxScript · nklave

Docs: docs.cryptuon.com/commit-reveal · Contact: contact@cryptuon.com

About

Cryptographic commit-reveal schemes with Schnorr zero-knowledge proofs. Pure Python, zero dependencies.

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages