Skip to content
commit-reveal Source  →

← Home · Compare

commit-reveal vs a DIY hashlib commitment

Hand-rolling H(value + salt) yourself with the standard library

You can absolutely write H(value ‖ salt) yourself — and for a throwaway script you probably should. What commit-reveal adds is the set of small, easy-to-miss correctness and safety details that turn "a hash" into "a commitment scheme you can defend in review".

Feature commit-reveal a DIY hashlib commitment Better fit
Lines of code you own A pip install; read the source if you like You own and maintain all of it Comparable
Salt generation secrets.token_bytes(32) by default Whatever you remember to use (people reach for random) commit-reveal
Reveal comparison hmac.compare_digest (constant-time) Usually == — an early-exit timing leak commit-reveal
Weak-hash guardrail md5 / sha1 raise SecurityError None — md5 works until someone notices commit-reveal
Zero-knowledge proof Schnorr on secp256k1, non-interactive You would hand-roll a curve — do not commit-reveal
Runtime dependencies None (only Python ≥ 3.8) None Comparable
Auditability One small, typed, tested library to review Scattered across your codebase commit-reveal
License MIT Yours Comparable

Pick commit-reveal when

  • You want a timing-safe reveal (hmac.compare_digest) rather than an == that leaks
  • You want weak hashes (md5, sha1) rejected at construction, not silently accepted
  • You want an optional Schnorr proof of knowledge without hand-rolling secp256k1
  • You want a no-plaintext-at-rest CLI and an audit trail for free

Pick a DIY hashlib commitment when

  • The commitment is a throwaway inside a single trusted process
  • You never need to reveal to an adversarial counterparty
  • You have your own vetted crypto utilities and a review process around them
  • You genuinely want zero code you did not write — commit-reveal is still tiny, but it is not nothing

Honest note

They solve different problems.

It is entirely reasonable to depend on both: py_ecc for the curve and pairing primitives, commit-reveal for the commitment scheme. The libraries do not overlap on their core jobs.