Troubleshooting pybitcointools transaction signing/verification

0

2

I'm having several problems getting tests to successfully run under my fork (or vbuterin's pybitcointools, and I'm hoping someone with a combined Python / Bitcoin knowledge can provide some insight.

Here's the error message (as submitted to #145):

======================================================================
FAIL: test_all (__main__.TestTransaction)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/private/var/mobile/Containers/Shared/AppGroup/AA78F2EC-3EE8-40F4-A318-8A9AB1BCB5FF/Pythonista3/Documents/pybitcointools-vbuterin/test.py", line 179, in test_all
    self.assertTrue(verify_tx_input(tx1, 0, mscript, sig1, pubs[1]), "Verification Error")
AssertionError: Verification Error

======================================================================
FAIL: test_all (__main__.TestTransactionSignVerify)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/private/var/mobile/Containers/Shared/AppGroup/AA78F2EC-3EE8-40F4-A318-8A9AB1BCB5FF/Pythonista3/Documents/pybitcointools-vbuterin/test.py", line 133, in test_all
    "Verification error"
AssertionError: Verification error

----------------------------------------------------------------------
Ran 18 tests in 6.944s

FAILED (failures=2, errors=2)

I've got a hunch this has to do with the introduction of low_s (ie s = N-s if s>N//2 else s) for ECDSA signing, but can't be certain.

Can anyone point out where things are going astray?

Wizard Of Ozzie

Posted 2016-07-26T00:50:45.730

Reputation: 4 535

Can you post a diff of your branch vs. vbuterin's?Jimmy Song 2016-07-26T01:59:40.407

@JimmySong git is not one of my strong suits (and currently using iOS for Python) so it's doable, but can you remind how I do a diff of my HEAD vs vbuterin's master?Wizard Of Ozzie 2016-07-27T00:08:34.543

git remote add vbuterin git@github.com:vbuterin/pybitcointools. Then git fetch vbuterin. Then git diff vbuterin/master.Jimmy Song 2016-07-27T13:57:17.120

Answers

1

OK, I figured it out.

It was an issue with the value of v in vrs (v being the version byte, and r/s being the DER values). Since v is not encoded by DER signatures, the check for 27 <= v <= 34 was failing because not knowing the v value would sometimes require v be equal to None, 0 or 1.

Wizard Of Ozzie

Posted 2016-07-26T00:50:45.730

Reputation: 4 535