I don't have your C module, but shouldn't you check for the lowest and highest valid address? Replacing the remaining base58 characters with ones and z's doesn't make the address valid, because of the checksum.
Guys this is an example, the Checkcum or validity doesn't is important for the lowest and highes addresses
I only use those values as limits, when i compare if the current hash I omit the prefix 00 byte and the postfix checksum bytes.
Example:
Target base58: 1Bitcoin
Lower limit base 58: 1Bitcoin11111111111111111111111111
Higher limit base 58: 1Bitcoinzzzzzzzzzzzzzzzzzzzzzzzzzz
Lower limit rmd160: 00759d667708d463667bab9e23c1b83761d6c71dcd3c000000
Higher limit rmd160: 00759d66770a11348c6dc1fda8d293dbc1dec867d5dfffffff
Current Address: 1Bitcoin873Ns4mSAVnUn1eD43RBq89vqo
current hashrmd: 00759d667708fb31996328d15f3056d190278a1bb57dc660b2
(Lower Limit) <= (Current HASH) <= (Higher Limit)
For this case will be:
759d667708d463667bab9e23c1b83761d6c71dcd<= 759d667708fb31996328d15f3056d190278a1bb5 <= 759d66770a11348c6dc1fda8d293dbc1dec867d5
memcmp stop at the first byte with some difference so the comparation will be only like:
759d667708
d4<= 759d6677
08fb <= 759d6677
0a11So if the Current hash value is between the given limits that means the function base58_encode_checksum(00 byte +current hash) will have the Same expected Prefix for this case will be "1Bitcoin"
Have you considered how permutations work on rmd160 hashes?
...
How exactly skipping a simple base58 encoding could double the speed? Is base58 encoding heavier than hashing? If that's the case then it could change a lot of other things, I just need to think what those things could be.
About the speed that its what in practice i get when i run keyhunt for addresses and keyhunt for hashes rmd160. rmd160 search get almost the double of the speed of address search
Aboute the permutations i will check it.
I already tested and for each prefix that we search for vanity ["1Fortune", "1Prosper", "1Winner", etc...] and almost always there are two RMD ranges that generate the same Base58 prefix, so I think that i will add all those ranges to the search, it will be enough.
The next example compare one address againts some prefixes. but it can also be the other way around Many address to one or more vanity prefixes
Output:
Address 1Bitcoin873Ns4mSAVnUn1eD43RBq89vqo encode to 759d667708fb31996328d15f3056d190278a1bb5
Raw size: 25, Encoded size: 33 : expected string 1Fortune, base string 1Fortune1111111111111111111111111 => hex 0002ccf0c09d38ef18ac118453594f3bf77af9d90366000000
Raw size: 25, Encoded size: 34 : expected string 1Fortune, base string 1Fortune11111111111111111111111111 => hex 00a26e8ba39ee62b96fbf7fae23bf39611dc9b2ac51c000000
Raw size: 25, Encoded size: 33 : expected string 1Fortune, base string 1Fortunezzzzzzzzzzzzzzzzzzzzzzzzz => hex 0002ccf0c09d3e6576041abaf0203889d5d363cd0c5fffffff
Raw size: 25, Encoded size: 34 : expected string 1Fortune, base string 1Fortunezzzzzzzzzzzzzzzzzzzzzzzzzz => hex 00a26e8ba3a022fcbcee0e5a674ccf3a71e49c74cdbfffffff
The target Address 759d667708fb31996328d15f3056d190278a1bb5 NOT match bewteen the start and end range (02ccf0c09d38ef18ac118453594f3bf77af9d903 and 02ccf0c09d3e6576041abaf0203889d5d363cd0c)
The target Address 759d667708fb31996328d15f3056d190278a1bb5 NOT match bewteen the start and end range (a26e8ba39ee62b96fbf7fae23bf39611dc9b2ac5 and a26e8ba3a022fcbcee0e5a674ccf3a71e49c74cd)
Raw size: 25, Encoded size: 33 : expected string 1Prosper, base string 1Prosper1111111111111111111111111 => hex 000452ba9d1f9147e608975a8067caddeb99dbb63f06000000
Raw size: 25, Encoded size: 34 : expected string 1Prosper, base string 1Prosper11111111111111111111111111 => hex 00fabe479926ea4a1df24a811783f64760dbc74a475c000000
Raw size: 25, Encoded size: 33 : expected string 1Prosper, base string 1Prosperzzzzzzzzzzzzzzzzzzzzzzzzz => hex 000452ba9d1f96be4360a0911d2eb42bc9f245aa47ffffffff
Raw size: 25, Encoded size: 34 : expected string 1Prosper, base string 1Prosperzzzzzzzzzzzzzzzzzzzzzzzzzz => hex 00fabe479928271b43e460e09c94d1ebc0e3c8944fffffffff
The target Address 759d667708fb31996328d15f3056d190278a1bb5 NOT match bewteen the start and end range (0452ba9d1f9147e608975a8067caddeb99dbb63f and 0452ba9d1f96be4360a0911d2eb42bc9f245aa47)
The target Address 759d667708fb31996328d15f3056d190278a1bb5 NOT match bewteen the start and end range (fabe479926ea4a1df24a811783f64760dbc74a47 and fabe479928271b43e460e09c94d1ebc0e3c8944f)
Raw size: 25, Encoded size: 33 : expected string 1Winner, base string 1Winner11111111111111111111111111 => hex 00059ef26b901a66d6bda68342507cdb76d44268a9dc000000
Raw size: 25, Encoded size: 33 : expected string 1Winner, base string 1Winnerzzzzzzzzzzzzzzzzzzzzzzzzzz => hex 00059ef26b915737fcafbce2c761587fd6dc43b2b27fffffff
The target Address 759d667708fb31996328d15f3056d190278a1bb5 NOT match bewteen the start and end range (059ef26b901a66d6bda68342507cdb76d44268a9 and 059ef26b915737fcafbce2c761587fd6dc43b2b2)
Raw size: 25, Encoded size: 33 : expected string 1Bitcoin, base string 1Bitcoin1111111111111111111111111 => hex 00020720a9c6c5de6748c0c08507c0f820955bb57ab6000000
Raw size: 25, Encoded size: 34 : expected string 1Bitcoin, base string 1Bitcoin11111111111111111111111111 => hex 00759d667708d463667bab9e23c1b83761d6c71dcd3c000000
Raw size: 25, Encoded size: 33 : expected string 1Bitcoin, base string 1Bitcoinzzzzzzzzzzzzzzzzzzzzzzzzz => hex 00020720a9c6cb54c4a0c9f721ceaa45feedc5a983afffffff
Raw size: 25, Encoded size: 34 : expected string 1Bitcoin, base string 1Bitcoinzzzzzzzzzzzzzzzzzzzzzzzzzz => hex 00759d66770a11348c6dc1fda8d293dbc1dec867d5dfffffff
The target Address 759d667708fb31996328d15f3056d190278a1bb5 NOT match bewteen the start and end range (020720a9c6c5de6748c0c08507c0f820955bb57a and 020720a9c6cb54c4a0c9f721ceaa45feedc5a983)
The target Address 759d667708fb31996328d15f3056d190278a1bb5 match bewteen the start and end range (759d667708d463667bab9e23c1b83761d6c71dcd and 759d66770a11348c6dc1fda8d293dbc1dec867d5)
Raw size: 25, Encoded size: 33 : expected string 1Satoshi, base string 1Satoshi1111111111111111111111111 => hex 0004d6b1134630fc8c8a8caf92ab9153c6e5569b77fa000000
Raw size: 25, Encoded size: 33 : expected string 1Satoshi, base string 1Satoshizzzzzzzzzzzzzzzzzzzzzzzzz => hex 0004d6b113463672e9e295e62f727aa1a53dc08f80f3ffffff
The target Address 759d667708fb31996328d15f3056d190278a1bb5 NOT match bewteen the start and end range (04d6b1134630fc8c8a8caf92ab9153c6e5569b77 and 04d6b113463672e9e295e62f727aa1a53dc08f80)
Raw size: 25, Encoded size: 33 : expected string 1P, base string 1P1111111111111111111111111111111 => hex 00042926b2614c8a210db0867df56b3274219a39c700000000
Raw size: 25, Encoded size: 34 : expected string 1P, base string 1P11111111111111111111111111111111 => hex 00f152c46a0b574b7d19fe78899a496e4f9cf1171600000000
Raw size: 25, Encoded size: 33 : expected string 1P, base string 1Pzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz => hex 000459912eda15d639d42146c98092fa90aec425217fffffff
Raw size: 25, Encoded size: 34 : expected string 1P, base string 1Pzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz => hex 00fc4ae49d68f2891a0f8a09a7214cc4c798706996ffffffff
The target Address 759d667708fb31996328d15f3056d190278a1bb5 NOT match bewteen the start and end range (042926b2614c8a210db0867df56b3274219a39c7 and 0459912eda15d639d42146c98092fa90aec42521)
The target Address 759d667708fb31996328d15f3056d190278a1bb5 NOT match bewteen the start and end range (f152c46a0b574b7d19fe78899a496e4f9cf11716 and fc4ae49d68f2891a0f8a09a7214cc4c798706996)
Raw size: 25, Encoded size: 33 : expected string 1Q, base string 1Q1111111111111111111111111111111 => hex 000459912eda15d639d42146c98092fa90aec4252180000000
Raw size: 25, Encoded size: 34 : expected string 1Q, base string 1Q11111111111111111111111111111111 => hex 00fc4ae49d68f2891a0f8a09a7214cc4c79870699700000000
Raw size: 25, Encoded size: 33 : expected string 1Q, base string 1Qzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz => hex 000489fbab52df22529a9207150bbac2ad3bee107bffffffff
Something is wrong please check this case "1Q"
Code:
/*
Compile in the keyhunt directory
gcc -o examplermdvanity examplermdvanity.c base58.o util.o
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "util.h"
#include "base58/libbase58.h"
#define LIST_SIZE 8
int main() {
char *targetaddress = "1Bitcoin873Ns4mSAVnUn1eD43RBq89vqo";
unsigned char raw_value_target[50];
char *hexaddress;
char *hextemp,*hextempA,*hextempB;
char *list_targets[LIST_SIZE] = {"1Fortune", "1Prosper", "1Winner", "1Bitcoin","1Satoshi","1P","1Q","1R"};
char target[50];
int i,j,cmpA,cmpB;
int raw_values_A_size,raw_values_B_size;
unsigned char **raw_values_A,**raw_values_B;
unsigned char raw_value_A[50],raw_value_B[50];
size_t stringsize,raw_value_length;
stringsize = strlen(targetaddress);
raw_value_length = 50;
b58tobin(raw_value_target,&raw_value_length,targetaddress,stringsize);
b58tobin(raw_value_target,&raw_value_length,targetaddress,stringsize);
hexaddress = tohex(raw_value_target+1,20);
printf("Address %s encode to %s\n",targetaddress,hexaddress);
raw_values_A = NULL;
raw_values_B = NULL;
for(i = 0; i < LIST_SIZE; i++) {
raw_value_length = 50;
stringsize = strlen(list_targets[i]);
memset(raw_value_A,0,50);
memset(raw_value_B,0,50);
memset(target,0,50);
strncpy(target,list_targets[i],stringsize);
j = 0;
do {
raw_value_length = 50;
b58tobin(raw_value_A,&raw_value_length,target,stringsize);
if(raw_value_length < 25) {
target[stringsize] = '1';
stringsize++;
}
if(raw_value_length == 25){
b58tobin(raw_value_A,&raw_value_length,target,stringsize);
raw_values_A = realloc(raw_values_A,(j+1) * sizeof(unsigned char *));
raw_values_A[j] = calloc(25,1);
memcpy(raw_values_A[j],raw_value_A,25);
hextemp = tohex(raw_values_A[j],raw_value_length);
printf("Raw size: %li, Encoded size: %li : expected string %s, base string %s => hex %s\n", raw_value_length,stringsize,list_targets[i],target,hextemp);
free(hextemp);
j++;
raw_values_A_size = j;
target[stringsize] = '1';
stringsize++;
}
}while(raw_value_length <= 25);
stringsize = strlen(list_targets[i]);
memset(raw_value_B,0,50);
memset(target,0,50);
strncpy(target,list_targets[i],stringsize);
j = 0;
do {
raw_value_length = 50;
b58tobin(raw_value_B,&raw_value_length,target,stringsize);
if(raw_value_length < 25) {
target[stringsize] = 'z';
stringsize++;
}
if(raw_value_length == 25) {
b58tobin(raw_value_B,&raw_value_length,target,stringsize);
raw_values_B = realloc(raw_values_B,(j+1) * sizeof(unsigned char *));
raw_values_B[j] = calloc(25,1);
memcpy(raw_values_B[j],raw_value_B,25);
hextemp = tohex(raw_values_B[j],raw_value_length);
printf("Raw size: %li, Encoded size: %li : expected string %s, base string %s => hex %s\n", raw_value_length,stringsize,list_targets[i],target,hextemp);
free(hextemp);
j++;
raw_values_B_size = j;
target[stringsize] = 'z';
stringsize++;
}
}while(raw_value_length <= 25);
if(raw_values_A_size != raw_values_B_size) {
printf("Something is wrong please check this case \"%s\"\n",list_targets[i]);
exit(0);
}
for(j = 0; j < raw_values_A_size; j++) {
hextempA = tohex(raw_values_A[j]+1,20);
hextempB = tohex(raw_values_B[j]+1,20);
cmpA = memcmp(raw_values_A[j]+1,raw_value_target+1,20);
cmpB = memcmp(raw_values_B[j]+1,raw_value_target+1,20);
if(cmpA <= 0 && cmpB >= 0) {
printf("The target Address %s match bewteen the start and end range (%s and %s)\n",hexaddress,hextempA,hextempB);
}
else {
printf("The target Address %s NOT match bewteen the start and end range (%s and %s)\n",hexaddress,hextempA,hextempB);
}
free(hextempA);
free(hextempB);
}
if(raw_values_A_size > 0){
for(j = 0; j < raw_values_A_size; j++) {
free(raw_values_A[j]);
free(raw_values_B[j]);
}
free(raw_values_A);
free(raw_values_B);
raw_values_A =NULL;
raw_values_B =NULL;
}
}
}