Commit 489ecb3
refactor(crypto): split aead.rs into focused modules (REFACTOR-001, 8 SP)
Split monolithic 1,529 LOC aead.rs into 4 focused modules for improved
maintainability, testability, and code organization.
New module structure (aead/):
- cipher.rs (488 LOC): Core AEAD types
- Nonce: 24-byte XChaCha20 nonce with counter and random modes
- Tag: 16-byte Poly1305 authentication tag
- AeadKey: 32-byte key with encrypt/decrypt/in-place operations
- AeadCipher: Legacy API wrapper
- Key commitment for key-committing AEAD
- 9 cipher tests
- replay.rs (264 LOC): Replay protection
- ReplayProtection: 256-bit sliding window
- Constant-time comparison via subtle crate
- Multi-word bit shifting for window advancement
- 7 replay tests
- session.rs (457 LOC): Session management
- SessionCrypto: Bidirectional encrypted communication
- BufferPool: Zero-allocation buffer reuse
- Key commitment in AAD for key-committing AEAD
- Automatic nonce counter management
- 7 session tests
- mod.rs (42 LOC): Public re-exports
- All types re-exported for backward compatibility
- Module documentation
Benefits:
- Single responsibility per module
- Easier testing and maintenance
- Clearer dependency boundaries
- Reduced cognitive load (4 small files vs 1 large)
- 278 LOC reduction (-18%) through deduplication
All 23 AEAD tests preserved and passing.
No API changes - full backward compatibility maintained.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 40056f6 commit 489ecb3
File tree
6 files changed
+1261
-1530
lines changed- crates/wraith-crypto/src
- aead
6 files changed
+1261
-1530
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
31 | 40 | | |
32 | 41 | | |
33 | 42 | | |
34 | | - | |
| 43 | + | |
35 | 44 | | |
36 | 45 | | |
37 | 46 | | |
| |||
0 commit comments