# moon-i2p A clean, zero-dependency, pure-[MoonBit](https://www.moonbitlang.com/) port of the modern **I2P (Invisible Internet Project)** protocol suite targeting `wasm`, `wasm-gc`, `js`, and `native`. ## Architecture & Implemented Modules ``` moon-i2p/ ├── encoding/ # I2P Base64 (-/~), Base32 (.b32.i2p), big-endian Reader/Writer, UTF-8, Hex ├── crypto/ # Pure-MoonBit SHA-256, HMAC-SHA256, HKDF-SHA256, ChaCha20-Poly1305, X25519, SipHash-2-4 ├── common/ # Hash, KeyTypes, Certificate/KeyCertificate, Mapping, Destination, RouterIdentity, RouterInfo, Lease2, LeaseSet2 ├── i2np/ # 16-byte standard & 9-byte NTCP2 short headers, SHA-256 checksums, core I2NP messages ├── noise/ # Noise_XK_25519_ChaChaPoly_SHA256 handshake/transport + NTCP2 SipHash-2-4 length masking ├── sam/ # SAMv3 text protocol parser, serializer, and command builders └── cmd/main/ # Demo CLI entrypoint ``` ### Verified Test Vectors Every cryptographic primitive in `crypto/` is verified against official standards: - **SHA-256**: FIPS 180-4 / NIST test vectors - **HMAC-SHA256**: RFC 4231 test cases 1 & 2 - **HKDF-SHA256**: RFC 5869 test case 1 - **ChaCha20-Poly1305 AEAD**: RFC 8439 Section 2.8.2 - **X25519**: RFC 7748 Sections 5.2 & 6.1 - **SipHash-2-4**: Official SipHash reference test vector ## Running Checks & Tests ```bash moon check moon test moon test --target native moon run cmd/main ``` ## Roadmap 1. **Phase 1–2 (Completed):** Core encoding, pure-MoonBit modern crypto, I2P Common Structures, I2NP messages, `Noise_XK_25519_ChaChaPoly_SHA256` state machine, NTCP2 SipHash length masking, and SAMv3 protocol codec. 2. **Phase 3 (Signatures & Ratchet):** - Pure-MoonBit **Ed25519** signing & verification (`RouterInfo` & `LeaseSet2` signatures). - **ECIES-X25519-AEAD-Ratchet** (Proposal 144) for Garlic encryption & end-to-end sessions. 3. **Phase 4 (Transports & Networking):** - **NTCP2** full TCP transport (AES-256-CBC ephemeral key obfuscation, options/padding blocks, session manager). - **SAMv3** live TCP client for interacting with an existing I2P/i2pd router. 4. **Phase 5 (Router Core):** - **NetDB** & Floodfill DHT (Kademlia XOR routing with daily routing key derivation). - **Tunnel** builder (`ShortTunnelBuild` Proposal 157), layered tunnel encryption, and tunnel pool management. - **Streaming** & **Repliable Datagrams** libraries.