Returns the encapsulation scheme.
The bytes (a view; do not mutate).
StaticcodecTagged-CBOR codec; the tag value selects the scheme, as the reference's TryFrom<CBOR>.
StaticfromCreate an EncapsulationPrivateKey from an X25519PrivateKey.
StaticfromCreate an EncapsulationPrivateKey from raw X25519 private key bytes.
StaticfromCreate an EncapsulationPrivateKey from an MLKEMPrivateKey.
StaticfromCreate an EncapsulationPrivateKey from raw MLKEM private key bytes.
StaticrandomA fresh random value; pass rng to make it deterministic.
StaticrandomA fresh ML-KEM private key at level; pass rng to make it deterministic.
StatickeypairA fresh private key and its public key.
StaticmlkemA fresh ML-KEM private key at level and its public key.
Returns true if this is an X25519 private key.
Returns true if this is an MLKEM private key.
Returns the X25519 private key if this is an X25519 encapsulation key.
Returns the MLKEM private key if this is an MLKEM encapsulation key.
Returns the X25519 private key if available, or null.
Returns the MLKEM private key if available, or null.
The public key corresponding to this private key.
Only an X25519 key derives its public key. For an ML-KEM key this
throws Crypto (Deriving ML-KEM public key not supported), as the
reference does: keep the public key mlkemKeypair hands out.
Decapsulate a shared secret from ciphertext.
The ciphertext from encapsulation
The decapsulated shared secret
Compare with another EncapsulationPrivateKey.
The reference's Display: EncapsulationPrivateKey(<short reference>, <inner key>).
Returns a unique reference to this EncapsulationPrivateKey instance.
The reference is derived from the SHA-256 hash of the tagged CBOR representation, providing a unique, content-addressable identifier.
Returns the CBOR tags associated with this private key.
Returns the untagged CBOR encoding.
The tagged CBOR form; the tag follows the scheme.
StaticfromDecode tagged (X25519 or ML-KEM) or untagged (X25519) CBOR.
Represents a private key for key encapsulation.
Use this to decapsulate a shared secret from ciphertext.