<p>OK, I figured it out.</p>

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

CC BY-SA 3.0
2016-08-01T05:08:55.427Z
2016-08-01T07:45:20.413Z
2016-08-01T07:45:20.413Z
Wizard Of Ozzie
<p>I'm having several problems getting tests to successfully run <a href="https://github.com/wizardofozzie/pybitcointools" rel="nofollow">under my fork</a> (or vbuterin's <a href="https://github.com/vbuterin/pybitcointools" rel="nofollow">pybitcointools</a>, and I'm hoping someone with a combined Python / Bitcoin knowledge can provide some insight.</p>

<p>Here's the error message (as submitted to <a href="https://github.com/vbuterin/pybitcointools/issues/145" rel="nofollow">#145</a>):</p>

<pre><code>======================================================================
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)
</code></pre>

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

<p>Can anyone point out where things are going astray?</p>

CC BY-SA 3.0
2016-07-26T01:59:40.407Z
Can you post a diff of your branch vs. vbuterin's?
Jimmy Song
CC BY-SA 3.0
2016-07-27T00:08:34.543Z
@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
CC BY-SA 3.0
2016-07-27T13:57:17.120Z
`git remote add vbuterin git@github.com:vbuterin/pybitcointools`. Then `git  fetch vbuterin`. Then `git diff vbuterin/master`.
Jimmy Song
<ecdsa><python>
Troubleshooting pybitcointools transaction signing/verification
Wizard Of Ozzie
# Troubleshooting pybitcointools transaction signing/verification

(Asked by: username_0 on 2016-07-26)

I'm having several problems getting tests to successfully run [under my fork](https://github.com/username_0/pybitcointools) (or vbuterin's [pybitcointools](https://github.com/vbuterin/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](https://github.com/vbuterin/pybitcointools/issues/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?

**Tags:** ecdsa, python

> **Comments:**
> **username_1**: Can you post a diff of your branch vs. vbuterin's?  
> **username_0**: @username_1 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?  
> **username_1**: `git remote add vbuterin git@github.com:vbuterin/pybitcointools`. Then `git  fetch vbuterin`. Then `git diff vbuterin/master`.  

---

## 1 answers

### Answer by username_0 on 2016-08-01. Score: 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`.


---

