Pages:
Author

Topic: Python HEX generator Range based (Read 388 times)

legendary
Activity: 1456
Merit: 1174
Always remember the cause!
April 28, 2021, 03:40:12 AM
#27
My bad, I read the OPs original post and he said he had the public keys; maybe he misspoke? Because with public keys or the address, one can use other programs.  Even if address only, still wouldn't take long. In your example, I could solve with address only in a few seconds.

(From OP)
Quote
I have the Public Keys so i try this script, maybe it exist a better solution !?

Yes I do have his public key too.

But if I can't verify that he gave me the correctly spelled private key then I won't even be able to Pollard's Kangaroo it (so far it finds nothing). I should probably ask for a photo of paper PK just to verify.

Will send it to you when the 2 msg per day expired.
Send it to me as well Wink
newbie
Activity: 11
Merit: 2
April 27, 2021, 01:49:55 PM
#26
My bad, I read the OPs original post and he said he had the public keys; maybe he misspoke? Because with public keys or the address, one can use other programs.  Even if address only, still wouldn't take long. In your example, I could solve with address only in a few seconds.

(From OP)
Quote
I have the Public Keys so i try this script, maybe it exist a better solution !?

Yes I do have his public key too.

But if I can't verify that he gave me the correctly spelled private key then I won't even be able to Pollard's Kangaroo it (so far it finds nothing). I should probably ask for a photo of paper PK just to verify.

Will send it to you when the 2 msg per day expired.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
April 27, 2021, 01:19:06 PM
#25
My bad, I read the OPs original post and he said he had the public keys; maybe he misspoke? Because with public keys or the address, one can use other programs.  Even if address only, still wouldn't take long. In your example, I could solve with address only in a few seconds.

(From OP)
Quote
I have the Public Keys so i try this script, maybe it exist a better solution !?

Yes I do have his public key too.

But if I can't verify that he gave me the correctly spelled private key then I won't even be able to Pollard's Kangaroo it (so far it finds nothing). I should probably ask for a photo of paper PK just to verify.
legendary
Activity: 1456
Merit: 1174
Always remember the cause!
April 27, 2021, 05:26:13 AM
#24
Instead I'd do something like this:
Code:
//This is coded for python 2.5+

from pybitcoin import BitcoinPrivateKey

// check the repository here
//                                                 https://github.com/blockstack/pybitcoin


    start =  long(someValueHex)
    stop  =  long( biggerValueHex)
    target = long(targetPubKeyHex)
    def generate (s,e):
        while s <= e:
            yield s  //it is a generator rather than an ordinary function
            s  += 1
        yield  0

    def searchForTarget:
        candid = generate(start, stop)
        while true:
            pk = next(candid)
            if pk == 0:
                print("Exhausted the search space, sorry, no good news :( " )
                break
            private_key = BitcoinPrivateKey(pk)
            public_key = privatekey.publickey()
            if public_key == target:
                hex_private_key = private_key.toHex();
                print("FOUND! :) /n %s" , %hex_private_key)
                break
If that is what OP was really wanting, versus priv keys he can feed to some program to do the conversion, then I would not use pybitcoin; using it is a lot slower than other ways. When I ran tests, generating random private keys and converting them all the way down to BTC address, pybitcoin was 2.5 times slower on python 2.7
Slower than what? Are you suggesting implementing the lib for Python from scratch?
full member
Activity: 1162
Merit: 237
Shooters Shoot...
April 27, 2021, 03:57:43 AM
#23
Ok, that might seem like a lot for your program, the FinderOuter, but I could check 5.8 billion in seconds.
Then you are more skilled than I.
But please note that the check here is against an address not a public key so algorithms such as Pollard Kangaroos, and Baby Step Giant Step can't work.

just telling how long it would take for you to find it with a slower program?  Who knows...
I'm not just reporting the time, I'm offering an existing solution and in case it wasn't clear the link to FinderOuter is found in my signature.
Announcement: https://bitcointalksearch.org/topic/the-finderouter-a-bitcoin-recovery-tool-v0160-2022-09-19-5214021
Source code: https://github.com/Coding-Enthusiast/FinderOuter

