> 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-hash-functions/ripemd-160-overview/elliptic-curve-diffie-hellman-ecdh-and-the-elliptic-curve-digital-signature-algorithm-ecdsa.md).

# Elliptic Curve Diffie-Hellman (ECDH) and the Elliptic Curve Digital Signature Algorithm (ECDSA)

#### Why Move to Elliptic Curves?

Both **ECDH** (Elliptic Curve Diffie-Hellman) and **ECDSA** (Elliptic Curve Digital Signature Algorithm) follow the **same principles** as standard Diffie-Hellman and DSA.

The main difference:

* **Standard DH/DSA:** Use **exponentiation** (gᵃ mod n).
* **Elliptic Curve versions:** Use **multiplication on elliptic curve points**.

👉 The benefit: Elliptic curve math offers **equivalent security with much smaller key sizes**.

* 3,072-bit keys in DH/DSA ≈ 256-bit keys in ECDH/ECDSA.

***

#### Key Exchange: DH vs. ECDH

**Standard Diffie-Hellman:**

`sv = (gᵃ)ᵇ mod 2³⁰⁷² = (gᵇ)ᵃ mod 2³⁰⁷²`

&#x20;

**Elliptic Curve Diffie-Hellman (ECDH):**

`sv = g·b·a mod 2²⁵⁶ = g·a·b mod 2²⁵⁶`

&#x20;

👉 **Result:** Both methods allow Alice and Bob to compute the same **shared secret (sv)**, but elliptic curves achieve this with much **smaller numbers**.

***

#### Digital Signatures: DSA vs. ECDSA

**Standard DSA (on message hash m):**

1. Private key: `a` (random integer < 2³⁰⁷²).
2. Public key: `A = gᵃ`.
3. Random one-time key: `k`.
4. Signature values:
   * `r = (gᵏ mod p) mod q`
   * `s = (k⁻¹(m + a·r)) mod q`

&#x20;

**ECDSA (on message hash m):**

1. Private key: `a` (random integer < 2²⁵⁶).
2. Public key: `A = g·a`.
3. Random one-time key: `k`.
4. Signature values:
   * `R = k·g`
   * `r = Rₓ mod q` (x-coordinate of R)
   * `s = (m + a·r)·k⁻¹ mod q`

👉 **Key difference:** Elliptic curve math replaces exponentiation with **point multiplication**.

***

#### Signature Verification

**Standard DSA verification:**

```
z = s⁻¹ mod q
w₁ = m·z mod q
w₂ = r·z mod q
v  = (gʷ¹ · Aʷ² mod p) mod q
Valid if v == r
```

&#x20;

**ECDSA verification:**

```
z = s⁻¹ mod q
w₁ = m·z mod q
w₂ = r·z mod q
v  = (g·w₁) + (A·w₂)
Valid if vₓ == r mod q
```

***

#### Why It Matters for BSV

Although **BSV’s UTXO model** is not about encrypting all communications, it is still built on two fundamental cryptographic ideas:

1. **Shared secrets** (ECDH provides a secure foundation).
2. **Digital signatures** (ECDSA secures ownership and transaction authenticity).

✅ **Summary:** By using elliptic curve cryptography, BSV achieves **stronger security with smaller keys**, making transactions more efficient while preserving the essential principles of **trust and integrity**.


---

# 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-hash-functions/ripemd-160-overview/elliptic-curve-diffie-hellman-ecdh-and-the-elliptic-curve-digital-signature-algorithm-ecdsa.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.
