#[non_exhaustive]pub struct MlKem512EncapKey(/* private fields */);Expand description
Public encapsulation key.
Implementations§
Source§impl MlKem512EncapKey
impl MlKem512EncapKey
Sourcepub fn from_bytes(bytes: [u8; 800]) -> Self
pub fn from_bytes(bytes: [u8; 800]) -> Self
Construct from raw bytes.
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
KyberLibError::InvalidLength on length mismatch.
Source§impl MlKem512EncapKey
impl MlKem512EncapKey
Sourcepub fn encapsulate<R: RngCore + CryptoRng>(
&self,
rng: &mut R,
) -> Result<(MlKem512Ciphertext, SharedSecret), KyberLibError>
pub fn encapsulate<R: RngCore + CryptoRng>( &self, rng: &mut R, ) -> Result<(MlKem512Ciphertext, SharedSecret), KyberLibError>
Encapsulate against this public key under ML-KEM-512.
§Errors
KyberLibError::InvalidKey if the key fails the FIPS 203
§7.2 modulus check; KyberLibError::RandomBytesGeneration if
the RNG fails.
Source§impl MlKem512EncapKey
impl MlKem512EncapKey
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 MlKem512EncapKey
impl Clone for MlKem512EncapKey
Source§fn clone(&self) -> MlKem512EncapKey
fn clone(&self) -> MlKem512EncapKey
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for MlKem512EncapKey
Source§impl Debug for MlKem512EncapKey
impl Debug for MlKem512EncapKey
impl Eq for MlKem512EncapKey
Source§impl PartialEq for MlKem512EncapKey
impl PartialEq for MlKem512EncapKey
impl StructuralPartialEq for MlKem512EncapKey
Auto Trait Implementations§
impl Freeze for MlKem512EncapKey
impl RefUnwindSafe for MlKem512EncapKey
impl Send for MlKem512EncapKey
impl Sync for MlKem512EncapKey
impl Unpin for MlKem512EncapKey
impl UnsafeUnpin for MlKem512EncapKey
impl UnwindSafe for MlKem512EncapKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more