pub struct SecretKey(/* private fields */);Expand description
The private key used for key encapsulation and encryption.
The X-Wing KEM is used which uses ML-KEM-768 (Kyber) and X25519 under the hood.
Implementations§
Source§impl SecretKey
impl SecretKey
Sourcepub fn from_seed(seed: &[u8; 32]) -> Self
pub fn from_seed(seed: &[u8; 32]) -> Self
Construct a secret key from a raw 32-byte X-Wing seed.
Sourcepub fn generate() -> Result<Self, Error>
pub fn generate() -> Result<Self, Error>
Generate a new secret key from the operating system CSPRNG.
The randomness source is owned by the library rather than caller-supplied:
a deterministic or repeated RNG would produce a predictable or duplicated
key seed, exposing the secret key. For deterministic derivation from a
known seed, use SecretKey::from_seed.
§Errors
Error::Rng if the operating system CSPRNG is unavailable.
Sourcepub fn public_key(&self) -> PublicKey
pub fn public_key(&self) -> PublicKey
Derive the corresponding PublicKey.
Source§impl SecretKey
impl SecretKey
Sourcepub fn unseal(
recipient: &SecretKey,
ciphertext: &[u8],
info: Option<&[u8]>,
) -> Result<Vec<u8>, Error>
pub fn unseal( recipient: &SecretKey, ciphertext: &[u8], info: Option<&[u8]>, ) -> Result<Vec<u8>, Error>
Unseal ciphertext with the recipient’s secret key.
§Returns
The opened plaintext.
§Errors
Error::EmptyCiphertextif the ciphertext is empty.Error::Decodeif the ciphertext is invalidError::UnsupportedVersionif the header specifies an unsupported version.Error::UnsupportedSuiteif the header specifices an unsupported cryptographic suite.Error::Unsealif the ciphertext cannot be unsealed.
Trait Implementations§
impl Eq for SecretKey
impl StructuralPartialEq for SecretKey
impl ZeroizeOnDrop for SecretKey
SecretKey wraps hpke’s X-Wing PrivateKey, which stores an
x_wing::DecapsulationKey. That key implements ZeroizeOnDrop, so
dropping a SecretKey wipes the only secret it holds.