Author

Topic: bit range of a private key (Read 144 times)

newbie
Activity: 72
Merit: 0
January 05, 2023, 09:27:32 AM
#4
fantastic - thank you
hero member
Activity: 510
Merit: 4005
January 05, 2023, 02:47:43 AM
#3
I think this is what you're after:

Code:
def get_bit_length(value: int) -> int:

    return len(bin(value)[2:])

def print_bit_range(value: int, *, inclusive: bool = False) -> None:

    bit_length = get_bit_length(value)

    print(f'Range {bit_length}: {hex(2**(bit_length-1))[2:]}-{hex(2**bit_length - (1 if inclusive else 0))[2:]}')

print_bit_range(0x1A9FF47)

Range 25: 1000000-2000000
legendary
Activity: 2310
Merit: 4313
🔐BitcoinMessage.Tools🔑
January 05, 2023, 02:17:14 AM
#2
example input bit range 25 - output = 100000:200000
Excuse my ignorance, what formula do you use to calculate these values? Why 25 bits are in range 100000-200000?

As for number of bits, you can use this:

Code:
def eval_bit(key):
    return len(f'{int(key, 16):b}')


print(eval_bit('1A9FF47'))
newbie
Activity: 72
Merit: 0
January 05, 2023, 01:21:18 AM
#1
if you have some private key how can i quickly find out which bit range this key is in?

example private key 1A9FF47

i know it is inside bit range 25 (1000000 - 2000000) but is the any python tool that allows to quickly display this?
if tool also possible to display the range after input of bit range would be great

example input bit range 25 - output = 1000000:2000000

edit: range corrected
Jump to: