You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a commit-reveal randomness scheme for front-running-resistant auction tie-breaking:
Bidders submit a hashed commitment during a bidding window, then reveal the pre-image during a separate reveal window.
The final tie-break seed is derived from the hash-chain of all valid reveals (seed = H(reveal_1 || reveal_2 || ... || reveal_n), applied in deterministic submission order — e.g. commitment index, not reveal-arrival order), so no single participant can unilaterally determine the outcome.
A bidder who commits but never reveals forfeits their slot and is excluded from tie-break resolution — with no refund advantage granted to non-revealers.
Scope: contract only. No backend or frontend integration is required for this feature.
This module is designed to serve auction-style mechanisms that need fair tie-breaking. The Burn Auction issue is the most likely consumer — check whether you're picking this up standalone or alongside that issue, since a tie-breaking primitive with no auction to consume it has limited value on its own (it's still independently testable and mergeable, though).
Integration points
New module file contracts/token-factory/src/commit_reveal.rs, declared via mod commit_reveal; in lib.rs
Public #[contractimpl] entry points added to the TokenFactory impl block in lib.rs — suggested names: create_commit_reveal_session, submit_commitment, reveal_pre_image, finalise_commit_reveal_session, get_commit_reveal_session, get_commitment
New DataKey variants added to types.rs for session/commitment state — do not reuse existing discriminants
New Error variants added to types.rs starting at 133 (current highest in-use code is 132), with matching entries added to Error::name()
Storage getters/setters added in storage.rs following the existing pattern
Events emitted via events.rs using short symbol_short! topic names (Soroban's 9-character limit)
Acceptance criteria
commit_reveal.rs implemented under contracts/token-factory/src/, wired into lib.rs
Session creation, commit, reveal, finalise, and query entry points implemented
DataKey/Error additions follow the checklist above
Storage and events wired following existing patterns
Unit tests in commit_reveal_test.rs covering: full commit-then-reveal happy path, hash-chain derivation determinism, non-revealer forfeiture, reveal-outside-window rejection, commit-outside-window rejection, mismatched pre-image rejection
cargo check --lib and cargo test --lib clean in contracts/token-factory
The hash-chain must be applied in a deterministic order (commitment index, not reveal-arrival order) — getting this wrong reintroduces exactly the manipulability this module exists to prevent. Keep the ordering rule explicit and tested.
Enforce sane minimum window durations (e.g. a MIN_COMMIT_WINDOW floor) as a safety measure against griefing with an artificially short window.
Overview
Add a commit-reveal randomness scheme for front-running-resistant auction tie-breaking:
seed = H(reveal_1 || reveal_2 || ... || reveal_n), applied in deterministic submission order — e.g. commitment index, not reveal-arrival order), so no single participant can unilaterally determine the outcome.Scope: contract only. No backend or frontend integration is required for this feature.
This module is designed to serve auction-style mechanisms that need fair tie-breaking. The Burn Auction issue is the most likely consumer — check whether you're picking this up standalone or alongside that issue, since a tie-breaking primitive with no auction to consume it has limited value on its own (it's still independently testable and mergeable, though).
Integration points
contracts/token-factory/src/commit_reveal.rs, declared viamod commit_reveal;inlib.rs#[contractimpl]entry points added to theTokenFactoryimpl block inlib.rs— suggested names:create_commit_reveal_session,submit_commitment,reveal_pre_image,finalise_commit_reveal_session,get_commit_reveal_session,get_commitmentDataKeyvariants added totypes.rsfor session/commitment state — do not reuse existing discriminantsErrorvariants added totypes.rsstarting at 133 (current highest in-use code is132), with matching entries added toError::name()storage.rsfollowing the existing patternevents.rsusing shortsymbol_short!topic names (Soroban's 9-character limit)Acceptance criteria
commit_reveal.rsimplemented undercontracts/token-factory/src/, wired intolib.rsDataKey/Erroradditions follow the checklist abovecommit_reveal_test.rscovering: full commit-then-reveal happy path, hash-chain derivation determinism, non-revealer forfeiture, reveal-outside-window rejection, commit-outside-window rejection, mismatched pre-image rejectioncargo check --libandcargo test --libclean incontracts/token-factorycargo build --target wasm32v1-none --release --libsucceedsNotes for implementers
MIN_COMMIT_WINDOWfloor) as a safety measure against griefing with an artificially short window.