fix: use int64 to avoid error when building for 32-bits target#143
fix: use int64 to avoid error when building for 32-bits target#143jht6 wants to merge 1 commit intoXRPLF:mainfrom
Conversation
📝 WalkthroughWalkthroughThe change updates the type of the loop variable in the Changes
Sequence Diagram(s)No sequence diagram generated as the change is limited to a loop variable type update and does not affect control flow or feature logic. ✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🔭 Outside diff range comments (2)
pkg/crypto/secp256k1.go (2)
66-74:discrimBytesnever filled – hashing the wrong data
The code allocatesdiscrimBytesbut then writes the 4 derived bytes into the input slicebytes, leavingdiscrimByteszero-initialised. Consequently, the hash operates on four zero bytes instead of the intended discriminator, andbytesis mutated unexpectedly.- discrimBytes := make([]byte, 4) - bytes[0] = byte(discrim.Uint64()) - bytes[1] = byte(discrim.Uint64() >> 8) - bytes[2] = byte(discrim.Uint64() >> 16) - bytes[3] = byte(discrim.Uint64() >> 24) - - hash.Write(discrimBytes) + discrimBytes := []byte{ + byte(discrim.Uint64()), + byte(discrim.Uint64() >> 8), + byte(discrim.Uint64() >> 16), + byte(discrim.Uint64() >> 24), + } + hash.Write(discrimBytes)
76-83: Same slice-mix-up forshiftBytes
shiftBytesis allocated but never populated; insteadbytesis overwritten. The hash again receives zeros, and the original seed slice is corrupted each iteration.- shiftBytes := make([]byte, 4) - bytes[0] = byte(i) - bytes[1] = byte(i >> 8) - bytes[2] = byte(i >> 16) - bytes[3] = byte(i >> 24) - - hash.Write(shiftBytes) + shiftBytes := []byte{ + byte(i), + byte(i >> 8), + byte(i >> 16), + byte(i >> 24), + } + hash.Write(shiftBytes)
🧹 Nitpick comments (1)
pkg/crypto/secp256k1.go (1)
58-59: Parameter name masks the built-inbytespackage
Using the identifierbytesfor a slice parameter shadows the standard library packagebytes, hindering readability and potential future imports. Consider renaming toseedorinput.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
pkg/crypto/secp256k1.go(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: florent-uzio
PR: Peersyst/xrpl-go#113
File: xrpl/transaction/credential_create.go:30-34
Timestamp: 2025-03-11T11:50:58.330Z
Learning: In PR #113 for xrpl-go, the `CredentialCreate` struct in xrpl/transaction/credential_create.go does not have any duplicated fields as was incorrectly flagged in a previous review comment.
Learnt from: florent-uzio
PR: Peersyst/xrpl-go#113
File: xrpl/transaction/credential_create.go:30-34
Timestamp: 2025-03-11T11:50:58.330Z
Learning: In the PR #113 for xrpl-go, the initial flagging of duplicated fields (`CredentialType` and `Expiration`) in the `xrpl/transaction/credential_create.go` file was determined to be irrelevant and not an actual issue.
Learnt from: florent-uzio
PR: Peersyst/xrpl-go#113
File: xrpl/transaction/credential_create.go:30-34
Timestamp: 2025-03-11T11:50:58.330Z
Learning: The CredentialCreate struct in xrpl/transaction/credential_create.go does not have any duplicated fields as was incorrectly flagged in a previous review comment.
🔇 Additional comments (1)
pkg/crypto/secp256k1.go (1)
61-61: 32-bit build fix is spot-on
Switching the loop counter toint64removes the overflow/constant-too-large error on 32-bit targets without changing behaviour.
Title
Description
This PR aims to . (Mark tags that apply)
Type of change
Checklist:
Changes
Notes (optional)
Describe any additional notes here.
Summary by CodeRabbit