Thanks so much for the detailed response.
I looked a little bit further and the output is in the format of a 'compressed public key'. My parser already takes into account the 65 byte uncompressed public key which was only used for a little while in the early lifetime of the blockchain. These compressed public keys are rarely used as well because most of the time the 20 byte RIPEMD160 hash of the public key is what is usually stored in the output script.
http://bitcoin.stackexchange.com/questions/3059/what-is-a-compressed-bitcoin-keyHere is the snippet if code I currently use to convert a 65 byte uncompressed public key to a bitcoin address, which matches your explanation.
bool bitcoinPublicKeyToAddress(const uint8_t input[65], // The 65 bytes long ECDSA public key; first byte will always be 0x4 followed by two 32 byte components
uint8_t output[25]) // A bitcoin address (in binary( is always 25 bytes long.
{
bool ret = false;
if ( input[0] == 0x04)
{
uint8_t hash1[32]; // holds the intermediate SHA256 hash computations
SHA256::computeSHA256(input,65,hash1); // Compute the SHA256 hash of the input public ECSDA signature
output[0] = 0; // Store a network byte of 0 (i.e. 'main' network)
RIPEMD160::computeRIPEMD160(hash1,32,&output[1]); // Compute the RIPEMD160 (20 byte) hash of the SHA256 hash
SHA256::computeSHA256(output,21,hash1); // Compute the SHA256 hash of the RIPEMD16 hash + the one byte header (for a checksum)
SHA256::computeSHA256(hash1,32,hash1); // now compute the SHA256 hash of the previously computed SHA256 hash (for a checksum)
output[21] = hash1[0]; // Store the checksum in the last 4 bytes of the public key hash
output[22] = hash1[1];
output[23] = hash1[2];
output[24] = hash1[3];
ret = true;
}
return ret;
}
What I'm wondering is how do I take the 33 byte 'compressed' form into account?