feat: Phase 3 Week 1 — X3DH key agreement + HKDF foundation

- Add hkdf = "0.12" dependency for Double Ratchet key derivation
- Extend mesh/crypto.rs with hkdf_sha256, hkdf_sha256_32, hkdf_sha256_64,
  and generate_x25519_ephemeral() for DH ratchet steps
- Create mesh/x3dh.rs: full X3DH key agreement protocol
  - PrekeyBundle generation with Ed25519-signed prekeys
  - 3-way (or 4-way) ECDH → HKDF-SHA256 → root key
  - Initiator and responder sides derive identical root key
  - CBOR encoding for mesh transmission
  - Bundle signature verification
  - 5 unit tests: generate+verify, both-sides-same-key,
    without-one-time-prekey, cbor-roundtrip, tamper-detection

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Dorian
2026-03-17 01:28:35 +00:00
parent e162ff8b3b
commit 37a591618d
5 changed files with 542 additions and 211 deletions

View File

@@ -14,6 +14,8 @@ pub mod protocol;
pub mod serial;
#[allow(dead_code)]
pub mod types;
#[allow(dead_code)]
pub mod x3dh;
pub use types::*;