My bad, I read the OPs original post and he said he had the public keys; maybe he misspoke? Because with public keys or the address, one can use other programs.  Even if address only, still wouldn't take long. In your example, I could solve with address only in a few seconds.

(From OP)
Quote
I have the Public Keys so i try this script, maybe it exist a better solution !?
legendary
Activity: 1040
Merit: 2785
Bitcoin and C♯ Enthusiast
April 27, 2021, 03:56:15 AM
#22
Ok, that might seem like a lot for your program, the FinderOuter, but I could check 5.8 billion in seconds.
Then you are more skilled than I.
But please note that the check here is against an address not a public key so algorithms such as Pollard Kangaroos, and Baby Step Giant Step can't work.

just telling how long it would take for you to find it with a slower program?  Who knows...
I'm not just reporting the time, I'm offering an existing solution and in case it wasn't clear the link to FinderOuter is found in my signature.
Announcement: https://bitcointalksearch.org/topic/the-finderouter-a-bitcoin-recovery-tool-v0160-2022-09-19-5214021
Source code: https://github.com/Coding-Enthusiast/FinderOuter
full member
Activity: 1162
Merit: 237
Shooters Shoot...
April 27, 2021, 03:41:52 AM
#21
11 characters at the end? Should take seconds, not hours or days.
It depends on whether the key is compressed or uncompressed. For a compressed key you have to check about 22 million while for an uncompressed key the number is 5.8 billion.
           // Numbers are approximates, values usually are ±1
            //         Uncompressed ;     Compressed
            // 1-5 ->             1 ;              1
            // 6   ->             9 ;              1
            // 7   ->           514 ;              3
            // 8   ->        29,817 ;            117
            // 9   ->     1,729,387 ;          6,756
            // 10  ->   100,304,420 ;        391,815
            // 11  -> 5,817,656,406 ;     22,725,222
            // 12  ->               ;  1,318,062,780


For the first case it takes about 2 minutes to check all the keys using FinderOuter


Ok, that might seem like a lot for your program, the FinderOuter, but I could check 5.8 billion in seconds.  It's like people want to make finding 11 missing characters from the end harder, or only use a program that they know or have used before. Now all I can wonder is why the merit for you, for just telling how long it would take for you to find it with a slower program?  Who knows...
legendary
Activity: 1040
Merit: 2785
Bitcoin and C♯ Enthusiast
April 26, 2021, 11:59:07 PM
#20
11 characters at the end? Should take seconds, not hours or days.
It depends on whether the key is compressed or uncompressed. For a compressed key you have to check about 22 million while for an uncompressed key the number is 5.8 billion.
            // Numbers are approximates, values usually are ±1
            //         Uncompressed ;     Compressed
            // 1-5 ->             1 ;              1
            // 6   ->             9 ;              1
            // 7   ->           514 ;              3
            // 8   ->        29,817 ;            117
            // 9   ->     1,729,387 ;          6,756
            // 10  ->   100,304,420 ;        391,815
            // 11  -> 5,817,656,406 ;     22,725,222
            // 12  ->               ;  1,318,062,780


For the first case it takes about 2 minutes to check all the keys using FinderOuter
full member
Activity: 1162
Merit: 237
Shooters Shoot...
April 26, 2021, 10:12:01 PM
#19
A few points that folks overlooked in this thread:

1- Iterating from start to end requires an addition, i.e. 256 bit addition.
From the programmer's perspective Python handles 256 bits integers trivially but python 2.5+ requires such variable to be defined as long explicitly, and it is good to know that we are not dealing with a one-cycle operation.
2- It looks that once the production of the output file is finished the journey is just started as OP wants to read this file and produce the corresponding public key for each row, comparing it with his target, so we need multiplication and modulo operations, it raises again performance issues. It is why we should use cryptographically optimized libraries wherever possible.

3-I think, generating a file firstly then feeding it to another python script as input for some computations is not the smartest plan for this use case,  especially when we are talking Pythonic  Wink

Instead I'd do something like this:
Code:
//This is coded for python 2.5+

from pybitcoin import BitcoinPrivateKey

