Class KemSender

java.lang.Object
net.jrodolfo.java_evolution.java21.key_encapsulation.KemSender

public class KemSender extends Object
Represents the sender side of a Java 21 KEM exchange.

The sender receives the receiver's public key, creates a shared secret, and creates an encapsulation message. The sender keeps the shared secret locally and sends only the encapsulation message to the receiver.

  • Method Details

    • forReceiver

      public static KemSender forReceiver(PublicKey receiverPublicKey) throws NoSuchAlgorithmException, InvalidKeyException
      Creates a sender that can encapsulate a secret for the supplied receiver.
      Parameters:
      receiverPublicKey - the public key published by the receiver
      Returns:
      a sender bound to the receiver public key
      Throws:
      NoSuchAlgorithmException - if DHKEM is not available from the active providers
      InvalidKeyException - if the public key cannot be used for DHKEM
    • encapsulate

      public EncapsulatedSecret encapsulate()
      Creates the sender-side secret and the encapsulation message.
      Returns:
      the shared secret and the message that should be sent to the receiver
    • providerName

      public String providerName()
      Returns the provider name selected by the Java Cryptography Architecture.
      Returns:
      the provider that implements this KEM operation