NotATether
Legendary
Offline
Activity: 1610
Merit: 6752
bitcoincleanup.com / bitmixlist.org
|
|
August 08, 2021, 11:24:31 AM |
|
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: min_range = 0x800000000000000000000000000000 max_range = 0x1000000000000000000000000000000 # autoconverts to int print(hex(max_range-min_range)) # 0x7fffffffffffffffffffffffffffff
|
. .BLACKJACK ♠ FUN. | | | ███▄██████ ██████████████▀ ████████████ █████████████████ ████████████████▄▄ ░█████████████▀░▀▀ ██████████████████ ░██████████████ █████████████████▄ ░██████████████▀ ████████████ ███████████████░██ ██████████ | | CRYPTO CASINO & SPORTS BETTING | | │ | | │ | ▄▄███████▄▄ ▄███████████████▄ ███████████████████ █████████████████████ ███████████████████████ █████████████████████████ █████████████████████████ █████████████████████████ ███████████████████████ █████████████████████ ███████████████████ ▀███████████████▀ ███████████████████ | | .
|
|
|
|
ssxb
Jr. Member
Offline
Activity: 81
Merit: 2
|
|
August 08, 2021, 11:27:22 AM |
|
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: 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
Activity: 1610
Merit: 6752
bitcoincleanup.com / bitmixlist.org
|
|
August 08, 2021, 11:35:31 AM |
|
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: ffffffffffffffffffffffffffffff and not: 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
Activity: 81
Merit: 2
|
|
August 08, 2021, 11:41:47 AM |
|
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: ffffffffffffffffffffffffffffff and not: 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
|
|
|
|
ssxb
Jr. Member
Offline
Activity: 81
Merit: 2
|
|
August 09, 2021, 06:07:25 AM |
|
Just silly question 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
Activity: 1610
Merit: 6752
bitcoincleanup.com / bitmixlist.org
|
|
August 09, 2021, 06:13:24 AM |
|
Just silly question 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
Activity: 81
Merit: 2
|
|
August 09, 2021, 10:53:49 AM |
|
can some one please let me know meaning of this line 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
|
|
|
|
NotATether
Legendary
Offline
Activity: 1610
Merit: 6752
bitcoincleanup.com / bitmixlist.org
|
|
August 09, 2021, 12:07:59 PM |
|
can some one please let me know meaning of this line 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 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
Activity: 38
Merit: 1
|
|
August 09, 2021, 02:45:06 PM |
|
Just silly question 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
Activity: 1610
Merit: 6752
bitcoincleanup.com / bitmixlist.org
|
|
August 09, 2021, 03:04:23 PM |
|
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 ) 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
|
|
August 09, 2021, 03:20:13 PM |
|
In that case this should do the trick: EDIT NUMBER 3: THIS VERSION ACTUALLY WORKS USE THIS ONE 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 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 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
Activity: 1610
Merit: 6752
bitcoincleanup.com / bitmixlist.org
|
|
August 09, 2021, 03:48:21 PM |
|
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?
|
. .BLACKJACK ♠ FUN. | | | ███▄██████ ██████████████▀ ████████████ █████████████████ ████████████████▄▄ ░█████████████▀░▀▀ ██████████████████ ░██████████████ █████████████████▄ ░██████████████▀ ████████████ ███████████████░██ ██████████ | | CRYPTO CASINO & SPORTS BETTING | | │ | | │ | ▄▄███████▄▄ ▄███████████████▄ ███████████████████ █████████████████████ ███████████████████████ █████████████████████████ █████████████████████████ █████████████████████████ ███████████████████████ █████████████████████ ███████████████████ ▀███████████████▀ ███████████████████ | | .
|
|
|
|
studyroom1
Jr. Member
Offline
Activity: 40
Merit: 7
|
|
August 09, 2021, 06:53:15 PM |
|
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 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
Activity: 81
Merit: 2
|
|
August 10, 2021, 03:01:48 AM |
|
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 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
Activity: 81
Merit: 2
|
|
August 10, 2021, 05:48:52 AM Last edit: August 10, 2021, 06:52:03 AM by ssxb |
|
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 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
Activity: 1610
Merit: 6752
bitcoincleanup.com / bitmixlist.org
|
|
August 10, 2021, 10:21:05 AM Last edit: October 05, 2021, 10:10:04 AM by NotATether |
|
~snip
You should put both with statements on a single line so you can read them both at the same time: #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
Activity: 81
Merit: 2
|
|
August 11, 2021, 04:57:27 AM |
|
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
Activity: 1610
Merit: 6752
bitcoincleanup.com / bitmixlist.org
|
|
August 11, 2021, 08:18:14 AM |
|
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 | | │ | | │ | ▄▄███████▄▄ ▄███████████████▄ ███████████████████ █████████████████████ ███████████████████████ █████████████████████████ █████████████████████████ █████████████████████████ ███████████████████████ █████████████████████ ███████████████████ ▀███████████████▀ ███████████████████ | | .
|
|
|
|
|
studyroom1
Jr. Member
Offline
Activity: 40
Merit: 7
|
|
August 14, 2021, 04:15:00 AM Last edit: August 14, 2021, 04:50:33 AM by studyroom1 Merited by ABCbits (3), NotATether (3) |
|
i have a script to convert compressed keys to uncompressed 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. 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
|
|
|
|
|