跳到主要内容
uencoder

Use ECDH 为键 exchange

ECDH (Elliptic Curve Diffie-Hellman) establishes shared secrets using elliptic curves. Smaller 关键, 相同安全 as DH.

  1. 1

    ECDH: Alice 有私有键 , 公共键 = *G. Bob 有私有键 b, 公共键 B = b*G. 它们 exchange 公共关键. Alice computes shared = *B = *b*G. Bob computes shared = b* = b**G. 两者 get 相同 point — x-坐标是 shared secret. Use Curve25519 为 ECDH — 它是 快, 常量-时间, 和安全.

  2. 2
    随机字节生成器 →

    生成 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
    哈希计算器 →

    Hash shared secret 到 derive symmetric 键. raw x-坐标的 shared point 是不 uniformly distributed — hash 它具有 SHA-256 到 get uniformly random 键. Use HKDF 为键 derivation: K = HKDF(shared_secret, info="加密键").

常见问题

ECDH vs DH?
ECDH 我们 elliptic curve groups — smaller 关键为 equivalent 安全 (256-位 ECDH ≈ 3072-位 DH). ECDH 是 faster 和我们更少带宽. Use ECDH 具有 Curve25519 为新 systems. 经典 DH 具有大 primes 是仍然安全但 slower.
什么是 X25519?
X25519 是 Diffie-Hellman 键 exchange 函数 using Curve25519. 它是 specified 在 RFC 7748 和 used 在 TLS 1.3, SSH, 和 Signal. 它是 快, 常量-时间 (resistant 到 timing attacks), 和 handles 所有边界情况 (否无效 curve attacks). Use X25519 为 ECDH 在新 systems.

解决此任务的工作流

相关工具