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-cryptopasses -
cargo clippy -p we-crypto -- -D warningsclean