# Merkle Trees & Digital Signatures

<figure><img src="/files/UysMrj9ttUc47RvxmOFT" alt=""><figcaption></figcaption></figure>

Besides the use for data integrity and data storage/retrieval, hash functions are used for two key concepts in BSV: **Merkle Trees and Digital signatures**

### Merkle Trees![](https://hub.bsvblockchain.org/~gitbook/image?url=https%3A%2F%2Fbitcoinsv.academy%2Fstorage%2Fphotos%2F4318%2FBSVA-MerkleTrees_Ch1Less1_VA3%2520updated.jpg\&width=768\&dpr=4\&quality=100\&sign=f6209f72\&sv=2)

#### What Are Merkle Trees?

The BSV blockchain makes extensive use of Merkle Trees.

A Merkle Tree is a **binary tree structure** (each branch splits into two nodes) that is made entirely of **hashes**.

<figure><img src="/files/zaYFhLkmSZbW1scOmlP2" alt=""><figcaption></figcaption></figure>

#### How They Are Built

* The **leaf nodes** at the bottom layer of the tree are the **hash values of raw Bitcoin transaction data**.
* Each successive layer is created by **concatenating two hashes** from the layer below and hashing them together.
* This process continues until reaching the **root node**, which represents the entire tree with a **single hash value**.

#### Why They Matter

This structure makes it:

* **Easy to find data** stored at the bottom of the tree.
* **Efficient to prove** that specific data exists in the tree.
* **Critical for scaling** the BSV system, since data integrity can be verified quickly without re-checking the entire dataset.

***

### Digital Signatures

#### What Are Digital Signatures?

Although hash tables and Merkle Trees are powerful uses of hash functions, the most **widely recognized use** is in **cryptography**.

* Digital signatures, alongside encryption and key exchange, **rely heavily on hash functions**.
* Like a **physical signature**, a digital signature **associates an identity** with a document or message.
* To keep them secure, digital signatures use **well-tested algorithms** for both creation and verification.

#### Digital Signatures in BSV

On the BSV blockchain, digital signatures are most commonly used in **Pay-to-Public-Key-Hash (P2PKH) transactions**— the standard template where **ownership of funds** is transferred from a sender to a receiver.

* Digital signatures let someone **prove they created a transaction** without ever revealing their **private key**.

#### How It Works

1. Instead of signing the **entire transaction data** (which may be large and inefficient), the data is first run through a **cryptographic hash function**.
2. This produces a **short, fixed-size digest** that uniquely represents the transaction.
3. The **sender signs this digest** with their **private key**.
4. Anyone can then use the **sender’s public key** to:
   * Verify the signature matches the digest (**authenticity**)
   * Confirm the data hasn’t been altered (**integrity**)

#### Key Learning

✅ **Digital signatures prove authorship and integrity without exposing private keys** — a foundation of security in Bitcoin transactions.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hub.bsvblockchain.org/higher-learning/bsv-academy/bitcoin-primitives-hash-functions/what-are-hash-functions/merkle-trees-and-digital-signatures.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
