fix(go): use math/rand/v2 instead of math/rand in SVM facilitator#1933
Open
br-to wants to merge 1 commit intox402-foundation:mainfrom
Open
fix(go): use math/rand/v2 instead of math/rand in SVM facilitator#1933br-to wants to merge 1 commit intox402-foundation:mainfrom
br-to wants to merge 1 commit intox402-foundation:mainfrom
Conversation
Replace math/rand with math/rand/v2 in fee payer address selection. math/rand/v2 uses a crypto-quality source by default (Go 1.22+), which is the idiomatic choice for financial infrastructure code. This aligns with the client-side code which already uses crypto/rand. Closes x402-foundation#1845 Co-Authored-By: Claude Opus 4.6 <[email protected]>
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.
Fixes #1845
Summary
Replace
math/randwithmath/rand/v2in SVM facilitator fee payer address selection.math/rand/v2uses a crypto-quality source by default (Go 1.22+), which is the idiomatic choice for financial infrastructure code. This aligns with the client-side code (exact/client/scheme.go,exact/v1/client/scheme.go) which already usescrypto/randfor memo nonce generation.Changes
go/mechanisms/svm/exact/facilitator/scheme.go:math/rand→math/rand/v2,rand.Intn→rand.IntNgo/mechanisms/svm/exact/v1/facilitator/scheme.go: same changeUses Option B from the issue (math/rand/v2) since
go.modrequires Go 1.24.0.Test plan
go build ./...passesgo test ./mechanisms/svm/...passes