Record Class EncapsulatedSecret
java.lang.Object
java.lang.Record
net.jrodolfo.java_evolution.java21.key_encapsulation.EncapsulatedSecret
- Record Components:
secretKey- the sender-side shared secretencapsulation- the message sent to the receiver
Holds the two pieces produced by the sender side of a KEM exchange.
The secretKey is local key material. It is not sent over the network.
The encapsulation is the byte message that can be sent to the
receiver. The receiver combines that message with its private key to recover
the same shared secret.
-
Constructor Summary
ConstructorsConstructorDescriptionEncapsulatedSecret(SecretKey secretKey, byte[] encapsulation) Creates an immutable holder for the encapsulation bytes. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Returns the value of theencapsulationrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.byte[]Returns the encoded shared secret bytes for demonstration and testing.Returns the value of thesecretKeyrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
EncapsulatedSecret
Creates an immutable holder for the encapsulation bytes.
-
-
Method Details
-
encapsulation
public byte[] encapsulation()Returns the value of theencapsulationrecord component.- Returns:
- the value of the
encapsulationrecord component
-
secretBytes
public byte[] secretBytes()Returns the encoded shared secret bytes for demonstration and testing.Real applications should usually pass key material into a key derivation step instead of printing or comparing raw bytes directly.
- Returns:
- a defensive copy of the sender-side secret bytes
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
secretKey
-