Skip to content

Conversation

@dcousens
Copy link
Contributor

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 *ScriptSignature is relevant to ECSignature or Script. It seems odd to have Transaction as a dependency of ECSignature.
Thoughts on this?

Reference for implementation: https://github.com/bitcoin/bitcoin/blob/master/src/script.cpp#L241

Copy link
Contributor Author

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) when pulling 5359578 on dcousens:canonical into db5a6d0 on bitcoinjs:master.

Copy link
Contributor

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')

@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) when pulling 63ce1fd on dcousens:canonical into db5a6d0 on bitcoinjs:master.

@weilu
Copy link
Contributor

weilu commented Jun 21, 2014

+1

1 similar comment
@kyledrake
Copy link
Contributor

+1

kyledrake added a commit that referenced this pull request Jun 22, 2014
ECSignature: fixes for canonical signatures
@kyledrake kyledrake merged commit d93623e into bitcoinjs:master Jun 22, 2014
@dcousens dcousens deleted the canonical branch June 27, 2014 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants