vbuterin / pybitcointools

SImple, common-sense Bitcoin-themed Python ECC library
1.28k stars 857 forks source link

bip62 low S #100

Closed wizardofozzie closed 8 years ago

wizardofozzie commented 9 years ago

Return low S as per https://github.com/bitcoin/bips/blob/master/bip-0062.mediawiki#low-s-values-in-signatures

jdb6167 commented 9 years ago

Since BIP66 activated over the weekend, any transaction containing BER-encoded signatures will not be accepted by the Bitcoin network. Roughly half of the signatures generated by PyBitcoinTools will be deemed invalid without this PR.

wizardofozzie commented 8 years ago

Yep, I've run into the issue several times already. I've submitted this PR which signs with low s and also implements is_bip66

Also check my fork. Note that pyspecials2 and pyspecials3 have been rolled into a single pyspecials, which checks for Python 2 with str == bytes

wizardofozzie commented 8 years ago

Testing fails if the ecdsa_raw_sign changes s to low s. Instead I've implemented der_encode_sig to check for:

  1. BIP66
  2. Low s

@vbuterin Is it best to implement the code at this PR while also fixing ecdsa_raw_sign to return low s?