1

This question already has an answer here:

The standard Bitcoin message signature works as follows:

sign(sha256(magicPrefix . length(message) . message))

The "magic prefix" is simply the string '\x18Bitcoin Signed Message:\n', where 0x18 is the length of the prefix text.

In other words, it's this:

sign(sha256(length(prefix) . prefix . length(message) . message))

My question is:

  1. Why does it use a magic prefix?
  2. Why does it include the lengths of the two components?

I'm asking mainly from a security point of view. Does adding a prefix or including the length(s) have any security benefits? If not, I'd like to drop it from my signatures.

marked as duplicate by morsecoder Apr 9 '15 at 3:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

RFC4880 apparently standardises the way signatures work, so it could be referring to:

0x18: Subkey Binding Signature This signature is a statement by the top-level signing key that indicates that it owns the subkey. This signature is calculated directly on the primary key and subkey, and not on any User ID or other packets. A signature that binds a signing subkey MUST have an Embedded Signature subpacket in this binding signature that contains a 0x19 signature made by the signing subkey on the primary key and subkey.

But it seems much more likely BIP70 extension proposal is the reason for standardising signatures, as outlined by their BitID wallet implementation requirements:

To be compatible with the BitID protocol, a wallet must implement the following:

  • register the bitid scheme
  • throw a bitid intent when scanning a BitID QR code (if applicable)
  • decode the URI and verify its format
  • display a request for authentication showing the domain name callback and > - ask for validation
  • ask the user to pick up or create a Bitcoin address for the authentication (show the last Bitcoin address used if this is a known callback address)
  • sign the BitID URI with the private key (using the \x18Bitcoin Signed Message:\n#{message.size.chr}#{message} convention)
  • POST the signature and the public key to the callback URL completion dialog : success/retry/cancel

Not the answer you're looking for? Browse other questions tagged or ask your own question.