test(frost/roast): 600-case cross-language differential corpus for the coordinator shuffle#4034
Merged
mswilkison merged 3 commits intoJun 11, 2026
Conversation
…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>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
…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)
d9d64f0
into
feat/frost-schnorr-migration-scaffold
16 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 byTestCoordinatorShuffle_DifferentialCorpushere and by the identical byte-for-byte copy in the Rust signer'sgo_math_randtests: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 wrappingseed + attemptcomposition — × six member sets including unsorted and reversed inputs (pinning the internal sort both implementations perform).group.MemberIndexrange), full-rangeint64seeds, 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