"\x18Bitcoin Signed Message:\n"
Process of Signing a Message
- Concatenation: The actual text that gets signed is a concatenation of the prefix and the message. Specifically, it’s the prefix followed by the length of the message (as a single byte or varint) and then the message itself.
- Hashing: Before signing, the concatenated string is hashed twice using SHA-256 (SHA-256d). This double hashing is a common practice in Bitcoin for added security.
- Signing: The double
SHA-256hash of the message is then signed using the private key associated with the Bitcoin address. This signing is done according to the ECDSA (Elliptic Curve Digital Signature Algorithm) standard used in Bitcoin.
Bitcoin Typed Message Signing in Fireblocks:
Below is a TypeScript SDK code example on how to execute Typed Message Signing (Personal Message) in Bitcoin. In this example we are specifically showing how to sign a TRUST platform compatible message:Structure of the Signature:
The signature produced in Bitcoin message signing is composed of the following: A single-byte recovery IDrecid - this byte helps in recovering the public key (and thus the address) from the signature and the signed message.
Two 32-byte numbers representing the ECDSA signature components - r and s.
The signature is usually encoded in Base64 format when being displayed or transmitted, making it easier to handle in web interfaces and other applications.