-
Notifications
You must be signed in to change notification settings - Fork 20.5k
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
crypto: add SignatureLength constant and use it everywhere #18264
Conversation
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.
LGTM for the Whisper part.
I don't really agree with this change. The 65 bytes is not something that's configurable or makes sense to separate out into a global constant. It's essentially defined by the cryptographic primitive of secp256k1, so hard coding 64 might make the code cleaner to read really. |
I agree, this is not a 'parameter' which can be configured, so I don't see the reason to modify this. |
@holiman @karalabe I agree this is not a configurable parameter, but rather is about all the code around that sizes up slices with 65 (
I would ask you to reconsider, please don't close the issue without allowing some comments from the contributor. In my work for the feeds module in Swarm I had to define my own constant so I don't have to put 65: Perhaps some parts can be tweaked in the PR so not everything is as I put it. Can we find some middle ground? Thanks |
Doesn't that then reinforce the argument that other packages operating on signatures shouldn't seem to have arbitrarily chosen a number, but instead rely on a truth value chaperoned by the package that provides the functionality? |
a83822f
to
e22174d
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.
This is a nice change, but unfortunately breaks the nocgo build. Please define the constants in package crypto instead of crypto/secp256k1.
e22174d
to
b765384
Compare
@fjl modified this to leave |
I'm not a fan, it adds a level of indirection making it more difficult for a programmer to see explicitly what the lengths and offsets are. |
magic number |
Rebased on master |
Not really sure what happened here, but GitHub can't merge this PR anymore. Will reopen this as a new PR. |
Also added PubkeyLength and DigestLength and RecoveryIDOffset, to avoid harcoded numbers