-
Notifications
You must be signed in to change notification settings - Fork 2.2k
ECSignature: fixes for canonical signatures #220
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
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.
Is this suitable? Or should we just enforce secp256k1 as we have in other parts. If so, the signature length is at most going to be less than 73 bytes if so, as enforced by the reference implementation.
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.
I support enforcing secp256k1 until we have a need for supporting other curves
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.
That won't help us if we ever use another ecdsa (with its own ECSignature) library other than the one currently included.
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.
We can worry about it then?
src/ecsignature.js
Outdated
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.
If you don't intend to differentiate the two error cases, why not just combine them? assert(hashTypeMod > 0x00 && hashTypeMod < 0x04, 'Invalid hashType')
|
+1 |
1 similar comment
|
+1 |
ECSignature: fixes for canonical signatures
This pull request accounts for all the edge cases allowed by the Bitcoin client, and adds the respective core tests to
tests/bitcoin.core.js.Namely adding the missing test cases for:
R<0,S<0, and checking the DER padding is not extraneous.Hash type checking has also been added, but to avoid the circular dependency the boundaries were hard coded. This is not ideal, but I'm still not sure if
*ScriptSignatureis relevant toECSignatureorScript. It seems odd to haveTransactionas a dependency ofECSignature.Thoughts on this?
Reference for implementation: https://github.com/bitcoin/bitcoin/blob/master/src/script.cpp#L241