← index

Satoshi Style Message Signing

An archive of delvingbitcoin.org · view original topic →

Stacie Waleyko · #1 ·

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:

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:

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?

Pieter Wuille · #2 ·

The message signing feature and encoding wasn’t designed by Satoshi, but by me, so you can direct all blame for quirks and lack of documentation here. You’re right that it predates the BIP process, so the code is really the specification I’m afraid, though with many reimplementations there are probably several languages to choose from.

It is roughly:

Anthony Towns · #3 ·

I’ve also been confused at the lack of docs. Might be good to at least update the wiki with the extra detail? sipa’s PR is:

Forum discussion linked from there at https://bitcointalk.org/index.php?topic=6428.0;all is probably also interesting.

Stacie Waleyko · #4 ·

Wow!! Thank you for such a fast and detailed reply @sipa! That list of steps is exactly the clarification I was trying to find. But there goes the idea of calling it “Satoshi format” (I swear I didn’t make that up!)

Thanks for digging up those resources @ajtowns! I will assign myself the task of updating the wiki. This is really great information that should be shared.

Mystery solved :blush:

Ján Sáreník · #5 · · in reply to #4

It is also used in Blockstream’s puzzle where they call it “old Bitcoin Armory style”. Thank you all! I really appreciate this!