Bitcoin Forum
April 26, 2024, 05:31:50 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Looking for code for recovering keys with missing characters  (Read 279 times)
Coding Enthusiast (OP)
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
September 13, 2019, 09:10:46 AM
Merited by LoyceV (4), hugeblack (3), o_e_l_e_o (2), bones261 (2), BitMaxz (1), ABCbits (1), aundroid (1)
 #1

Recently I started working on a new project called The FinderOuter1 and whenever I implement an algorithm, I go around comparing it with others to see how others have tackled it compared to my approach. Unfortunately in this case I could only find 2 solution (1 & 2) and both are simple loops, not exactly the best approach.

So if you know of any code that could recover something like the following, please post it here:
Code:
5HueCGU*rMjxEXxi*uD5*Dku*MkF*eZyd4dZ1jvhTVqvbTLvyTJ
Example is from bitcoin wiki

Alternatively if you have done this in the past and have any benchmark (the time it took to find the correct key) please post your time here for comparison.

Sneak peek of what I'm building in pure c# (1.25 million/sec is with core i3 CPU):



1. Name is inspired by the TV show called Futurama

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
1714109510
Hero Member
*
Offline Offline

Posts: 1714109510

View Profile Personal Message (Offline)

Ignore
1714109510
Reply with quote  #2

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

Posts: 1714109510

View Profile Personal Message (Offline)

Ignore
1714109510
Reply with quote  #2

1714109510
Report to moderator
1714109510
Hero Member
*
Offline Offline

Posts: 1714109510

View Profile Personal Message (Offline)

Ignore
1714109510
Reply with quote  #2

1714109510
Report to moderator
HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
September 20, 2019, 10:57:57 PM
 #2

Have you considered using "random" combinations of missing characters as opposed to simply looping through the character sets sequentially?

I believe this would be much like the approach that "VanityGen" takes, where it just randomly generates a key and tests to see if it matches your desired prefix... You could randomly generate the missing characters and test if it results in a valid key etc.

I'm sure that there is all sorts of mathematical theory that is waaaayyyyy above anything I've ever been inclined to study that would predict which method is the more efficient.

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
bob123
Legendary
*
Offline Offline

Activity: 1624
Merit: 2481



View Profile WWW
September 20, 2019, 11:19:17 PM
 #3

Have you considered using "random" combinations of missing characters as opposed to simply looping through the character sets sequentially?

Just using random combinations would most probably be less efficient.

He would need to store the characters which were already tested to not test the same one twice or even more often.
And if he does that, i doubt he would gain anything compared to simply iterating through the whole charset.

HCP
Legendary
*
Offline Offline

Activity: 2086
Merit: 4316

<insert witty quote here>


View Profile
September 21, 2019, 12:29:10 AM
 #4

Yeah, but Maths can "surprise" you sometimes...

For instance, imagine trying to bruteforce a 4 digit combination of "9361"... going sequentially through all digits from 0-9... you're going to test 9362 iterations before you find the right one. Now imagine what the odds are of randomly generating 9361 if generating these combinations randomly... 0.1^4 right?

Now... what happens if the 4 digit combination was "0101"? You're only going to need 102 iterations... but the odds of randomly finding it are still 0.1^4...

So what are the odds of sequentially searching is faster than random? Huh Apparently, statisically, it makes no difference...

I suspect the more efficient method is dependent on a number of factors like the "randomness" of the combination you're looking for, the total size of the search space and how much time is required to generate and/or test each combination? But like I said... this is getting into some serious probability theory etc that confuses me these days Tongue