// check the repository here
//                                                 https://github.com/blockstack/pybitcoin


    start =  long(someValueHex)
    stop  =  long( biggerValueHex)
    target = long(targetPubKeyHex)
    def generate (s,e):
        while s <= e:
            yield s  //it is a generator rather than an ordinary function
            s  += 1
        yield  0

    def searchForTarget:
        candid = generate(start, stop)
        while true:
            pk = next(candid)
            if pk == 0:
                print("Exhausted the search space, sorry, no good news :( " )
                break
            private_key = BitcoinPrivateKey(pk)
            public_key = privatekey.publickey()
            if public_key == target:
                hex_private_key = private_key.toHex();
                print("FOUND! :) /n %s" , %hex_private_key)
                break
If that is what OP was really wanting, versus priv keys he can feed to some program to do the conversion, then I would not use pybitcoin; using it is a lot slower than other ways. When I ran tests, generating random private keys and converting them all the way down to BTC address, pybitcoin was 2.5 times slower on python 2.7
legendary
Activity: 1456
Merit: 1174
Always remember the cause!
April 26, 2021, 07:39:24 PM
#18
A few points that folks overlooked in this thread:

1- Iterating from start to end requires an addition, i.e. 256 bit addition.
From the programmer's perspective Python handles 256 bits integers trivially but python 2.5+ requires such variable to be defined as long explicitly, and it is good to know that we are not dealing with a one-cycle operation.
2- It looks that once the production of the output file is finished the journey is just started as OP wants to read this file and produce the corresponding public key for each row, comparing it with his target, so we need multiplication and modulo operations, it raises again performance issues. It is why we should use cryptographically optimized libraries wherever possible.

3-I think, generating a file firstly then feeding it to another python script as input for some computations is not the smartest plan for this use case,  especially when we are talking Pythonic  Wink

Instead I'd do something like this:
Code:
//This is coded for python 2.5+

from pybitcoin import BitcoinPrivateKey

// check the repository here
//                                                 https://github.com/blockstack/pybitcoin


    start =  long(someValueHex)
    stop  =  long( biggerValueHex)
    target = long(targetPubKeyHex)
    def generate (s,e):
        while s <= e:
            yield s  //it is a generator rather than an ordinary function
            s  += 1
        yield  0

    def searchForTarget:
        candid = generate(start, stop)
        while true:
            pk = next(candid)
            if pk == 0:
                print("Exhausted the search space, sorry, no good news :( " )
                break
            private_key = BitcoinPrivateKey(pk)
            public_key = privatekey.publickey()
            if public_key == target:
                hex_private_key = private_key.toHex();
                print("FOUND! :) /n %s" , %hex_private_key)
                break
full member
Activity: 1162
Merit: 237
Shooters Shoot...
April 26, 2021, 02:09:52 PM
#17
@NotATether, you told me in pm the PK, with missing letters, is in a range of xxx and xxxxx so maybe i can search it this way.

Yes but you see, it is more efficient to use the WifSolver program by @PawGo for problems like this, because something you write by hand may not be fully tested and not find private keys properly.

Looks like you are trying to find private key with balance... This won't work for that. This is why:

base on post history of the starter i believe he is trying to recover his own private key that is damaged and is missing a part of it. that is probably why the range looks like this.
although if starter was more clear about what he is trying to do he would also get better help.

I do have the fragment of the PK for which he's trying to recover the other part.

The range search, which has already been running for a day, should take a few more days to finish on my hardware. It's 11 chars missing including checksum.
11 characters at the end? Should take seconds, not hours or days.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
April 26, 2021, 02:05:18 PM
#16
@NotATether, you told me in pm the PK, with missing letters, is in a range of xxx and xxxxx so maybe i can search it this way.

Yes but you see, it is more efficient to use the WifSolver program by @PawGo for problems like this, because something you write by hand may not be fully tested and not find private keys properly.

Looks like you are trying to find private key with balance... This won't work for that. This is why:

base on post history of the starter i believe he is trying to recover his own private key that is damaged and is missing a part of it. that is probably why the range looks like this.
although if starter was more clear about what he is trying to do he would also get better help.

I do have the fragment of the PK for which he's trying to recover the other part.

The range search, which has already been running for a day, should take a few more days to finish on my hardware. It's 11 chars missing including checksum.



