package net.i2p.router.crypto.ratchet
The Double Ratchet with X25519 key agreement and ECIES hybrid encryption, used by the NTCP2 and SSU transports for session encryption.
It provides forward secrecy - compromising current key material does not expose past sessions - and post-compromise security, recovering after a few message exchanges. Not for use by apps, clients or plugins.
See also: The Double Ratchet Algorithm.
- ClassDescriptionTimer for sending ratchet-layer acknowledgments when application responses are delayed, supporting NS, NSR, ACK requests, and forward next key blocks.Utility methods for creating unpadded arrays with optimal growth sizing.Binary search utilities for array operations without argument validation overhead.ECIES+AEAD encryption engine providing New Session, New Session Reply, and Existing Session message handlingPer-thread pool of payload block objects and the block list, to avoid allocation per outbound payload.Threaded factory for pre-calculating Elligator2-encoded X25519 key pairs to prevent Diffie-Hellman computation bottlenecks in critical pathsX25519 key pair with pre-calculated Elligator2-encoded public key.Elligator2 encoding and decoding for X25519 public keys to provide cryptographically indistinguishable representationsHelper methods for efficient primitive array growth and insertion.Multiplexed decryption engine supporting both ElGamal and ECIES+AEAD with adaptive ordering.Post-quantum hybrid decryption engine supporting both ECIES and ML-KEM with adaptive ordering.Post-quantum hybrid session key manager combining ECIES and ML-KEM operations.Multiplexed session key manager combining ElGamal and ECIES key management.X25519 public key with identifier for next session key exchange in ratchet protocol.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.Ratchet payload generation and parsing.Acknowledgment block for ratchet payload.Acknowledgment request block for ratchet payload.Base class for blocks to be transmitted.Timestamp block for ratchet payload synchronization and timing.Garlic clove block for embedding I2NP messages in ratchet payload.Next session key block for ratchet key exchange operations.Options block for ratchet protocol configuration and negotiation.Padding block for ratchet payload size alignment and obfuscation.For all callbacks, recommend throwing exceptions only from the handshake.Packet number block for ratchet payload.Termination block for ratchet session closure with reason codes.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.Session key manager for ratchet encryption.Manages session tags and keys for a single ratchet direction with automatic key generation, supporting both inbound lookahead and on-demand outbound operationsCallback interface for ratchet acknowledgment notifications with expiration support.Session key with nonce and optional handshake state for ratchet message encryption and decryption operations, supporting nonces up to 65535Interface for managing session tag lifecycle in ratchet tag sets.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 itemsContainer for Noise protocol split keys that prevents duplicate HKDF calculations by sharing derived keys between engine and session key manager components.