This question already has an answer here:
- What is the strMessageMagic good for? 2 answers
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:
- Why does it use a magic prefix?
- 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.