Hi, below is the full code i modified from
https://blog.trailofbits.com/2020/06/11/ecdsa-handle-with-care/
import ecdsa
import random
import libnum
import olll
import hashlib
import sys
order = 115792089237316195423570985008687907852837564279074904382605163141518161494337
pub = (xxx, xxx)
print ("Curve SECP256k1")
print ("Order:",order)
print ("pub:",pub)
priv = random.randrange(1,order)
Public_key = pub
Private_key = ecdsa.ecdsa.Private_key(Public_key, priv)
k1 = random.randrange(1, pow(2,127))
k2 = random.randrange(1, pow(2,127))
m1 =xxxx
m2 =xxxx
r1 =xxxx
r2 =xxxx
s1 =xxxx
s2 =xxxx
print ("k1: ",k1)
print ("k2: ",k2)
print ("Private key: ",Private_key)
s1_inv = libnum.invmod(s1, order)
s2_inv = libnum.invmod(s2, order)
matrix = [[order, 0, 0, 0], [0, order, 0, 0],
[r1*s1_inv, r2*s2_inv, (2**128) / order, 0],
[m1*s1_inv, m2*s2_inv, 0, 2**128]]
search_matrix = olll.reduction(matrix, 0.75)
r1_inv = libnum.invmod(r1, order)
for search_row in search_matrix:
possible_k1 = search_row[0]
try_private_key = (r1_inv * ((possible_k1 * s1) - m1)) % order
print(f"try_private_key",try_private_key)
it keeps giving a result that is not to the right address after my input and its not random results. it just stays on the same 4 result even though with K (random) and Private Key (random). thats fine but its not pointing to the correct address.
my question is,
1)where i am going wrong with my code?
2)what should i add or change?
3) i tried different loop codes that checks the "try_private_key" to the public key but its not working.
how do i add a proper loop code to check the private key against public key?
please give your own input in the xxx boxes to understand what i meant. Thanks for your help.