we (web engine): Experimental web browser project to understand the limits of Claude

X25519 key exchange (RFC 7748) #51

open opened by pierrelf.com

Phase 5: Pure Rust Crypto#

Implement X25519 Diffie-Hellman key exchange in the crypto crate per RFC 7748.

Requirements#

  • Field arithmetic in GF(2^255 - 19): add, sub, mul, pow, inverse
  • Montgomery ladder scalar multiplication on Curve25519
  • x25519(scalar, u_coordinate) -> u_coordinate
  • Key generation: clamp private key, compute public key from basepoint
  • Shared secret derivation: x25519(my_private, their_public)
  • Constant-time implementation to prevent timing side-channels

Acceptance Criteria#

  • Field arithmetic for GF(2^255 - 19) with 5x51-bit limb representation
  • Montgomery ladder scalar multiplication
  • x25519_base(private_key) -> public_key (basepoint multiplication)
  • x25519(private_key, public_key) -> shared_secret
  • Pass RFC 7748 ยง6.1 test vectors
  • Pass iterated test vector (1,000 iterations)
  • Constant-time (no secret-dependent branches or memory accesses)
  • cargo test -p we-crypto passes
  • cargo clippy -p we-crypto -- -D warnings clean
sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mgemtscimy2c