Skip to content

Problem with read Public Key + generating Bitcoin Address #1

@Sztef89

Description

@Sztef89

Hi!

Thank you for your code! Is very usefull :)

I have couple problems :( I modify your code (ino) to delete printer component and comunicate with Arduino throw serial port. I get private key in WIF format with no problems but function:
bitaddress::generateAddress(x,y,encoded,sizeof(encoded));
may not working correct, please tell me what I'm doing wrong (code below).

Second question: How do you speed up calculations in your printer? How microcontroler do you use (from arduino uno = ATmega 328?). Can you upload schematic? :) In my case generate priv + pub take about 3 minutes - this is horrible.

This is my ino code:

include <panic.h>

include <progress.h>

include <bignat.h>

include <bigint.h>

include <sha256.h>

include <rmd160.h>

include <base58.h>

include <bitelliptic.h>

include <bitaddress.h>

include <rng.h> // Random Number Generator

void PANIC(byte errorCode){
Serial.println(F("PANIC"));
Serial.println(errorCode);
for(;;){}
}

void PROGRESS(float p){
Serial.println(p);
}

uint8_t PRIVATE[32];
WORD xbuf[32];
WORD ybuf[32];
struct bigint pubx(xbuf,sizeof(xbuf));
struct bigint puby(ybuf,sizeof(ybuf));

void printprivate(uint8_t *PRIVATE){
char encoded[52];
bitaddress::generatePrivateWIF(PRIVATE,encoded,sizeof(encoded));
Serial.println("Private key WIF:");
Serial.println(encoded);
}

void printpublic(const struct bigint &x,const struct bigint &y){
char encoded[40];
bitaddress::generateAddress(x,y,encoded,sizeof(encoded));

Serial.println("\nBitcoin Address:");
Serial.println(encoded);
Serial.println("\n--------------\n");
}

void generatePrivateKey(uint8_t *PRIVATE){
rng::generate(PRIVATE);
}

void setup(){
Serial.begin(9600);
Serial.println("Bitcoin Address Generator v0.0.1\n");

//PRIVATE
//Generate random number
generatePrivateKey(PRIVATE);
//Create private key in WIF
printprivate(PRIVATE);

// PUBLIC
// Public key ECDSA
bitaddress::generatePublicKey(PRIVATE,pubx,puby);
// Public ECDSA to Bitcoin Address
printpublic(pubx,puby);

Serial.println("\nEnd of line");
}

void loop(){
}

Result:
Bitcoin Address Generator v0.0.1

0.00
0.02
0.04
[...]
0.94
0.96
0.98
Private key WIF:
5JJhAHNMkFs9TkoxVzt3k4ej71gjJaw9CL52mS7FDBCoGeK1nPs
0.00
0.03
[...]
0.94
0.97

Bi

Thank you for your help.

Best regards
Stefan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions