Bitcoin Forum
May 24, 2024, 08:59:26 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: algorithimLLL  (Read 114 times)
krashfire (OP)
Jr. Member
*
Offline Offline

Activity: 112
Merit: 6

Life aint interesting without any cuts and bruises


View Profile
January 22, 2023, 01:04:51 AM
Last edit: January 22, 2023, 01:17:17 AM by krashfire
 #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.

KRASH
ymgve2
Full Member
***
Offline Offline

Activity: 161
Merit: 230


View Profile
January 22, 2023, 09: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.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!