Skip to content

Replace linear nonce replay scan with normalized hash set - #9

Open
notforhumansfun-rgb wants to merge 1 commit into
iamonuwa:mainfrom
notforhumansfun-rgb:fix/hashed-nonce-replay
Open

notforhumansfun-rgb wants to merge 1 commit into
iamonuwa:mainfrom
notforhumansfun-rgb:fix/hashed-nonce-replay

Conversation

@notforhumansfun-rgb

Copy link
Copy Markdown

Closes #7.

What changed

  • deserialize Context.seen_nonces into a deduplicated HashSet<[u8; 32]>
  • normalize CLI nonce inputs once into the same binary set
  • reject non-0x-prefixed or non-32-byte nonce inputs before verification
  • replace the per-verification linear string scan with one O(1) set lookup
  • cap CLI input at 100,000 unique consumed nonces and document the boundary
  • exercise NONCE_REPLAY with a 100,001-entry set, plus malformed-input and normalization regressions

The JSON wire shape remains string[]; reason codes and normative check order do not change. The public Rust field type changes from Vec<String> to HashSet<[u8; 32]>, matching the issue proposal.

Verification

  • cargo build --workspace
  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo test --workspace
  • python crosscheck/verify.py vectors — 9/9
  • python -m pytest crosscheck/test_crosscheck.py — 2/2

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.

Replace linear nonce-replay scan with a hashed set

1 participant