Skip to content

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
br-to:fix/svm-crypto-rand
Open

fix(go): use math/rand/v2 instead of math/rand in SVM facilitator#1933
br-to wants to merge 1 commit intox402-foundation:mainfrom
br-to:fix/svm-crypto-rand

Conversation

@br-to
Copy link
Copy Markdown

@br-to br-to commented Apr 4, 2026

Fixes #1845

Summary

Replace math/rand with math/rand/v2 in SVM facilitator 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 (exact/client/scheme.go, exact/v1/client/scheme.go) which already uses crypto/rand for memo nonce generation.

Changes

  • go/mechanisms/svm/exact/facilitator/scheme.go: math/randmath/rand/v2, rand.Intnrand.IntN
  • go/mechanisms/svm/exact/v1/facilitator/scheme.go: same change

Uses Option B from the issue (math/rand/v2) since go.mod requires Go 1.24.0.

Test plan

  • go build ./... passes
  • go test ./mechanisms/svm/... passes
  • Verify fee payer selection still distributes load across signers

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]>
@github-actions github-actions bot added go sdk Changes to core v2 packages labels Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go sdk Changes to core v2 packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggest: use crypto/rand instead of math/rand in SVM facilitator

1 participant