Class KemReceiver
java.lang.Object
net.jrodolfo.java_evolution.java21.key_encapsulation.KemReceiver
Represents the receiver side of a Java 21 KEM exchange.
The receiver owns the asymmetric key pair. It shares the public key with the sender and keeps the private key secret. The private key is later used to decapsulate the sender's encapsulation message.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic KemReceivercreate()Creates a receiver with a fresh X25519 key pair.decapsulate(byte[] encapsulation) Recovers the shared secret from the sender's encapsulation message.Returns the public key that can be shared with the sender.
-
Field Details
-
KEY_PAIR_ALGORITHM
The key agreement key type used by this compact example.- See Also:
-
KEM_ALGORITHM
The Java 21 KEM algorithm name used by the standard API.- See Also:
-
-
Method Details
-
create
Creates a receiver with a fresh X25519 key pair.- Returns:
- a receiver ready to publish its public key
- Throws:
NoSuchAlgorithmException- if X25519 is not available from the active providers
-
publicKey
Returns the public key that can be shared with the sender.- Returns:
- the receiver public key
-
decapsulate
public SecretKey decapsulate(byte[] encapsulation) throws NoSuchAlgorithmException, InvalidKeyException, DecapsulateException Recovers the shared secret from the sender's encapsulation message.- Parameters:
encapsulation- the byte message produced by the sender- Returns:
- the receiver-side shared secret
- Throws:
NoSuchAlgorithmException- if DHKEM is not available from the active providersInvalidKeyException- if the receiver private key cannot be used for DHKEMDecapsulateException- if the encapsulation message cannot be decapsulated
-