11 characters at the end? Should take seconds, not hours or days.

It will take seconds on a GPU. But there are no GPU-bound programs that take a WIF and try to complete it (Bitcrack completely misses the key in the range), so I'm stuck with a cpu-bound solver running on 48 cores.
newbie
Activity: 11
Merit: 2
April 26, 2021, 12:43:09 PM
#15
Perfect thank you !
full member
Activity: 1162
Merit: 237
Shooters Shoot...
April 26, 2021, 12:34:31 PM
#14
It look all great, and thx for all that wanna help.

Now how can i start with a from me given HEX number for example 0000000000000000000000000000000000000000000000000000251462abc584, and lets say, generate linear the next 10k HEX numbers or 20k.


I managed to do it:

Code:
import secrets
start = int('0000000000000000000000000000000000000000000000000000251462abc584',16)
stop = start + 10000
hex(secrets.choice(range(start, stop))).zfill(64)


You can change stop (10000) and start for whatever number you like

To add to txt
Code:
import secrets

path = './file.txt'
start = int('0000000000000000000000000000000000000000000000000000251462abc584',16)
stop = start + 10000

with open(path, 'w+') as f:
        f.write(hex(secrets.choice(range(start, stop))).zfill(64))

When i do this code, it gives me 00000000000000000000000000000000000000000000000000x251462abe24aL that means i have to take 00000000000000000000000000000000000000000000000000x251462abe24a, because the L is only a python "Mistake" !

But it is possible, to write all the hex, in the txt file, every in one line ... so that on 10k it generate 10k lines  linear to the start HEX number ?!

Here is how I would do it:

Code:
arq1 = open('sequentialkeys.txt', 'a')

start         = 0x0000000000000000000000000000000000000000000000000000251462abc584
increment     = 0x2710
startplusincr = start + increment
while (start < startplusincr):
    start = start+0x1
    arq1.write((hex(start)).lstrip("0x").rstrip("L").zfill(64)+'\n')

Results file looks like this:

Code:
0000000000000000000000000000000000000000000000000000251462abc585
0000000000000000000000000000000000000000000000000000251462abc586
0000000000000000000000000000000000000000000000000000251462abc587
0000000000000000000000000000000000000000000000000000251462abc588
0000000000000000000000000000000000000000000000000000251462abc589
0000000000000000000000000000000000000000000000000000251462abc58a
0000000000000000000000000000000000000000000000000000251462abc58b
0000000000000000000000000000000000000000000000000000251462abc58c
0000000000000000000000000000000000000000000000000000251462abc58d
0000000000000000000000000000000000000000000000000000251462abc58e
0000000000000000000000000000000000000000000000000000251462abc58f
0000000000000000000000000000000000000000000000000000251462abc590
0000000000000000000000000000000000000000000000000000251462abc591
0000000000000000000000000000000000000000000000000000251462abc592
0000000000000000000000000000000000000000000000000000251462abc593
0000000000000000000000000000000000000000000000000000251462abc594
0000000000000000000000000000000000000000000000000000251462abc595
0000000000000000000000000000000000000000000000000000251462abc596
0000000000000000000000000000000000000000000000000000251462abc597
0000000000000000000000000000000000000000000000000000251462abc598
0000000000000000000000000000000000000000000000000000251462abc599
0000000000000000000000000000000000000000000000000000251462abc59a
0000000000000000000000000000000000000000000000000000251462abc59b
0000000000000000000000000000000000000000000000000000251462abc59c
0000000000000000000000000000000000000000000000000000251462abc59d
0000000000000000000000000000000000000000000000000000251462abc59e
0000000000000000000000000000000000000000000000000000251462abc59f
...
0000000000000000000000000000000000000000000000000000251462abec8e
0000000000000000000000000000000000000000000000000000251462abec8f
0000000000000000000000000000000000000000000000000000251462abec90
0000000000000000000000000000000000000000000000000000251462abec91
0000000000000000000000000000000000000000000000000000251462abec92
0000000000000000000000000000000000000000000000000000251462abec93
0000000000000000000000000000000000000000000000000000251462abec94

