net.i2p.router.crypto.ratchet

## Class RatchetPayload

- java.lang.Object
- - net.i2p.router.crypto.ratchet.RatchetPayload

-     class RatchetPayload
      extends Object

  Ratchet payload generation and parsing

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `RatchetPayload.AckBlock` Acknowledgment block for ratchet payload.
    `static class` | `RatchetPayload.AckRequestBlock` Acknowledgment request block for ratchet payload.
    `static class` | `RatchetPayload.Block` Base class for blocks to be transmitted.
    `static class` | `RatchetPayload.DateTimeBlock` Timestamp block for ratchet payload synchronization and timing
    `static class` | `RatchetPayload.GarlicBlock` Garlic clove block for embedding I2NP messages in ratchet payload
    `static class` | `RatchetPayload.NextKeyBlock` Next session key block for ratchet key exchange operations
    `static class` | `RatchetPayload.OptionsBlock` Options block for ratchet protocol configuration and negotiation
    `static class` | `RatchetPayload.PaddingBlock` Padding block for ratchet payload size alignment and obfuscation
    `static interface` | `RatchetPayload.PayloadCallback` For all callbacks, recommend throwing exceptions only from the handshake.
    `static class` | `RatchetPayload.PNBlock` Packet number block for ratchet payload.
    `static class` | `RatchetPayload.TerminationBlock` Termination block for ratchet session closure with reason codes

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `BLOCK_HEADER_SIZE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RatchetPayload()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `processPayload(I2PAppContext ctx, RatchetPayload.PayloadCallback cb, byte[] payload, int off, int length, boolean isHandshake)` Ratchet payload generation and parsing utilities supporting datetime, options, garlic, next key, acknowledgment, and padding blocks for ECIES+AEAD messages
    `static int` | `writePayload(byte[] payload, int off, List<RatchetPayload.Block> blocks)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### BLOCK_HEADER_SIZE

          public static final int BLOCK_HEADER_SIZE

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### RatchetPayload

          RatchetPayload()

  - ### Method Detail

    - #### processPayload

          public static int processPayload(I2PAppContext ctx,
                                           RatchetPayload.PayloadCallback cb,
                                           byte[] payload,
                                           int off,
                                           int length,
                                           boolean isHandshake)
                                    throws IOException,
                                           DataFormatException,
                                           I2NPMessageException

      Ratchet payload generation and parsing utilities supporting datetime, options, garlic, next key, acknowledgment, and padding blocks for ECIES+AEAD messages
      Throws:
        `IOException`
        `DataFormatException`
        `I2NPMessageException`

    - #### writePayload

          public static int writePayload(byte[] payload,
                                         int off,
                                         List<RatchetPayload.Block> blocks)

      Parameters:
        `payload` - writes to it starting at off
      Returns:
        the new offset