> For the complete documentation index, see [llms.txt](https://hub.bsvblockchain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hub.bsvblockchain.org/higher-learning/bsv-academy/bitcoin-primitives-digital-signatures/bsv-and-digital-signatures/signed-messages.md).

# Signed Messages

The **Bitcoin protocol** allows users to sign any type of data (not just transactions) using a **Bitcoin private key**. The same counts for BSV. This process is primarily used for **message authentication**—proving that the signer has access to a specific BSV address at the time of signing.

***

### Private and Public Key Generation

The process of generating **private and public keys** is the same as in BSV transactions.\
Some wallets also provide a **message signing feature**, enabling you to sign data with your private key.

***

### How a Message is Signed

1. The message is **prepended** with the string:\
   `"Bitcoin Signed Message:\n"` along with the message length.
2. It is then **double-hashed** with **SHA-256**.
3. The result is signed using **ECDSA**.
4. The **signature** is produced as a tuple `(i, r, s)` where:
   * `i` = 1 byte (parity byte)
   * `r` = 32 bytes
   * `s` = 32 bytes
5. Finally, the tuple is **base64 encoded**.

<figure><img src="https://3421145409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRTEKu4E7Fvtss3GI9CYU%2Fuploads%2Fje472pNnwssFcfvrY1oR%2Fsignature.svg?alt=media&amp;token=fee6d54e-5560-413a-b639-a96bac2b6d12" alt=""><figcaption></figcaption></figure>

### How a Message is Verified

1. The **address** is transmitted with the **original message** and the **signed message**.
2. Using the **parity byte** `i`, the system derives between **0–4 candidate public keys**.
3. The verification process repeats the same steps:
   * Prepend `"Bitcoin Signed Message:\n"`
   * **Double-hash** the message with SHA-256
   * Run the **verification algorithm** for each candidate key
4. If one of the candidate keys returns **True**, the signature is valid.
5. The valid public key is then converted into an **address** and checked against the sender’s provided address.

<figure><img src="https://3421145409-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRTEKu4E7Fvtss3GI9CYU%2Fuploads%2FlUBV8frTXY8ZtfDFUd0c%2Fverified.svg?alt=media&amp;token=700b7aa0-eaf9-47a0-a937-c466b18b92a0" alt=""><figcaption></figcaption></figure>

### Address Reminder

Recall: a **BSV address** is derived as follows:

* Start with the **public key**
* Apply **SHA-256**, then **RIPEMD-160**
* Encode the result as a **Base58 string**

***

### Key Takeaway

* **Signed messages** prove control of a BSV private key without moving coins.
* The process ensures **authenticity** (message truly from the signer) and **integrity** (message unchanged).
* Both **signing** and **verification** rely on **ECDSA**, **double hashing**, and the **Base58-encoded address** structure.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hub.bsvblockchain.org/higher-learning/bsv-academy/bitcoin-primitives-digital-signatures/bsv-and-digital-signatures/signed-messages.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
