#[non_exhaustive]pub struct MlKem768EncapKey(/* private fields */);Expand description
ML-KEM-768 encapsulation key (public). 1184 bytes.
Implementations§
Source§impl MlKem768EncapKey
impl MlKem768EncapKey
Sourcepub fn from_bytes(bytes: [u8; 1184]) -> Self
pub fn from_bytes(bytes: [u8; 1184]) -> Self
Construct from raw bytes — typically the receiving side of a wire-format decode.
Sourcepub fn try_from_slice(bytes: &[u8]) -> Result<Self, KyberLibError>
pub fn try_from_slice(bytes: &[u8]) -> Result<Self, KyberLibError>
Construct from a borrowed slice, validating the length.
§Errors
Returns KyberLibError::InvalidLength if bytes.len() != KYBER_PUBLIC_KEY_BYTES.
Source§impl MlKem768EncapKey
impl MlKem768EncapKey
Sourcepub fn encapsulate<R: RngCore + CryptoRng>(
&self,
rng: &mut R,
) -> Result<(MlKem768Ciphertext, SharedSecret), KyberLibError>
pub fn encapsulate<R: RngCore + CryptoRng>( &self, rng: &mut R, ) -> Result<(MlKem768Ciphertext, SharedSecret), KyberLibError>
Encapsulate against this public key. Returns the ciphertext and the resulting shared secret.
§Errors
Returns KyberLibError::InvalidKey if the key fails the
FIPS 203 §7.2 modulus check, or
KyberLibError::RandomBytesGeneration if the supplied RNG
fails.
Source§impl MlKem768EncapKey
impl MlKem768EncapKey
Sourcepub fn validate(&self) -> Result<(), KyberLibError>
pub fn validate(&self) -> Result<(), KyberLibError>
Runs the FIPS 203 §7.2 encapsulation-key check: every encoded 12-bit coefficient must be below q = 3329. The length (type) check is enforced by the type itself.
Self::encapsulate runs the same check; call this to
reject a key when it is imported.
§Errors
KyberLibError::InvalidKey if a coefficient is not
reduced modulo q.
Trait Implementations§
Source§impl Clone for MlKem768EncapKey
impl Clone for MlKem768EncapKey
Source§fn clone(&self) -> MlKem768EncapKey
fn clone(&self) -> MlKem768EncapKey
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more