-
Notifications
You must be signed in to change notification settings - Fork 1
force assign geth's S256() as Curve value #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
291f57e to
8c1e10a
Compare
|
@dai1975 Thank you, but why did you notice this issue? Ah, I resolved it myself. |
pkg/wallet/wallet.go
Outdated
| // The ecdsaPrivKey.Curve points to the dcrd.secp256k1.S256() instance, | ||
| // but in some environments (e.g., Docker containers) the comparison with gethcrypto.S256() may fail. | ||
| // To ensure consistency, we replace the Curve with gethcrypto.S256().' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation is OK, but probably, this issue description is not accurate.
Since dcrd.secp256k1.S256() and gethcrypto.S256() are different objects, pointer comparison between them ALWAYS fails.
The real issue is implementation difference between signatrure_nocgo.go and signature_cgo.go in the go-ethereum/crypto package.
The former implementation requires prv.Curve == gethcrypto.S256() but the latter doesn't.
In typical environments, the latter implementation is chosen to build relayers, and so this issue doesn't pop up.
In some environments, like Docker containers with no C compilers installed, the former implementation is used.
Could you fix the comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks I did not understand real cause.
I've rewritten that comment.
Signed-off-by: Daisuke Kanda <daisuke.kanda@datachain.jp>
8c1e10a to
ce80e1f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses an issue with comparing the S256() curve in docker environments by forcing the use of gethcrypto.S256() when necessary.
- Replaces direct return of btcecPrivKey.ToECDSA() with an intermediate assignment.
- Adds a conditional to reassign ecdsaPrivKey.Curve to gethcrypto.S256() if it does not match.
Comments suppressed due to low confidence (1)
pkg/wallet/wallet.go:134
- Comparing the curve by pointer equality after checking the name may be brittle if the underlying implementation changes. Consider caching the gethcrypto.S256() value in a local variable to improve clarity and ensure consistent comparisons.
if ecdsaPrivKey.Curve.Params().Name == "secp256k1" && ecdsaPrivKey.Curve != gethcrypto.S256() {
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
siburu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dai1975 LGTM!
Fix S256() curve compare fails in docker enviroments.
https://github.com/ethereum/go-ethereum/blob/master/crypto/signature_nocgo.go#L82