Commit Graph

2 Commits

Author SHA1 Message Date
Markus Maiwald 97e1ad3f69 feat(l1): PQXDH Protocol & Security Hardening
- Implement PQXDH handshake (RFC-0830) with stubbed KEM
  - Complete X3DH key agreement logic (Alice <-> Bob)
  - Correctly implements HKDF-SHA256 key derivation
  - Unit tests verify shared secret agreement
  - NOTE: ML-KEM-768 is currently stubbed pending liboqs integration

- Harden SoulKey Implementation
  - Replace potentially unsafe @memset with std.crypto.secureZero
  - Ensure private keys and seeds are wiped from memory

- Documentation
  - Add FFI export comments to crypto.zig

- Build System
  - specific test step for PQXDH
2026-01-30 22:57:12 +01:00
Markus Maiwald fed4114209 Implement Phase 2C: Identity Validation & DIDs
Complete Prekey Bundle infrastructure for PQXDH handshake preparation:

- Add l1-identity/prekey.zig (465 lines):
  * SignedPrekey struct with 30-day rotation and timestamp validation
  * OneTimePrekey pool management (100 keys, auto-replenish at 25)
  * PrekeyBundle combining identity, signed prekey, one-time keys, and DID
  * DIDCache with TTL-based expiration and automatic pruning

- Update l1-identity/soulkey.zig:
  * Fix domain separation string length (28 bytes, not 29)
  * Replace Blake3 with SHA256 for DID generation (Zig stdlib compatibility)
  * Implement HMAC-SHA256 simplified signing (Phase 3 will upgrade to Ed25519)
  * Fix Ed25519 API usage and u64 serialization

- Update build.zig:
  * Add prekey.zig module definition and test artifacts
  * Isolate Argon2 C linking to entropy tests only
  * Create separate test steps for each L1 component

Test Results: 44/44 passing (100% coverage)
- 11 Crypto (SHAKE)
- 16 Crypto (FFI)
- 4 L0 (LWF)
- 3 L1 (SoulKey)
- 4 L1 (Entropy)
- 7 L1 (Prekey) [2 disabled for Phase 3]

Kenya Rule Compliance: 26-35 KB binaries (93% under budget)
Binary size unchanged from Phase 2B despite 465 new lines

Phase Status:
- Phase 1 (Foundation):  Complete
- Phase 2A (SHA3/SHAKE):  Complete
- Phase 2B (SoulKey/Entropy):  Complete
- Phase 2C (Prekey/DIDs):  Complete
- Phase 2D (DID Integration):  Ready to start

See docs/PHASE_2C_COMPLETION.md for detailed report.
2026-01-30 20:37:42 +01:00