Right now the most common way to sign general messages is still with a private key that corresponds to a legacy P2PKH address. Many hardware and software projects have implemented this including Ledger, Trezor, Coldcard, and Sparrow, as well as a few multisig companies. One reason why they are so useful is they help users test that the hardware controlling their keys has not succumbed to bit rot.
This technique for message signing comes from Bitcoin Core code that Satoshi wrote (see src/util/message.cpp [link]). This was created before the BIP process, so the best technical documentation I have found, aside from the actual implementation, is this page on the Bitcoin Wiki.
While comprehensive, the Bitcoin Wiki page doesn’t make some very important technical details as obvious as they should be. Examples include:
- The “Bitcoin Signed Message:\n” magic bytes. I think this is alluded to in the Displaying signed messages section. But the actual magic bytes are never stated on the page.
- The double hashing that is performed on each message. See bitcoin/src/hash.h at v27.0 · bitcoin/bitcoin · GitHub
This wiki page also covers the rules for the signature header byte (see src/key.cpp::SignCompact()) but I found this post on Bitcoin Stack Exchange did a much better job explaining this tricky part.
Related work & message signing in the wild
There has been lots of good work to address message signing for other address types, including BIP-137, BIP-notatether-messageverify, and BIP-322, but I have yet to find a single reliable source of documentation on the “Satoshi format” of message signing described above.
This baffles me because there are plenty of projects that have implemented this. Apart from the examples listed earlier, we also have things like:
- Bitcoin Message Tool [January 2023, likely built on this project and this one]
- https://checkmsg.org/ [another verification tool, this time from CoinKite]
It seems like plenty of people know how to do this, so either I’m bad at reading the material we have today, or those that have come before me have spent a substantial amount of time and effort figuring it out. Can someone help me tease apart the information I have been able to gather here? Is the “Satoshi format” of message signing fully documented anywhere other than the code?
