Saltar al contenido
uencoder

Usar ECDH para clave exchange

ECDH (Elliptic Curve Diffie-Hellman) establishes shared secrets usando elliptic curves. Smaller claves, mismo seguridad como DH.

  1. 1

    ECDH: Alice has private key a, public key A = a*G. Bob has private key b, public key B = b*G. They exchange public keys. Alice computes shared = a*B = a*b*G. Bob computes shared = b*A = b*a*G. Both get the same point — the x-coordinate is the shared secret. Use Curve25519 for ECDH — it is fast, constant-time, and secure.

  2. 2
    Generador de bytes aleatorios →

    Generar the private key — a random integer in [1, n-1] where n is the curve order. For Curve25519, the private key is 32 random bytes with specific bit clamping. Use a CSPRNG — the private key must be unpredictable.

  3. 3
    Calculadora de hash →

    Hash the shared secret to derive a symmetric key. The raw x-coordinate of the shared point is not uniformly distributed — hash it with SHA-256 to get a uniformly random key. Use HKDF for key derivation: K = HKDF(shared_secret, info="encryption key").

Preguntas frecuentes

ECDH vs DH?
ECDH uses elliptic curve groups — smaller keys for equivalent security (256-bit ECDH ≈ 3072-bit DH). ECDH is faster and uses less bandwidth. Use ECDH with Curve25519 for new systems. Classic DH with large primes is still secure but slower.
What is X25519?
X25519 is the Diffie-Hellman key exchange function using Curve25519. It is specified in RFC 7748 and used in TLS 1.3, SSH, and Signal. It is fast, constant-time (resistant to timing attacks), and handles all edge cases (no invalid curve attacks). Use X25519 for ECDH in new systems.

Flujos que resuelven esta tarea

Herramientas relacionadas