refactor(retry): move duplicated participant-selection into a shared package#4118
Merged
mswilkison merged 2 commits intoJun 27, 2026
Conversation
…package pkg/frost/retry/retry.go was a byte-for-byte copy of pkg/tecdsa/retry/retry.go -- two hand-synchronized copies of the security-critical retry participant-selection algorithm (EvaluateRetryParticipantsForSigning / ...ForKeyGeneration). A fix applied to one and not the other would silently make ECDSA and FROST select different qualified-operator sets for the same seed. This selection is structurally shared across schemes: it is the scheme-agnostic "pick the base signing group from the ready members" used for the initial attempt of every signing (and for DKG). FROST's per-attempt robustness diverges only on retries, via ROAST (NextAttempt); the initial selection does not -- ROAST is a transition-from-previous function and cannot produce attempt 0, so the initial selection is permanently shared. Move the algorithm (byte-for-byte, verified identical) into a neutral package, pkg/protocol/retry, and point both callers (pkg/tbtc/dkg_loop.go and signing_loop_legacy_selector.go -- the only two) at it. Delete pkg/tecdsa/retry and pkg/frost/retry. Keep the superset test (the tecdsa copy had an extra triplet-seat-count case the frost copy lacked). No behavior change; a single source eliminates the drift hazard. Co-Authored-By: Claude Opus 4.8 (1M context) <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 |
…etry-selection-shared-package
d97b8fb
into
feat/frost-schnorr-migration-scaffold
17 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.
Summary
Follow-up to #3866. Eliminates a byte-for-byte duplicate of the retry participant-selection algorithm by moving it into a shared, scheme-neutral package.
pkg/frost/retry/retry.gowas a byte-for-byte copy ofpkg/tecdsa/retry/retry.go— two hand-synchronized copies of the security-critical retry participant-selection algorithm (EvaluateRetryParticipantsForSigning/…ForKeyGeneration). A fix applied to one and not the other would silently make ECDSA and FROST select different qualified-operator sets for the same seed.Why a shared package (vs. one importing the other)
This selection is structurally shared across schemes: it's the scheme-agnostic "pick the base signing group from the ready members" used for the initial attempt of every signing (and for DKG). FROST's per-attempt robustness diverges only on retries, via ROAST (
NextAttempt) — the initial selection does not. ROAST is a transition-from-previous-attempt function and cannot produce attempt 0, soroastSigningParticipantSelectorfalls back to this selection for the initial attempt (ConsumeRoastTransitionForSelectionreturnsErrRoastSelectionFallBackToLegacyatroastAttemptNumber == 0). So the initial selection is permanently shared — neithertecdsanorfrostshould own it.Change
diff-identical, no logic change) into a new neutral packagepkg/protocol/retry(packageretry, alongsidepkg/protocol/group).pkg/tbtc/dkg_loop.go(DKG) andpkg/tbtc/signing_loop_legacy_selector.go(FROST initial selection) — at it (import-path change only; usageretry.Xunchanged).pkg/tecdsa/retryandpkg/frost/retry.tecdsacopy had aTestExcludeOperatorTripletsCountsRightOperatorSeatscase thefrostcopy lacked).Verification
diffconfirms the moved algorithm is byte-identical to the original (pure move).go build ./...clean (no dangling references to the deleted packages); builds clean under-tags 'frost_native frost_tbtc_signer cgo frost_roast_retry'.go vetclean; the movedpkg/protocol/retrytest passes (incl. the superset case); the fullpkg/tbtcsuite passes.No behavior change — a single source eliminates the silent-drift hazard.
Found during review of #3866.
🤖 Generated with Claude Code