There's a hard-coded 27 value in Bitcoin's encoding of Compact Signatures that I don't understand:
https://github.com/bitcoin/bitcoin/blob/v0.7.1/src/key.cpp#L333
I get that the need to encode the nRecId
to disambiguate the correct recovered key, but I don't understand the 27 (or for that matter why fCompressedPubKey
is encoded as a 4).
The decoder requires the first byte be between 27 and 35, but then just subtracts the hard-coded 27 sans explanation.
It this poor man's bitmasking? It there something in the protocol that Compact Signature's can't begin with a 0x00 and this is a weird work-around? Perhaps it's acting as a sort of magic cookie?