# Package net.i2p.router.crypto.ratchet

Implementation of ECIES-X25519-AEAD-Ratchet cryptographic protocol (I2P proposal 144), providing forward secrecy and enhanced security for I2P transport communications.

See: Description

- Interface Summary
  Interface | Description
  --- | ---
  RatchetPayload.PayloadCallback | For all callbacks, recommend throwing exceptions only from the handshake.
  ReplyCallback | Callback interface for ratchet acknowledgment notifications with expiration support
  SessionTagListener | Interface for managing session tag lifecycle in ratchet tag sets

- Class Summary
  Class | Description
  --- | ---
  ACKTimer | Timer for sending ratchet-layer acknowledgments when application responses are delayed, supporting NS, NSR, ACK requests, and forward next key blocks The vast majority of these will be cancelled before firing, when streaming sends a response.
  ArrayUtils | Utility methods for creating unpadded arrays with optimal growth sizing
  ContainerHelpers | Binary search utilities for array operations without argument validation overhead
  ECIESAEADEngine | ECIES+AEAD encryption engine providing New Session, New Session Reply, and Existing Session message handling No, this does not extend ElGamalAESEngine or AEADEngine or CryptixAEADEngine.
  Elg2KeyFactory | Threaded factory for pre-calculating Elligator2-encoded X25519 key pairs to prevent Diffie-Hellman computation bottlenecks in critical paths Try to keep DH pairs at the ready.
  Elg2KeyPair | X25519 key pair with pre-calculated Elligator2-encoded public key
  Elligator2 | Elligator2 encoding and decoding for X25519 public keys to provide cryptographically indistinguishable representations Ported from the Jan.
  GrowingArrayUtils | Helper methods for efficient primitive array growth and insertion operations, treating array length as capacity rather than element count for optimal performance All methods in this class assume that the length of an array is equivalent to its capacity and NOT to number of elements in the array.
  MuxedEngine | Multiplexed decryption engine supporting both ElGamal and ECIES+AEAD with adaptive ordering
  MuxedPQEngine | Post-quantum hybrid decryption engine supporting both ECIES and ML-KEM with adaptive ordering
  MuxedPQSKM | Post-quantum hybrid session key manager combining ECIES and ML-KEM operations
  MuxedSKM | Multiplexed session key manager combining ECIES and post-quantum key management
  NextSessionKey | X25519 public key with identifier for next session key exchange in ratchet protocol
  RatchetEntry | Container for outbound ratchet encryption data including tag, key, nonce, and optional next session keys for message preparation The object returned from SKM.consumeNextAvailableTag() to the engine encrypt.
  RatchetPayload | Ratchet payload generation and parsing
  RatchetPayload.AckBlock | Acknowledgment block for ratchet payload.
  RatchetPayload.AckRequestBlock | Acknowledgment request block for ratchet payload.
  RatchetPayload.Block | Base class for blocks to be transmitted.
  RatchetPayload.DateTimeBlock | Timestamp block for ratchet payload synchronization and timing
  RatchetPayload.GarlicBlock | Garlic clove block for embedding I2NP messages in ratchet payload
  RatchetPayload.NextKeyBlock | Next session key block for ratchet key exchange operations
  RatchetPayload.OptionsBlock | Options block for ratchet protocol configuration and negotiation
  RatchetPayload.PaddingBlock | Padding block for ratchet payload size alignment and obfuscation
  RatchetPayload.PNBlock | Packet number block for ratchet payload.
  RatchetPayload.TerminationBlock | Termination block for ratchet session closure with reason codes
  RatchetSessionTag | 8-byte session tag for ratchet protocol messages with efficient long-based storage representation for memory optimization Does not extend SessionTag or DataStructure to save space
  RatchetSKM | Session key manager for ratchet encryption.
  RatchetTagSet | Manages session tags and keys for a single ratchet direction with automatic key generation, supporting both inbound lookahead and on-demand outbound operations For outbound, uses very little memory.
  SessionKeyAndNonce | Session key with nonce and optional handshake state for ratchet message encryption and decryption operations, supporting nonces up to 65535 This is what is returned from RatchetTagSet.consume().
  SingleTagSet | Single-use tag set for handling inbound Existing Session messages in database replies with fixed nonce of 0, designed for DSM/DSRM response processing
  SparseArray<E> | Memory-efficient sparse array implementation for integer-to-object mappings using binary search lookup, optimized for collections with up to hundreds of items
  SplitKeys | Container for Noise protocol split keys that prevents duplicate HKDF calculations by sharing derived keys between engine and session key manager components

## Package net.i2p.router.crypto.ratchet Description

Implementation of ECIES-X25519-AEAD-Ratchet cryptographic protocol (I2P proposal 144), providing forward secrecy and enhanced security for I2P transport communications.

This package provides:

- Double ratchet algorithm implementation
- X25519 key exchange integration
- AEAD (Authenticated Encryption with Associated Data)
- ECIES (Elliptic Curve Integrated Encryption Scheme)
- Key derivation and rotation

The ratchet protocol provides forward secrecy by regularly rotating encryption keys, ensuring that compromising long-term keys does not compromise past communications. This implementation follows proposal 144 for integrating ECIES with X25519 and AEAD.

Since 0.9.44. Subject to change, not a public API, not for external use.