Skip to content
commit-reveal Source  →

From pip install to a proof in five steps.

Every snippet below is copy-paste runnable against commit-reveal as published. No configuration, no services, no keys to provision.

  1. 01

    Install

    Install from PyPI. There are no wheels to compile and no transitive dependencies to resolve — it is pure Python.

    pip install commit-reveal
  2. 02

    Commit to a value

    Construct a scheme and commit. You get back a commitment (safe to publish) and a salt (keep it secret until reveal).

    from commit_reveal import CommitRevealScheme
    
    scheme = CommitRevealScheme()               # sha256 by default
    commitment, salt = scheme.commit("my bid: 42")
  3. 03

    Reveal and verify

    Later, reveal the value with its salt. The check is timing-safe (hmac.compare_digest). A wrong value returns False.

    assert scheme.reveal("my bid: 42", salt, commitment)   # True
    assert not scheme.reveal("my bid: 43", salt, commitment)  # False
  4. 04

    Prove without revealing (optional)

    Opt in to the Schnorr ZKP path. You can prove you know the committed value without publishing it — useful for hidden-then-verified votes.

    scheme = CommitRevealScheme(use_zkp=True)
    commitment, salt = scheme.commit("secret")
    
    public_key, R_compressed, challenge, response = scheme.create_zkp_proof(
        "secret", salt, commitment
    )
    assert scheme.verify_zkp_proof(
        commitment, public_key, R_compressed, challenge, response
    )
  5. 05

    Or use the secure CLI

    For interactive use, the secure CLI prompts via getpass, never echoes the value, and never writes plaintext to disk (files are mode 0600).

    commit-reveal-secure commit my-bid
    commit-reveal-secure reveal my-bid
    commit-reveal-secure list

Where next

You have a working commitment. Now design the protocol around it.

Read how it works for the cryptographic detail, browse the use-cases, or check the threat model before relying on it.