security.md raw

Elliptic Curve Security Analysis

Security properties, attack vectors, and mitigations for elliptic curve cryptography.

The Discrete Logarithm Problem (ECDLP)

Definition

Given points P and Q = kP on an elliptic curve, find the scalar k.

Security assumption: For properly chosen curves, this problem is computationally infeasible.

Best Known Attacks

Generic Attacks (Work on Any Group)

AttackComplexityNotes
Baby-step Giant-stepO(√n) space and timeRequires √n storage
Pollard's rhoO(√n) time, O(1) spacePractical for large groups
Pollard's lambdaO(√n)When k is in known range
Pohlig-HellmanO(√p) where p is largest prime factorExploits factorization of n

For secp256k1 (n ≈ 2²⁵⁶):

Curve-Specific Attacks

AttackApplicable WhenMitigation
MOV/FR reductionLow embedding degreeUse curves with high embedding degree
Anomalous curve attackn = pEnsure n ≠ p
GHS attackExtension field curvesUse prime field curves

secp256k1 is immune to all known curve-specific attacks.

Side-Channel Attacks

Timing Attacks

Vulnerability: Execution time varies based on secret data.

Examples:

Mitigations:

Power Analysis

Simple Power Analysis (SPA): Single trace reveals operations.

Differential Power Analysis (DPA): Statistical analysis of many traces.

Cache Attacks

FLUSH+RELOAD Attack:

1. Attacker flushes cache line containing lookup table
2. Victim performs table lookup based on secret
3. Attacker measures reload time to determine which entry was accessed

Mitigations:

Electromagnetic (EM) Attacks

Similar to power analysis but captures electromagnetic emissions.

Mitigations:

Implementation Vulnerabilities

k-Reuse in ECDSA

The Sony PS3 Hack (2010):

If the same k is used for two signatures (r₁, s₁) and (r₂, s₂) on messages m₁ and m₂:

s₁ = k⁻¹(e₁ + rd) mod n
s₂ = k⁻¹(e₂ + rd) mod n

Since k is the same:
s₁ - s₂ = k⁻¹(e₁ - e₂) mod n
k = (e₁ - e₂)(s₁ - s₂)⁻¹ mod n

Once k is known:
d = (s₁k - e₁)r⁻¹ mod n

Mitigation: Use deterministic k (RFC 6979).

Weak Random k

Even with unique k values, if the RNG is biased:

Mitigations:

Invalid Curve Attacks

Attack: Attacker provides point not on the curve.

Mitigation: Always validate points are on curve:

Verify: y² ≡ x³ + ax + b (mod p)

Small Subgroup Attacks

Attack: If cofactor h > 1, points of small order exist.

Mitigation:

Fault Attacks

Attack: Induce computational errors (voltage glitches, radiation).

Mitigations:

Signature Malleability

ECDSA Malleability

Given valid signature (r, s), signature (r, n - s) is also valid for the same message.

Impact: Transaction ID malleability (historical Bitcoin issue)

Mitigation: Enforce low-S normalization:

if s > n/2:
    s = n - s

Schnorr Non-Malleability

BIP-340 Schnorr signatures are non-malleable by design:

Quantum Threats

Shor's Algorithm

Threat: Polynomial-time discrete log on quantum computers.

Timeline: Estimated 10-20+ years for cryptographically relevant quantum computers.

Migration Strategy

  1. Monitor: Track quantum computing progress
  2. Prepare: Develop post-quantum alternatives
  3. Hybrid: Use classical + post-quantum in transition
  4. Migrate: Full transition when necessary

Post-Quantum Alternatives

Best Practices

Key Generation

DO:
- Use cryptographically secure RNG
- Validate private key is in [1, n-1]
- Verify public key is on curve
- Verify public key is not point at infinity

DON'T:
- Use predictable seeds
- Use truncated random values
- Skip validation

Signature Generation

DO:
- Use RFC 6979 for deterministic k
- Validate all inputs
- Use constant-time operations
- Clear sensitive memory after use

DON'T:
- Reuse k values
- Use weak/biased RNG
- Skip low-S normalization (ECDSA)

Signature Verification

DO:
- Validate r, s are in [1, n-1]
- Validate public key is on curve
- Validate public key is not infinity
- Use batch verification when possible

DON'T:
- Skip any validation steps
- Accept malformed signatures

Public Key Handling

DO:
- Validate received points are on curve
- Check point is not infinity
- Prefer compressed format for storage

DON'T:
- Accept unvalidated points
- Skip curve membership check

Security Checklist

Implementation Review

Operational Security

Security Levels Comparison

CurveBitsSymmetric EquivalentRSA Equivalent
secp192r1192961536
secp224r12241122048
secp256k12561283072
secp384r13841927680
secp521r152125615360

References