█████████████████████████
████▐██▄█████████████████
████▐██████▄▄▄███████████
████▐████▄█████▄▄████████
████▐█████▀▀▀▀▀███▄██████
████▐███▀████████████████
████▐█████████▄█████▌████
████▐██▌█████▀██████▌████
████▐██████████▀████▌████
█████▀███▄█████▄███▀█████
███████▀█████████▀███████
██████████▀███▀██████████
█████████████████████████
.
BC.GAME
▄▄░░░▄▀▀▄████████
▄▄▄
██████████████
█████░░▄▄▄▄████████
▄▄▄▄▄▄▄▄▄██▄██████▄▄▄▄████
▄███▄█▄▄██████████▄████▄████
███████████████████████████▀███
▀████▄██▄██▄░░░░▄████████████
▀▀▀█████▄▄▄███████████▀██
███████████████████▀██
███████████████████▄██
▄███████████████████▄██
█████████████████████▀██
██████████████████████▄
.
..CASINO....SPORTS....RACING..
█░░░░░░█░░░░░░█
▀███▀░░▀███▀░░▀███▀
▀░▀░░░░▀░▀░░░░▀░▀
░░░░░░░░░░░░
▀██████████
░░░░░███░░░░
░░█░░░███▄█░░░
░░██▌░░███░▀░░██▌
░█░██░░███░░░█░██
░█▀▀▀█▌░███░░█▀▀▀█▌
▄█▄░░░██▄███▄█▄░░▄██▄
▄███▄
░░░░▀██▄▀


▄▄████▄▄
▄███▀▀███▄
██████████
▀███▄░▄██▀
▄▄████▄▄░▀█▀▄██▀▄▄████▄▄
▄███▀▀▀████▄▄██▀▄███▀▀███▄
███████▄▄▀▀████▄▄▀▀███████
▀███▄▄███▀░░░▀▀████▄▄▄███▀
▀▀████▀▀████████▀▀████▀▀
Coding Enthusiast (OP)
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
September 21, 2019, 04:46:37 AM
 #5

I believe this would be much like the approach that "VanityGen" takes, where it just randomly generates a key and tests to see if it matches your desired prefix... You could randomly generate the missing characters and test if it results in a valid key etc.

Usually when randomness is involved in an algorithm, the first step is random not the subsequent ones, and there is a relationship between these steps. There is also a chance of failure in such algorithms which means you have to go back to first step and choose another random first step. Example: Pollard's kangaroo algorithm, you "hop" around based on the first random entry point.
I am not familiar with how Vanitygen works but most probably the only reason for choosing a random key for its starting point is because the final result must be random and if it starts from anything not-random, the result could be reproduced and that makes the whole thing useless. Besides, that code is looking for collision in a very small space which is not more than a couple of bytes depending on the number of characters you chose so you have many possible results. But here we are looking for a single needle in a haystack.

What you said, could work if and only if there were some rules for going from key1 (the random key) to key2 apart from iteration (+=1) which means the only way of implementing something like this is to randomize the entry point and do the same thing from there. Anything other than that (eg. choosing a random combination each step) has the potential of increasing the chance of not finding the result ever since you'd be shooting in the dark.

Hint: the trick in optimization of something like this is going through all cases but not-repeating things you have already done. A simple loop over 656 mil+ would have taken about 20 minutes.

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
prix
Hero Member
*****
Offline Offline

Activity: 750
Merit: 511


View Profile
September 21, 2019, 05:05:41 AM
 #6

Yeah, but Maths can "surprise" you sometimes...
For instance, imagine trying to bruteforce a 4 digit combination of "9361"... going sequentially through all digits from 0-9... you're going to test 9362 iterations before you find the right one. Now imagine what the odds are of randomly generating 9361 if generating these combinations randomly... 0.1^4 right?
Now... what happens if the 4 digit combination was "0101"? You're only going to need 102 iterations... but the odds of randomly finding it are still 0.1^4...

I don't see any suprise here. In both cases, you have to do 5000 checks on a large data set if each value will be generated only once. But you cannot force the generator to generate only unique values, so, additional overheads arise, associated either with the storage of already tested combinations, or with the re-verification of already tested ones. With a random number generator you will need to do 10000 generations on average.
Therefore, in this case, the best method is iteration.
Coding Enthusiast (OP)
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
October 14, 2019, 11:16:57 AM
 #7

I'm not sure when I'll be able to release the application itself, right now I'm looking into parallel programming and it is proving to be harder than I thought.
If you are interested in seeing the algorithm and have any feedback on it or any idea about parallelizing it you can check it out here: https://gist.github.com/Coding-Enthusiast/1a88a9c04a987b624bf33dee6765a635 (extra checks and report generator methods are removed)
The only thing missing is the code is the case when checksum is unknown (generate more than one result) and the code for Sha256 class which is pretty basic permutation function used in SHA algorithms without any intrinsics (ie. it is highly optimized but it has room to be optimized more).

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
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!