Author

Topic: algorithimLLL (Read 33 times)

full member
Activity: 161
Merit: 230
January 22, 2023, 05:28:20 AM
#2
You are using external signatures, which will not work unless you KNOW they are biased in the exact same way as the example. You are not using the k1, k2 and private key variables at all.

As with the previous fault injection code, you seem to just throw external signatures in the middle of a program and don't care or understand the purpose of the program.
jr. member
Activity: 96
Merit: 6
Life aint interesting without any cuts and bruises
January 21, 2023, 09:04:51 PM
#1
Hi, below is the full code i modified from
https://blog.trailofbits.com/2020/06/11/ecdsa-handle-with-care/

Code:

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?  Huh Huh Huh Cry
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.
Jump to: