Bitcoin Forum
April 30, 2024, 06:16:35 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 ... 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 [104] 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 »
  Print  
Author Topic: Pollard's kangaroo ECDLP solver  (Read 55517 times)
NotATether
Legendary
*
Offline Offline

Activity: 1582
Merit: 6715


bitcoincleanup.com / bitmixlist.org


View Profile WWW
August 08, 2021, 11:24:31 AM
 #2061

how to calculate hex key range , i mean

120 range is

  • Min range: 800000000000000000000000000000
  • Max range: 1000000000000000000000000000000

so total search space is 7fffffffffffffffffffffffffffff . i guess

how can i calculate total range space between 2 key ranges?

It's as simple as doing max range - min range and then turning the result back into hex.

It can be done using simple Python statements:

Code:
min_range = 0x800000000000000000000000000000
max_range = 0x1000000000000000000000000000000 # autoconverts to int
print(hex(max_range-min_range))
# 0x7fffffffffffffffffffffffffffff

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
1714500995
Hero Member
*
Offline Offline

Posts: 1714500995

View Profile Personal Message (Offline)

Ignore
1714500995
Reply with quote  #2

1714500995
Report to moderator
1714500995
Hero Member
*
Offline Offline

Posts: 1714500995

View Profile Personal Message (Offline)

Ignore
1714500995
Reply with quote  #2

1714500995
Report to moderator
1714500995
Hero Member
*
Offline Offline

Posts: 1714500995

View Profile Personal Message (Offline)

Ignore
1714500995
Reply with quote  #2

1714500995
Report to moderator
Each block is stacked on top of the previous one. Adding another block to the top makes all lower blocks more difficult to remove: there is more "weight" above each block. A transaction in a block 6 blocks deep (6 confirmations) will be very difficult to remove.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714500995
Hero Member
*
Offline Offline

Posts: 1714500995

View Profile Personal Message (Offline)

Ignore
1714500995
Reply with quote  #2

1714500995
Report to moderator
1714500995
Hero Member
*
Offline Offline

Posts: 1714500995

View Profile Personal Message (Offline)

Ignore
1714500995
Reply with quote  #2

1714500995
Report to moderator
ssxb
Jr. Member
*
Offline Offline

Activity: 81
Merit: 2


View Profile
August 08, 2021, 11:27:22 AM
 #2062

how to calculate hex key range , i mean

120 range is

  • Min range: 800000000000000000000000000000
  • Max range: 1000000000000000000000000000000

so total search space is 7fffffffffffffffffffffffffffff . i guess

how can i calculate total range space between 2 key ranges?

It's as simple as doing max range - min range and then turning the result back into hex.

It can be done using simple Python statements:

Code:
min_range = 0x800000000000000000000000000000
max_range = 0x1000000000000000000000000000000 # autoconverts to int
print(hex(max_range-min_range))
# 0x7fffffffffffffffffffffffffffff


i used exact way but i am getting 0x800000000000000000000000000000 ?
 not sure what is wrong or some thing is missing , even with your code it is giving me same out put

"0x800000000000000000000000000000"

can you run on your side please ?
NotATether
Legendary
*
Offline Offline

Activity: 1582
Merit: 6715


bitcoincleanup.com / bitmixlist.org


View Profile WWW
August 08, 2021, 11:35:31 AM
 #2063

i used exact way but i am getting 0x800000000000000000000000000000 ?
 not sure what is wrong or some thing is missing , even with your code it is giving me same out put

"0x800000000000000000000000000000"

can you run on your side please ?

Same result here. It's because you have an off-by-one error. The max range should be:

Code:
ffffffffffffffffffffffffffffff 

and not:

Code:
1000000000000000000000000000000

because the largest private key that fits 120 bits is the ffff.... number, the 1000.... number requires 121 bits to fit (all bits will be zero except for the 121st bit which is one).

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
ssxb
Jr. Member
*
Offline Offline

Activity: 81
Merit: 2


View Profile
August 08, 2021, 11:41:47 AM
 #2064

i used exact way but i am getting 0x800000000000000000000000000000 ?
 not sure what is wrong or some thing is missing , even with your code it is giving me same out put

"0x800000000000000000000000000000"

can you run on your side please ?

Same result here. It's because you have an off-by-one error. The max range should be:

Code:
ffffffffffffffffffffffffffffff 

and not:

Code:
1000000000000000000000000000000

because the largest private key that fits 120 bits is the ffff.... number, the 1000.... number requires 121 bits to fit (all bits will be zero except for the 121st bit which is one).

cool , that was the issue now i got it , Thanks bro , you deserve share from my side if i hit the key hehehehe Sad
ssxb
Jr. Member
*
Offline Offline

Activity: 81
Merit: 2


View Profile
August 09, 2021, 06:07:25 AM
 #2065

Just silly question  Grin

is it possible to know this public key is from this range? like 110 or 115?

is there any way to identify?
NotATether
Legendary
*
Offline Offline

Activity: 1582
Merit: 6715


bitcoincleanup.com / bitmixlist.org


View Profile WWW
August 09, 2021, 06:13:24 AM
 #2066

Just silly question  Grin

is it possible to know this public key is from this range? like 110 or 115?

is there any way to identify?

No, otherwise you would be able to find the upper bits of every private key in existence.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
ssxb
Jr. Member
*
Offline Offline

Activity: 81
Merit: 2


View Profile
August 09, 2021, 10:53:49 AM
 #2067

  can some one please let me know meaning of this line
Code:
y = bit.format.x_to_y(x, int(pub_hex[:2], 16) % 2)
in my understanding
it is saying Y = change x value to Y in binary or multiply pub_hex bla bla . really confusing

 Roll Eyes
NotATether
Legendary
*
Offline Offline

Activity: 1582
Merit: 6715


bitcoincleanup.com / bitmixlist.org


View Profile WWW
August 09, 2021, 12:07:59 PM
 #2068

 can some one please let me know meaning of this line
Code:
y = bit.format.x_to_y(x, int(pub_hex[:2], 16) % 2)
in my understanding
it is saying Y = change x value to Y in binary or multiply pub_hex bla bla . really confusing

 Roll Eyes


It just calculates the Y point from the X point and the polarity of Y (compressed to uncompressed public key).

The [:2] is necessary to get the "02" or "03" at the beginning so we can convert that part from hex to int, then we use "% 2" to check if it represents odd or even Y.

fastecdsa can't work with compressed points, so we have to convert them to uncompressed points first.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
batareyka
Jr. Member
*
Offline Offline

Activity: 38
Merit: 1


View Profile
August 09, 2021, 02:45:06 PM
 #2069

Just silly question  Grin

is it possible to know this public key is from this range? like 110 or 115?

is there any way to identify?

No, otherwise you would be able to find the upper bits of every private key in existence.


Hi. Can you explain how you can learn the upper bits by knowing the range?
NotATether
Legendary
*
Offline Offline

Activity: 1582
Merit: 6715


bitcoincleanup.com / bitmixlist.org


View Profile WWW
August 09, 2021, 03:04:23 PM
 #2070

Hi. Can you explain how you can learn the upper bits by knowing the range?

If you know that a key will be less than and greater than a maximum and minimum, it limits the values that the higher bits can have (else it wouldn't fit in that range, now would it  Wink)

For example, say that you know that a private key is between 115 and 120 bits long. That automatically means, since private keys are 256 numbers, that the bits after the 120th one (assume 1-based counting for simplicity) are all zero.

Because the ranges in these puzzle addresses are only ever going to be between (range-1) and range bits (i.e. that particular bit will always be set), it is straightforward to determine the higher bits that are zero or in a certain range like 0 to 4 (hex number values), 0 to C, etc. that's what makes brute-forcing possible.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
bigvito19
Full Member
***
Offline Offline

Activity: 706
Merit: 111


View Profile
August 09, 2021, 03:20:13 PM
 #2071

In that case this should do the trick:


EDIT NUMBER 3: THIS VERSION ACTUALLY WORKS USE THIS ONE

Code:
from fastecdsa import curve
from fastecdsa.point import Point
import bit

G = curve.secp256k1.G
N = curve.secp256k1.q

def pub2point(pub_hex):
    x = int(pub_hex[2:66], 16)
    if len(pub_hex) < 70:
        y = bit.format.x_to_y(x, int(pub_hex[:2], 16) % 2)
    else:
        y = int(pub_hex[66:], 16)
    return Point(x, y, curve=curve.secp256k1)



# This function makes all the downscaled pubkeys obtained from subtracting
# numbers between 0 and divisor, before dividing the pubkeys by divisor.
def shiftdown(pubkey, divisor, file, convert=True):
    Q = pub2point(pubkey) if convert else pubkey
    print(Q, 'QQ')
    # k = 1/divisor
    k = pow(divisor, N - 2, N)
    for i in range(divisor+1):
        P = Q - (i * G)
        P = k * P
        if (P.y % 2 == 0):
            prefix = "02"
        else:
            prefix = "03"
        hx = hex(P.x)[2:].zfill(64)
        hy = hex(P.y)[2:].zfill(64)
        file.write(prefix+hx+"\n") # Writes compressed key to file

factor = 32

with open("input.txt", "r") as f, open("output.txt", "w") as outf:
    line = f.readline().strip()
    while line != '':
          shiftdown(line, factor, outf)
          line = f.readline().strip()

This is for all keys in one file, I technically *could* script the case of one set of shifted keys per file, but then it requires an argc/argv switch to toggle the one you want and implementing that will bloat the code size Tongue



EDIT: I had posted an older version of the script which people complained had a bunch of errors, admittingly I did not test this version with the file input since the base script was already "bug free" I thought these should be straightforward changes... well now I know  Embarrassed

After some proper testing, I got rid of a bunch of artifacts from older script versions that were triggering lint errors, and the result is posted here, above.

What are the requirements for using this, I'm using python 3 on windows and still getting errors.
NotATether
Legendary
*
Offline Offline

Activity: 1582
Merit: 6715


bitcoincleanup.com / bitmixlist.org


View Profile WWW
August 09, 2021, 03:48:21 PM
 #2072

What are the requirements for using this, I'm using python 3 on windows and still getting errors.

Did you install fastecdsa and bit modules from PyPI first?  Huh

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
studyroom1
Jr. Member
*
Offline Offline

Activity: 40
Merit: 7


View Profile
August 09, 2021, 06:53:15 PM
 #2073

need help in python

i have 2 files and each file have 32 lines hex values
so i want to

subtract line 1 of "file1.txt" with line 1 of "file2"
subtract line 2 of "file1.txt" with line 2 of "file2"

vice versa and print  output.
i am using code like this but don't know what i am doing wrong



Code:
with open("file1.txt", "r") as f:
    line = f.readline().strip()
    while line != '':
          hex1 = f.readline().strip()

with open("file2.txt", "r") as f:
    line = f.readline().strip()
    while line != '':
          hex2 = f.readline().strip()
   
   
def add(file1.txt, file2.txt):
    P = (hex1)
    Q = (hex2)
    R = hex(P - Q)
    hx = hex(R).zfill(64)
    print(hx)
   
ssxb
Jr. Member
*
Offline Offline

Activity: 81
Merit: 2


View Profile
August 10, 2021, 03:01:48 AM
 #2074

need help in python

i have 2 files and each file have 32 lines hex values
so i want to

subtract line 1 of "file1.txt" with line 1 of "file2"
subtract line 2 of "file1.txt" with line 2 of "file2"

vice versa and print  output.
i am using code like this but don't know what i am doing wrong



Code:
with open("file1.txt", "r") as f:
    line = f.readline().strip()
    while line != '':
          hex1 = f.readline().strip()

with open("file2.txt", "r") as f:
    line = f.readline().strip()
    while line != '':
          hex2 = f.readline().strip()
   
   
def add(file1.txt, file2.txt):
    P = (hex1)
    Q = (hex2)
    R = hex(P - Q)
    hx = hex(R).zfill(64)
    print(hx)
   


i am not sure but surely @NotATether is hero here , he will help you out
ssxb
Jr. Member
*
Offline Offline

Activity: 81
Merit: 2


View Profile
August 10, 2021, 05:48:52 AM
Last edit: August 10, 2021, 06:52:03 AM by ssxb
 #2075

i managed to make this script to do the job but this one only doing subtraction for line 1 of file1 and line 1 of file2 , not doing subtraction for all lines .

maybe need to fix the code

Code:
with open("file1.txt", "r") as f1:
    line1 = f1.readline().strip()

         
def key1(line1):
    x = int(line1, 16)
    return (x)
     
     

with open("file2.txt", "r") as f2:
    line2 = f2.readline().strip()

   
def key2(line2):
    y = int(line2, 16)
    return (y)
   
def add(f1, f2):
    P = key1(line1)
    Q = key2(line2)
    R = P - Q
    hx = hex(R).zfill(64)
    print(hx+"\n")
   

add(f1, f2)
NotATether
Legendary
*
Offline Offline

Activity: 1582
Merit: 6715


bitcoincleanup.com / bitmixlist.org


View Profile WWW
August 10, 2021, 10:21:05 AM
Last edit: October 05, 2021, 10:10:04 AM by NotATether
 #2076

~snip

You should put both with statements on a single line so you can read them both at the same time:

Code:
#begin copy from my scipt
from fastecdsa import curve
from fastecdsa.point import Point
import bit

G = curve.secp256k1.G
N = curve.secp256k1.q

def pub2point(pub_hex):
    x = int(pub_hex[2:66], 16)
    if len(pub_hex) < 70:
        y = bit.format.x_to_y(x, int(pub_hex[:2], 16) % 2)
    else:
        y = int(pub_hex[66:], 16)
    return Point(x, y, curve=curve.secp256k1)


def point2pub(R):
    if (R.y % 2 == 0):
        prefix = "02"
    else:
        prefix = "03"
    hx = hex(R.x)[2:].zfill(64)
    return hx

#end copy

def sub(hex1, hex2):
    P = pub2point(hex1)
    Q = pub2point(hex2)
    R = P - Q
    return R

with open("file1.txt", "r") as f1, open("file2.txt", "r") as f2:
    line1 = f1.readline().strip()
    line2 = f2.readline().strip()
    while line1 != '' and line2 != '':
          print(point2pub(sub(line1, line2)))
          line1 = f1.readline().strip()
          line2 = f2.readline().strip()    
    


Make sure you check the indenting, especially if you are pasting this to console since it will choke the interpreter.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
ssxb
Jr. Member
*
Offline Offline

Activity: 81
Merit: 2


View Profile
August 11, 2021, 04:57:27 AM
 #2077

can some one explain x = (i * G)

so if G  = X: 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
               Y: 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8

and i    = 11B

how we will calculate x? , i was unable to understand how can we do 2 lines hex G multiplication.
NotATether
Legendary
*
Offline Offline

Activity: 1582
Merit: 6715


bitcoincleanup.com / bitmixlist.org


View Profile WWW
August 11, 2021, 08:18:14 AM
 #2078

can some one explain x = (i * G)

so if G  = X: 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
               Y: 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8

and i    = 11B

how we will calculate x? , i was unable to understand how can we do 2 lines hex G multiplication.

Basically, first you factor i in powers of two like this:

i = 11b = 3 (decimal) = 2 + 1

Then you calculate G, 2G, 4G etc using repeated point doubling and store the results (see https://en.bitcoin.it/wiki/Elliptic_curve_cryptography for the algorithm as well as the one for point addition), then you use point addition add these results depending on the factors of i above.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
bigvito19
Full Member
***
Offline Offline

Activity: 706
Merit: 111


View Profile
August 13, 2021, 11:08:58 PM
 #2079

What are the requirements for using this, I'm using python 3 on windows and still getting errors.

Did you install fastecdsa and bit modules from PyPI first?  Huh

I finally got it to work for me, you're code, this one https://gist.github.com/ZenulAbidin/286a652b160086b3b0f184a886ba68ca
studyroom1
Jr. Member
*
Offline Offline

Activity: 40
Merit: 7


View Profile
August 14, 2021, 04:15:00 AM
Last edit: August 14, 2021, 04:50:33 AM by studyroom1
Merited by ABCbits (3), NotATether (3)
 #2080

i have a script to convert compressed keys to uncompressed

Code:
import binascii

p_hex = 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFC2F'
p = int(p_hex, 16)
compressed_key_hex = '0250863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B2352'
x_hex = compressed_key_hex[2:66]
x = int(x_hex, 16)
prefix = compressed_key_hex[0:2]

y_square = (pow(x, 3, p)  + 7) % p
y_square_square_root = pow(y_square, (p+1)/4, p)
if (prefix == "02" and y_square_square_root & 1) or (prefix == "03" and not y_square_square_root & 1):
    y = (-y_square_square_root) % p
else:
    y = y_square_square_root

computed_y_hex = format(y, '064x')
computed_uncompressed_key = "04" + x_hex + computed_y_hex

print computed_uncompressed_key

 but i need script where i can convert uncompressed keys to compressed

i guess that will be pretty simple to make as we need to take x value and add 02 or 03 in front of x. right?

but need working code where i can upload file of uncompressed keys and get all compressed keys :p

edit:

i wrote these code to convert uncompressed to compress but output file is blank.

Code:
from fastecdsa import curve
from fastecdsa.point import Point
import bit

G = curve.secp256k1.G
N = curve.secp256k1.q

def pub2point(line, file):
    x = int(line[2:66], 16)
    if len(line) < 70:
        y = bit.format.x_to_y(x, int(line[:2], 16) % 2)
    else:
        y = int(line[66:], 16)
    return Point(x, y, curve=curve.secp256k1)
    if (y % 2 == 0):
        prefix = "02"
    else:
        prefix = "03"
        hx = hex(x)[2:].zfill(64)
        hy = hex(y)[2:].zfill(64)
        file.write(prefix+hx+"\n") # Writes compressed key to file    
    

    
with open("1.txt", "r") as f, open("output.txt", "w") as outf:
    line = f.readline().strip()
    while line != '':
          pub2point(line, outf)
          line = f.readline().strip()

i guess something is missing or i am doing it wrong
Pages: « 1 ... 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 [104] 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 »
  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!