Skip to content

Commit

Permalink
Add support for hex keys
Browse files Browse the repository at this point in the history
  • Loading branch information
MakisChristou committed Jun 1, 2022
1 parent 8562c28 commit d612cc2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CC=gcc
CFLAGS=-g -Ofast -Wall -Wno-unused-function -Wno-pointer-sign \
CFLAGS=-g -O3 -Wall -Wno-unused-function -Wno-pointer-sign \
-I. -Isecp256k1 -Isecp256k1/include -funsafe-loop-optimizations
LDFLAGS=$(CFLAGS)
LDLIBS=-lm -lgmp -lssl -lcrypto -lpthread
Expand Down
29 changes: 23 additions & 6 deletions vanitygen.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ char *pattern = "bcq1test"; // Pattern to match
char *hrp = "bc"; // Different for each coin
char *output_file;
int update_time = 5; // Update screen every x seconds
int hex_priv = 0; // 1 for hex private keys, else WIF

// Stolen from supervanitygen
void announce_result(int found, const u8 result[52])
void announce_result(int found, const u8 result[52], int hex_priv)
{
align8 u8 priv_block[64], pub_block[64], cksum_block[64];
align8 u8 wif[64], checksum[32];
Expand All @@ -50,9 +51,20 @@ void announce_result(int found, const u8 result[52])
sha256_hash(checksum, cksum_block);
memcpy(priv_block+34, checksum, 4);

b58enc(wif, priv_block, 38);
if(hex_priv == 1)
{
printf("Private Key: ");
for(int i = 0; i < 32; i++)
printf("%02x", result[i]);
printf("\n");
}
else
{
b58enc(wif, priv_block, 38);
printf("Private Key: %s\n", wif);
}


printf("Private Key: %s\n", wif);

// /* Convert Public Key to Compressed WIF */

Expand All @@ -70,6 +82,7 @@ void announce_result(int found, const u8 result[52])
// printf("Address: %s\n", wif);
}


// Run this on retarded user input
void print_usage()
{
Expand Down Expand Up @@ -101,7 +114,7 @@ void parse_arguments(int argc, char** argv)
}

int opt;
while((opt = getopt(argc,argv, "hp:t:")) != -1)
while((opt = getopt(argc,argv, "hp:t:d")) != -1)
{
//Print Help Message
if(opt == 'h')
Expand All @@ -125,6 +138,10 @@ void parse_arguments(int argc, char** argv)
check_pattern(optarg);
pattern = optarg;
}
else if(opt == 'd')
{
hex_priv = 1;
}
else
{
exit(1); // exit on wrong argument
Expand Down Expand Up @@ -452,8 +469,8 @@ void* vanity_engine(void *vargp)

if(valid_private_key)
{
// Print WIF private key
announce_result(1,privkey);
// Print WIF or HEX private key
announce_result(1, privkey, hex_priv);

// Print Segwit Address
printf("Address: %s\n",output);
Expand Down

0 comments on commit d612cc2

Please sign in to comment.