Post
Topic
Board Development & Technical Discussion
Merits 2 from 1 user
Re: Bitcoin private key BASE58 problem
by
o_e_l_e_o
on 04/12/2021, 09:09:48 UTC
⭐ Merited by TheArchaeologist (2)
there're two \0 bytes to be added . second one added to start right before base58 op.
There aren't. The reason that code adds 0x00 twice is because the second time it calls back to the RIPEMD-160 output, instead of calling back to the RIPEMD-160 output with the 0x00 already prepended.

Take the public key, SHA256 it, RIPEMD-160 it, then add 0x00 to the start. Call this pubhash_prefix. SHA256 this twice, take the first 4 bytes, and then append these 4 bytes to pubhash_prefix. Convert to base58 and you have your address.