<p>I am doing my research on SECP256k1 but now i am facing assertion error sometimes.
I can't seem to find where it comes from, so i once thought its because the resulting point is point at affinity.</p>
<p>So i used order of the curve n but instead i got (None,None) not assertion error.</p>
<p>Please help.</p>
<p>Here is the error:</p>
<pre><code>    point2 = Point(curve, Q[0], Q[1])
  File &quot;/home/admin/.local/lib/python3.9/site-packages/ecdsa/ellipticcurve.py&quot;, line 1090, in __init__
    assert self.__curve.contains_point(x, y)
AssertionError
</code></pre>
<p>Responsible code:</p>
<pre><code>import ecdsa
from ecdsa import SECP256k1
from ecdsa.ellipticcurve import Point
from sympy import mod_inverse
import bitcoin
import multiprocessing

curve = SECP256k1.curve
G = ecdsa.SECP256k1.generator
n= G.order()

def addp(P,Q):
    point1 = Point(curve, P[0], P[1])
    point2 = Point(curve, Q[0], Q[1])
    result_point = point1 + point2
    return result_point.x()

def find(public_key,a,b,r):
    print(hex(public_key[0]))
    if not(a == b):
        p1 = bitcoin.fast_multiply(bitcoin.G,a)# (a = z/s)
        p2 = bitcoin.fast_multiply(public_key,b)# (b = r/s)
        R = addp( p1, p2) 
        tg = R % n
        if(tg == r):
            return True
    return False
</code></pre>

CC BY-SA 4.0
2023-10-28T12:12:08.180Z
Hi Alexio, your code doesn't include any import statements and only defines functions but doesn't actually execute anything. Can you share the complete code that reproduces your error?
Vojtěch Strnad
CC BY-SA 4.0
2023-10-28T12:18:45.813Z
@VojtěchStrnad i have corrected the code
Alexio puk2sefu
CC BY-SA 4.0
2023-10-28T13:45:56.763Z
What functions do you invoke (`find`?), and with which arguments?
Pieter Wuille
CC BY-SA 4.0
2023-10-28T14:30:32.390Z
@PieterWuille it's random numbers 1 to 50 in a and b then the r value from signature along with public key
Alexio puk2sefu
CC BY-SA 4.0
2023-10-28T14:33:11.280Z
The. Code attempts to find a multiplier and a reminder (U1 and U2) in ecdsa signature such that k = U2*d+U1
Alexio puk2sefu
CC BY-SA 4.0
2023-10-28T14:39:50.263Z
@Alexiopuk2sefu Can you paste the actual code you're using?
Pieter Wuille
<python><secp256k1>
Why assertion error in Point addition?
Alexio puk2sefu
# Why assertion error in Point addition?

(Asked by: username_0 on 2023-10-28)

I am doing my research on SECP256k1 but now i am facing assertion error sometimes.
I can't seem to find where it comes from, so i once thought its because the resulting point is point at affinity.

So i used order of the curve n but instead i got (None,None) not assertion error.

Please help.

Here is the error:

```
    point2 = Point(curve, Q[0], Q[1])
  File "/home/admin/.local/lib/python3.9/site-packages/ecdsa/ellipticcurve.py", line 1090, in __init__
    assert self.__curve.contains_point(x, y)
AssertionError

```

Responsible code:

```
import ecdsa
from ecdsa import SECP256k1
from ecdsa.ellipticcurve import Point
from sympy import mod_inverse
import bitcoin
import multiprocessing

curve = SECP256k1.curve
G = ecdsa.SECP256k1.generator
n= G.order()

def addp(P,Q):
    point1 = Point(curve, P[0], P[1])
    point2 = Point(curve, Q[0], Q[1])
    result_point = point1 + point2
    return result_point.x()

def find(public_key,a,b,r):
    print(hex(public_key[0]))
    if not(a == b):
        p1 = bitcoin.fast_multiply(bitcoin.G,a)# (a = z/s)
        p2 = bitcoin.fast_multiply(public_key,b)# (b = r/s)
        R = addp( p1, p2) 
        tg = R % n
        if(tg == r):
            return True
    return False

```

**Tags:** python, secp256k1

> **Comments:**
> **username_1**: Hi username_0, your code doesn't include any import statements and only defines functions but doesn't actually execute anything. Can you share the complete code that reproduces your error?  
> **username_0**: @username_1 i have corrected the code  
> **username_2**: What functions do you invoke (`find`?), and with which arguments?  
> **username_0**: @username_2 it's random numbers 1 to 50 in a and b then the r value from signature along with public key  
> **username_0**: The. Code attempts to find a multiplier and a reminder (U1 and U2) in ecdsa signature such that k = U2*d+U1  
> **username_2**: @username_0 Can you paste the actual code you're using?  

---

## 0 answers

