Bitcoin Forum
May 03, 2024, 02:24:27 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: bit range of a private key  (Read 144 times)
yoshimitsu777 (OP)
Newbie
*
Offline Offline

Activity: 72
Merit: 0


View Profile
January 05, 2023, 05:21:18 AM
Last edit: January 05, 2023, 01:27:12 PM by yoshimitsu777
 #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
1714746267
Hero Member
*
Offline Offline

Posts: 1714746267

View Profile Personal Message (Offline)

Ignore
1714746267
Reply with quote  #2

1714746267
Report to moderator
1714746267
Hero Member
*
Offline Offline

Posts: 1714746267

View Profile Personal Message (Offline)

Ignore
1714746267
Reply with quote  #2

1714746267
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714746267
Hero Member
*
Offline Offline

Posts: 1714746267

View Profile Personal Message (Offline)

Ignore
1714746267
Reply with quote  #2

1714746267
Report to moderator
1714746267
Hero Member
*
Offline Offline

Posts: 1714746267

View Profile Personal Message (Offline)

Ignore
1714746267
Reply with quote  #2

1714746267
Report to moderator
witcher_sense
Legendary
*
Offline Offline

Activity: 2338
Merit: 4316

🔐BitcoinMessage.Tools🔑


View Profile WWW
January 05, 2023, 06: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'))

█▀▀▀











█▄▄▄
▀▀▀▀▀▀▀▀▀▀▀
e
▄▄▄▄▄▄▄▄▄▄▄
█████████████
████████████▄███
██▐███████▄█████▀
█████████▄████▀
███▐████▄███▀
████▐██████▀
█████▀█████
███████████▄
████████████▄
██▄█████▀█████▄
▄█████████▀█████▀
███████████▀██▀
████▀█████████
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
c.h.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀█











▄▄▄█
▄██████▄▄▄
█████████████▄▄
███████████████
███████████████
███████████████
███████████████
███░░█████████
███▌▐█████████
█████████████
███████████▀
██████████▀
████████▀
▀██▀▀
PowerGlove
Hero Member
*****
hacker
Offline Offline

Activity: 510
Merit: 4001



View Profile
January 05, 2023, 06:47:43 AM
Merited by ABCbits (1), witcher_sense (1)
 #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
yoshimitsu777 (OP)
Newbie
*
Offline Offline

Activity: 72
Merit: 0


View Profile
January 05, 2023, 01:27:32 PM
 #4

fantastic - thank you
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!