newbie
Activity: 11
Merit: 2
April 26, 2021, 12:31:55 PM
#13
I know, Bitcoin is the perpetuum mobile, of the cryptohack.
But ... now comes the BUT, since i search the lost letters from my PK ( see this post https://bitcointalksearch.org/topic/need-help-with-python-scrict-private-key-search-5331951 ),
i read and read, try to understand and try to learn.

Maybe because i am a older generation ( C64 ... Amiga 500 ), the CONTRA REGULE thinking ( against normal rules ), is breaking through.

Why all brute force tryings go one way. Nobody thinks CONTRA REGULE, but this is another post, what i will open soon.

My biggest problem is that i cant write a script  Roll Eyes Roll Eyes Roll Eyes Roll Eyes

Big thanks for help, solving this problem here.
legendary
Activity: 2114
Merit: 1293
There is trouble abrewing
April 26, 2021, 12:11:57 PM
#12
Looks like you are trying to find private key with balance... This won't work for that. This is why:

base on post history of the starter i believe he is trying to recover his own private key that is damaged and is missing a part of it. that is probably why the range looks like this.
although if starter was more clear about what he is trying to do he would also get better help.
legendary
Activity: 2352
Merit: 6089
bitcoindata.science
April 26, 2021, 10:52:40 AM
#11
When i do this code, it gives me 00000000000000000000000000000000000000000000000000x251462abe24aL that means i have to take 00000000000000000000000000000000000000000000000000x251462abe24a, because the L is only a python "Mistake" !

I was not able to reproduce this "bug" here.

If your private keys are properly generated, they cannot be guessed or brute forced. Take a look at this infographic so you have an idea about the size of combinations:


source: https://www.reddit.com/r/Bitcoin/comments/1ohwvu/bitcoin_your_money_is_secured_by_the_laws_of_the/
newbie
Activity: 11
Merit: 2
April 26, 2021, 10:16:55 AM
#10
It look all great, and thx for all that wanna help.

Now how can i start with a from me given HEX number for example 0000000000000000000000000000000000000000000000000000251462abc584, and lets say, generate linear the next 10k HEX numbers or 20k.


I managed to do it:

Code:
import secrets
start = int('0000000000000000000000000000000000000000000000000000251462abc584',16)
stop = start + 10000
hex(secrets.choice(range(start, stop))).zfill(64)


You can change stop (10000) and start for whatever number you like

To add to txt
Code:
import secrets

path = './file.txt'
start = int('0000000000000000000000000000000000000000000000000000251462abc584',16)
stop = start + 10000

with open(path, 'w+') as f:
        f.write(hex(secrets.choice(range(start, stop))).zfill(64))

When i do this code, it gives me 00000000000000000000000000000000000000000000000000x251462abe24aL that means i have to take 00000000000000000000000000000000000000000000000000x251462abe24a, because the L is only a python "Mistake" !

But it is possible, to write all the hex, in the txt file, every in one line ... so that on 10k it generate 10k lines  linear to the start HEX number ?!
legendary
Activity: 2352
Merit: 6089
bitcoindata.science
April 26, 2021, 09:27:16 AM
#9
It look all great, and thx for all that wanna help.

Now how can i start with a from me given HEX number for example 0000000000000000000000000000000000000000000000000000251462abc584, and lets say, generate linear the next 10k HEX numbers or 20k.


I managed to do it:

Code:
import secrets
start = int('0000000000000000000000000000000000000000000000000000251462abc584',16)
stop = start + 10000
hex(secrets.choice(range(start, stop))).zfill(64)


You can change stop (10000) and start for whatever number you like

To add to txt
Code:
import secrets

path = './file.txt'
start = int('0000000000000000000000000000000000000000000000000000251462abc584',16)
stop = start + 10000

with open(path, 'w+') as f:
        f.write(hex(secrets.choice(range(start, stop))).zfill(64))
newbie
Activity: 11
Merit: 2
April 26, 2021, 08:22:28 AM
#8
It look all great, and thx for all that wanna help.

Now how can i start with a from me given HEX number for example 0000000000000000000000000000000000000000000000000000251462abc584, and lets say, generate linear the next 10k HEX numbers or 20k.



Pages:
Jump to: