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