#[non_exhaustive]pub struct MlKem1024EncapKey(/* private fields */);Expand description
Public encapsulation key.
Implementations§
Source§impl MlKem1024EncapKey
impl MlKem1024EncapKey
Sourcepub fn from_bytes(bytes: [u8; 1568]) -> Self
pub fn from_bytes(bytes: [u8; 1568]) -> 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 MlKem1024EncapKey
impl MlKem1024EncapKey
Sourcepub fn encapsulate<R: RngCore + CryptoRng>(
&self,
rng: &mut R,
) -> Result<(MlKem1024Ciphertext, SharedSecret), KyberLibError>
pub fn encapsulate<R: RngCore + CryptoRng>( &self, rng: &mut R, ) -> Result<(MlKem1024Ciphertext, SharedSecret), KyberLibError>
Encapsulate against this public key under ML-KEM-1024.
§Errors
KyberLibError::InvalidKey if the key fails the FIPS 203
§7.2 modulus check; KyberLibError::RandomBytesGeneration if
the RNG fails.
Source§impl MlKem1024EncapKey
impl MlKem1024EncapKey
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 MlKem1024EncapKey
impl Clone for MlKem1024EncapKey
Source§fn clone(&self) -> MlKem1024EncapKey
fn clone(&self) -> MlKem1024EncapKey
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 MlKem1024EncapKey
Source§impl Debug for MlKem1024EncapKey
impl Debug for MlKem1024EncapKey
impl Eq for MlKem1024EncapKey
Source§impl PartialEq for MlKem1024EncapKey
impl PartialEq for MlKem1024EncapKey
impl StructuralPartialEq for MlKem1024EncapKey
Auto Trait Implementations§
impl Freeze for MlKem1024EncapKey
impl RefUnwindSafe for MlKem1024EncapKey
impl Send for MlKem1024EncapKey
impl Sync for MlKem1024EncapKey
impl Unpin for MlKem1024EncapKey
impl UnsafeUnpin for MlKem1024EncapKey
impl UnwindSafe for MlKem1024EncapKey
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