bitcoinjs/bitcoinjs-lib — pull request #220 by dcousens (2014-06-20 05:46:14+00:00)
Title: 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 `*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