<p>Imagine if that weren't there. What if someone tricked you into signing a Bitcoin transaction with your key? They could put the signature they got from you along with your public key into the input script for the transaction, and broadcast that transaction to the network. (Unless something else I'm not aware of would prevent that.)</p>

<p>Granted, it would be somewhat difficult to trick someone into doing that (Bitcoin transactions include null chars, and I don't think you can copy-paste those) but why take the risk at all?</p>

CC BY-SA 3.0
2014-12-22T23:24:16.083Z
2014-12-31T03:24:49.643Z
2014-12-31T03:24:49.643Z
Nick ODell
<p>The "magic string" is prefixed to a message before hashing. You could think of it as setting the hashing function to a particular initial state before hashing the message. It serves only to give some distinction to hashes of Bitcoin-specific messages, by resulting in a hash value that is different from hashing just the bare message. There is no cryptographic reason or consequence for this.</p>

CC BY-SA 3.0
2014-12-22T23:10:12.393Z
2014-12-22T23:10:12.393Z
Chuck Batson
<p>The bitcoin message magic, "Bitcoin Signed Message:\n", is defined: <a href="https://github.com/bitcoin/bitcoin/blob/203632d20b3107009f45fae56cc3f7d828b16660/src/main.cpp#L80" rel="nofollow noreferrer">https://github.com/bitcoin/bitcoin/blob/203632d20b3107009f45fae56cc3f7d828b16660/src/main.cpp#L80</a></p>

<p>I know it is used as a part of signing messages to prove they were sent from owners of specific private keys, as detailed here: <a href="https://bitcoin.stackexchange.com/questions/3337/what-are-the-safety-guidelines-for-using-the-sign-message-feature/3339#3339">What are the safety guidelines for using the Sign Message feature?</a>.</p>

<p>What I don't know, though, is what good is this message magic? Does it make sure the same key can't be used in two coins? Is there some cryptographic reason?</p>

<message-signing>
What is the strMessageMagic good for?
morsecoder
# What is the strMessageMagic good for?

(Asked by: username_0 on 2014-12-22)

The bitcoin message magic, "Bitcoin Signed Message:\n", is defined: <https://github.com/bitcoin/bitcoin/blob/203632d20b3107009f45fae56cc3f7d828b16660/src/main.cpp#L80>

I know it is used as a part of signing messages to prove they were sent from owners of specific private keys, as detailed here: [What are the safety guidelines for using the Sign Message feature?](https://bitcoin.stackexchange.com/questions/3337/what-are-the-safety-guidelines-for-using-the-sign-message-feature/3339#3339).

What I don't know, though, is what good is this message magic? Does it make sure the same key can't be used in two coins? Is there some cryptographic reason?

**Tags:** message-signing


---

## 2 answers

### Answer by username_1 on 2014-12-22. Score: 2 | Accepted answer

Imagine if that weren't there. What if someone tricked you into signing a Bitcoin transaction with your key? They could put the signature they got from you along with your public key into the input script for the transaction, and broadcast that transaction to the network. (Unless something else I'm not aware of would prevent that.)

Granted, it would be somewhat difficult to trick someone into doing that (Bitcoin transactions include null chars, and I don't think you can copy-paste those) but why take the risk at all?


---

### Answer by username_2 on 2014-12-22. Score: 1

The "magic string" is prefixed to a message before hashing. You could think of it as setting the hashing function to a particular initial state before hashing the message. It serves only to give some distinction to hashes of Bitcoin-specific messages, by resulting in a hash value that is different from hashing just the bare message. There is no cryptographic reason or consequence for this.


---

