net.i2p.router.message

## Class GarlicMessageReceiver

- java.lang.Object
- - net.i2p.router.message.GarlicMessageReceiver

-     public class GarlicMessageReceiver
      extends Object

  Handles the reception and decryption of GarlicMessages. Decrypts the garlic message using the appropriate keys, validates each garlic clove, and passes valid cloves to the configured `GarlicMessageReceiver.CloveReceiver` for dispatch. This class supports decryption keys of various types including ElGamal, ECIES, and PQ keys, and performs key selection based on availability. The receiver can be configured to target a specific client destination, allowing session-key and tunnel settings to be applied accordingly.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `GarlicMessageReceiver.CloveReceiver` Interface for handling decrypted garlic cloves.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GarlicMessageReceiver(RouterContext context, GarlicMessageReceiver.CloveReceiver receiver)` Constructs a GarlicMessageReceiver without targeting a specific client destination.
    `GarlicMessageReceiver(RouterContext context, GarlicMessageReceiver.CloveReceiver receiver, Hash clientDestination)` Constructs a GarlicMessageReceiver targeting a specific client destination.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `receive(GarlicMessage message)` Processes a received GarlicMessage by attempting to decrypt it with the appropriate keys.

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

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

- - ### Constructor Detail

    - #### GarlicMessageReceiver

          public GarlicMessageReceiver(RouterContext context,
                                       GarlicMessageReceiver.CloveReceiver receiver)

      Constructs a GarlicMessageReceiver without targeting a specific client destination.
      Parameters:
        `context` - The router context containing necessary services.
        `receiver` - The non-null CloveReceiver to handle valid cloves.

    - #### GarlicMessageReceiver

          public GarlicMessageReceiver(RouterContext context,
                                       GarlicMessageReceiver.CloveReceiver receiver,
                                       Hash clientDestination)

      Constructs a GarlicMessageReceiver targeting a specific client destination.
      Parameters:
        `context` - The router context containing necessary services.
        `receiver` - The non-null CloveReceiver to handle valid cloves.
        `clientDestination` - The client destination hash this receiver targets, or null to target self.

  - ### Method Detail

    - #### receive

          public void receive(GarlicMessage message)

      Processes a received GarlicMessage by attempting to decrypt it with the appropriate keys. Valid cloves are passed to the configured CloveReceiver. If decryption fails, statistics and message history are updated accordingly.
      Parameters:
        `message` - The incoming GarlicMessage to be processed.