pub struct ContactKeyPair { /* private fields */ }Expand description
Hybrid X25519 + ML-KEM-768 contact keypair.
The private material is stored as a versioned Lockbox binary record in
SecretVec. The public contact key is cached separately for wrapping new
content keys.
Implementations§
Source§impl ContactKeyPair
impl ContactKeyPair
Sourcepub fn generate() -> Result<ContactKeyPair, Error>
pub fn generate() -> Result<ContactKeyPair, Error>
Generate a fresh hybrid X25519 + ML-KEM-768 keypair.
Returns Error::SecurityLimitExceeded if the private record cannot be
stored in secure memory.
Sourcepub fn encrypt(&self, content_key: &[u8]) -> Result<ContactWrappedKey, Error>
pub fn encrypt(&self, content_key: &[u8]) -> Result<ContactWrappedKey, Error>
Encrypt a content key to this keypair’s public contact key.
Returns Error::InvalidKey if authenticated wrapping fails.
Sourcepub fn decrypt(&self, wrapped: &ContactWrappedKey) -> Result<Vec<u8>, Error>
pub fn decrypt(&self, wrapped: &ContactWrappedKey) -> Result<Vec<u8>, Error>
Decrypt a content key previously encrypted for this keypair.
Returns Error::InvalidKey if authenticated decrypt fails,
Error::InvalidKeyMaterial if the stored private key cannot be decoded,
or Error::SecurityLimitExceeded if secure memory access fails.
Sourcepub fn public_key(&self) -> ContactPublicKey
pub fn public_key(&self) -> ContactPublicKey
Return the public contact key for this keypair.
Sourcepub fn from_private_key_record(
private_key_bytes: SecureVec,
) -> Result<ContactKeyPair, Error>
pub fn from_private_key_record( private_key_bytes: SecureVec, ) -> Result<ContactKeyPair, Error>
Construct a keypair by taking ownership of a private key record buffer.
Returns Error::InvalidKeyMaterial if the bytes do not encode a
supported Lockbox hybrid contact private key, or
Error::SecurityLimitExceeded if secure memory access fails.
Sourcepub fn private_key_record(&self) -> Result<SecureVec, Error>
pub fn private_key_record(&self) -> Result<SecureVec, Error>
Clone the private key record into a new SecretVec.
Returns Error::SecurityLimitExceeded if secure memory allocation
fails.