Skip to content

feat: V2 commitment replay boundary — frozen preimage, domain binding, weak salt - #838

Open
GazzyLee wants to merge 1 commit into
DigiNodes:mainfrom
GazzyLee:v2-commitment-replay-boundary
Open

GazzyLee wants to merge 1 commit into
DigiNodes:mainfrom
GazzyLee:v2-commitment-replay-boundary

Conversation

@GazzyLee

@GazzyLee GazzyLee commented Oct 17, 2026 •

Copy link
Copy Markdown

Freeze commitment preimage fields, types, encoding, chain/release/contract/round domains, and salt requirements for VerificationCommitReveal (PREWAVE-SC-085).

Changes

Contract (contracts/v2/VerificationCommitReveal.sol)

  • RELEASE_VERSION constant — pinned protocol release hash for cross-release replay protection
  • COMMITMENT_TYPEHASH updated — includes releaseVersion and deadline (10 replay dimensions total: chainId, releaseVersion, verifyingContract, verifier, claimId, roundId, deadline, decision, rationaleHash, salt)
  • Deadline parameter added to commit(),
    eveal(),
    evealWithSignature(), _reveal(), and computeCommitment() — stored in Record and must match at reveal
  • Deadline validation — DeadlinePassed, DeadlineTooShort (below MIN_DEADLINE_BUFFER=1h), DeadlineTooFar (above MAX_DEADLINE_HORIZON=365 days)
  • Weak salt detection — WeakSalt error for all-identical bytes, last-byte-only non-zero, and small integer-like salts
  • Encoding — all preimages use �bi.encode (never �bi.encodePacked)
  • New errors: WeakSalt, DeadlinePassed, DeadlineTooShort, DeadlineTooFar

Tests ( est/v2/VerificationCommitReveal.t.sol)

  • Cross-chain replay (chainId 10 vs 1)
  • Cross-release replay (canonical vs alt release version)
  • Cross-contract replay (same hash on different contract instance)
  • Cross-round replay (reveal on wrong round)
  • Field reordering (swapped fields produce different hash)
  • Packed encoding ambiguity demonstration
  • Zero salt, weak salt (all-identical, last-byte-only, small-int)
  • Wrong voter
  • Deadline validation (past, too soon, too far, min buffer, max horizon)
  • Fuzz: any changed field fails and leaves state intact
  • Fuzz: weak salt is rejected

Infrastructure (build fixes)

  • config/networks.ts — missing module required by hardhat.config.ts

emappings.txt — point to node_modules instead of empty lib/ submodules

  • V2OperationIds.sol, V2SubmoduleProvenance.sol — missing stubs for compilation

Acceptance Criteria

  • Commitments are unambiguous and context-bound (10-dimensional domain separation)
  • Published vectors match on/off-chain implementations (computeCommitment is public view)
  • Reveal cannot be replayed elsewhere (cross-chain/release/contract/round all fail closed)
  • Pre-reveal data exposes no decision (only commitment hash emitted)

Security & Architecture Constraints

  • Preserves approved Optimism/EVM V2 topology, timelock, role, and operation-scoped pause model
  • Does not weaken tests, assertions, custom errors, or release gates (additive only)
  • Uses exact integer arithmetic and deterministic artifacts

Dependencies

Non-Goals

  • Unrelated refactors or mainnet deployment
  • Applying Stellar Wave before maintainer activation

Closes #719

…, weak salt

Freeze commitment preimage fields, types, encoding, chain/release/contract/round
domains, and salt requirements for VerificationCommitReveal (PREWAVE-SC-085).

Changes:
- Add RELEASE_VERSION constant for cross-release replay protection
- Add deadline field to commitment preimage for temporal binding
- Update COMMITMENT_TYPEHASH to include releaseVersion and deadline (10 dimensions)
- Add deadline validation (MIN_DEADLINE_BUFFER, MAX_DEADLINE_HORIZON)
- Add weak salt detection (all-identical bytes, last-byte-only, small integers)
- Store deadline in Record; reveal must resubmit matching deadline
- All encodings use abi.encode (never abi.encodePacked)
- New errors: WeakSalt, DeadlinePassed, DeadlineTooShort, DeadlineTooFar

Tests added:
- Cross-chain replay (chainId=10 vs 1)
- Cross-release replay (canonical vs alt release version)
- Cross-contract replay (same hash on different contract instance)
- Cross-round replay (reveal on wrong round)
- Field reordering (swapped fields produce different hash)
- Packed encoding ambiguity demonstration
- Zero salt (existing), weak salt (all-identical, last-byte-only, small-int)
- Wrong voter (existing)
- Deadline validation (past, too soon, too far, min buffer, max horizon)
- Fuzz: any changed field fails and leaves state intact
- Fuzz: weak salt is rejected

Infrastructure fixes for build:
- config/networks.ts (missing module required by hardhat.config.ts)
- remappings.txt (point to node_modules instead of empty lib/ submodules)
- V2OperationIds.sol, V2SubmoduleProvenance.sol (missing stubs for compilation)

Closes DigiNodes#724
@GazzyLee
GazzyLee requested a review from dDevAhmed as a code owner October 17, 2026 16:02
@coderabbitai

coderabbitai Bot commented Oct 17, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Repository: DigiNodes/truthbounty-contract/.coderabbit.yaml
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 66080b3b-9f46-44e7-9d6f-a1fb71993e87
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PREWAVE-SC-043 — Domain-Separate Commit-Reveal Salt and Commitment Schemes

1 participant