Just made some tweaks to my code. Would love some feedback on whether my approach is more efficient or even makes sense.
Looking for Efficient K Nonce Calculation
23 replies 103 views
I heard that six weeks is pretty quick for this, but I'm aiming to speed things up. Can you guys check out my sagemath code and suggest improvements?
Hey there, here’s my version if you have the private key or might need to brute-force.
You can always verify if you found a valid K by checking R == K * G.
Sounds good, I’ll give it a shot.
So I got this error:
line 12
SyntaxError: Non-ASCII character in file nonce9.sage.py on line 12. No encoding declared; check the Python docs.
Krashfire,
u1 = (modinv(s, n) * z) % n
u2 = (modinv(s, n) * r) % n
if K == (u1 * G + u2 * R):
Isn't u1 and u2 known? What’s the issue with finding u1*G + u2*R?
Just updated my code in sagemath.
Dude, try testing your code with this data. I ran your previous script and couldn’t find k!
Test data:
r = 115780575977492633039504758427830329241728645270042306223540962614150928364886
s = 115784413730767153834193500621449522112098284939719838943229029456606672741370
z = 2
k = 6
Getting the same error again. Tried to fix it but it keeps happening:
k = ((r * i%n + z%n)%n * modinv(s, n) % n)%n
File "sage/structure/element.pyx", line 1921...
That can’t be right. Did you insert your rsz? I tried with 3 different rsz sets, signature verified, and the code works.
I’m using this rsz, man:
r = 115780575977492633039504758427830329241728645270042306223540962614150928364886
s = 115784413730767153834193500621449522112098284939719838943229029456606672741370
z = 2
What’s wrong?
I added this part:
k = (r * i + z) * modinv(s, n) % n
R = E.lift_x(Integer(r))
P = k * G
print("K:", hex(P.xy()[0]))
It worked! Found k but...
ecdsa123 says nonce is 6, not the value I got.
Here’s a little example of how to integrate your code into bsgs or kangaroo software:
r = 115780575977492633039504758427830329241728645270042306223540962614150928364886
s = 115784413730767153834193500621449522112098284939719838943229029456606672741370
z = 2
i = 0
while True:
k = (z + i) % n
print("k", k)
R = E.lift_x(Integer(r))
K = k * (modinv(s, n) * G)
u1 = (modinv(s, n) * z) % n
u2 = (modinv(s, n) * r) % n
if K == (u1 * G + u2 * R):
print("&", k)
print("yes!!!")
print("Found real k:", k, i)
break
i = i
Lol, that won’t work. That’s not a real rsz.
Why does this not work? Just swap the base point and "i" in kangaroo, and you get "i" where you find k. It’s just another way to use kangaroo and bsgs.
Try with your actual 6 weeks search rsz and let us know how long it takes to find k using cuda bsgs or cuda kangaroo.
@Krashfire, any updates on your findings?
Hi, I want to try your code with these rsz:
1:
r = 0x57a463b8ac30f2ed36767d5ccabf04fbe29c94b054b4309996f086556428c748
s = 0x5a4c7e96159688e8cd2525a3230ec5184597d6cfbaf037ca5815fa01097f67cc
z = 0xa37f38a2db651ba57f68ef4d0ac297e732d0eb3954bb85ac069569f9b372daa0
2:
r = 0x4f7f2657387cf1fef8152e2bbd39f153ee235e1f46294fded0d42dacbbe7ea
s = 0x430773be7ebda7fba5ed2f829e9b47a7f92d526905c250780f044ed860de0786
z = 0x76757e4b29801bbb747a125c0bb6752feeeabd84c58fe3dd71e94eed3839dfaa
Can you help with a script to find private keys?
Those two sets of r,s,z use different public keys, so the private keys have to be different too.
Related topics
- New Bitcoin Improvement Proposal with $100 Reward 9
- Clipboard Vulnerabilities in Cryptocurrency Transactions 8
- Understanding the Differences Between Traditional and Simplified Chinese Mnemonics 6
- Understanding Fees with Taproot Script Usage 3
- Can You Prune Bitcoin Core Data by Date Range? 4
- Best Hardware Specs for Running Bitcoin Core 7