Skip to content

test(frost/roast): 600-case cross-language differential corpus for the coordinator shuffle#4034

Merged
mswilkison merged 3 commits into
feat/frost-schnorr-migration-scaffoldfrom
parity/coordinator-shuffle-corpus-go-2026-06-11
Jun 11, 2026
Merged

test(frost/roast): 600-case cross-language differential corpus for the coordinator shuffle#4034
mswilkison merged 3 commits into
feat/frost-schnorr-migration-scaffoldfrom
parity/coordinator-shuffle-corpus-go-2026-06-11

Conversation

@mswilkison

Copy link
Copy Markdown
Contributor

Stacked on #3866 (base: feat/frost-schnorr-migration-scaffold). Implements the review item "widen the Go↔Rust math/rand parity from a handful of pinned vectors to corpus-based differential fuzzing" — Go half; the Rust consumer is the paired PR stacked on #4005.

What

A generated 600-case differential corpus over SelectCoordinator (testdata/coordinator_shuffle_corpus.json, 176 KB), replayed by TestCoordinatorShuffle_DifferentialCorpus here and by the identical byte-for-byte copy in the Rust signer's go_math_rand tests:

  • 216 boundary cases: seeds {0, ±1, i64::MIN/MAX, MIN+3/MAX−3, the test(frost/roast): pin cross-language coordinator selection vectors #4026 pin seed and its negation} × attempts {0, 1, 7, u32::MAX} — exercising the two's-complement wrapping seed + attempt composition — × six member sets including unsorted and reversed inputs (pinning the internal sort both implementations perform).
  • 384 generated cases: fixed-seed generator sweeping set sizes 1..255 (the full group.MemberIndex range), full-range int64 seeds, and small/large/extreme attempt numbers.

Regeneration is deterministic and gated (ROAST_SHUFFLE_CORPUS_REGEN=1), so the corpus provably comes from the documented case matrix rather than hand-pinning.

This complements #4030's Annex-A seed-derivation vectors: those pin the derivation end-to-end on 10 vectors; this corpus stress-pins the shuffle port itself — the actual cross-language landmine — at volume, including the integer-boundary regions where a port diverges first.

Not full continuous fuzzing (no coverage-guided harness); it's the pragmatic corpus-differential version that rides the existing unit-test CI on both sides at negligible cost. A coverage-guided Go-oracle harness can layer on later if desired.

Tests

go test ./pkg/frost/roast/... passes (corpus replay + regeneration roundtrip verified).

🤖 Generated with Claude Code

…ator shuffle

Widens Go<->Rust math/rand parity from a handful of pinned vectors to
a generated 600-case differential corpus over SelectCoordinator:

- 216 boundary cases: seeds {0, +/-1, i64 MIN/MAX, MIN+3/MAX-3, the
  #4026 pin seed and its negation} x attempts {0, 1, 7, u32::MAX}
  (exercising the two's-complement wrapping seed+attempt composition)
  x six member sets including unsorted and reversed inputs (pinning
  the internal sort).
- 384 generated cases from a fixed-seed generator sweeping set sizes
  1..255 (full group.MemberIndex range), full-range int64 seeds, and
  small/large/extreme attempt numbers.

The corpus is regenerated from the deterministic case matrix via
ROAST_SHUFFLE_CORPUS_REGEN=1 and mirrored byte-identically to the
Rust signer (pkg/tbtc/signer/testdata/), whose go_math_rand port
replays the same 600 cases -- any drift in source seeding,
Fisher-Yates order, int31n bounds, sign handling, wrapping, or
sorting fails the drifting side's own suite.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5ed33c87-c3df-4ef8-884c-81f6ed8047b4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch parity/coordinator-shuffle-corpus-go-2026-06-11

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 and usage tips.

mswilkison and others added 2 commits June 11, 2026 17:49
…nge event

A regen run that produces different bytes means the legacy math/rand
shuffle semantics changed and deployed engines would disagree on
coordinator rotation. Both language suites passing after a dual regen
is not evidence of compatibility with deployed engines.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Review follow-up (F2): the differential corpus did not exercise Go's
rand.NewSource seed normalization, which reduces the source seed mod
(2^31 - 1) and maps 0 to 89482311 -- so +/-(2^31 - 1) seed the generator
identically to 0. Add both as boundary seeds (verified: same coordinator
as seed 0 at attempt 0 across all boundary sets). A port that
special-cases literal 0 but skips the modulo now fails its own replay.
Corpus grows 600 -> 648 cases; regeneration remains deterministic.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mswilkison added a commit that referenced this pull request Jun 11, 2026
…ffle corpus (#4035)

Stacked on #4005 (base: `extraction/frost-signer-mirror-2026-05-26`).
Rust half of the corpus-based differential parity item from the review;
pairs with the Go-side PR #4034.

Adds `testdata/coordinator_shuffle_corpus.json` — a byte-identical copy
of the canonical 600-case corpus generated from keep-core's Go
`SelectCoordinator` — and
`select_coordinator_matches_cross_language_differential_corpus`, which
replays every case through the `go_math_rand` port: 216 integer-boundary
cases (seeds 0/±1/`i64::MIN`/`i64::MAX`/the #4026 pin seed; wrapping
`seed + attempt` composition up to `u32::MAX`; unsorted and reversed
member inputs pinning the internal sort) plus 384 generated sweeps over
set sizes 1..255 with full-range seeds.

All 600 cases replay identically today — direct evidence the `math/rand`
port is bit-exact across the boundary regions where ports diverge first.
Any future drift in source seeding, Fisher-Yates order, `int31n` bounds,
sign handling, wrapping, or sorting fails this suite on the drifting
side.

Full signer suite passes (245 tests); clippy/rustfmt clean. Mirror note:
port back to the tBTC monorepo signer with the next extraction sync.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
@mswilkison mswilkison merged commit d9d64f0 into feat/frost-schnorr-migration-scaffold Jun 11, 2026
16 checks passed
@mswilkison mswilkison deleted the parity/coordinator-shuffle-corpus-go-2026-06-11 branch June 11, 2026 23:14
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.

1 participant