pub struct PublicKey1024 { /* private fields */ }Expand description
ML-KEM-1024 encapsulation key (public key) as defined in FIPS 203.
See SecretKey1024 for a full usage example.
Implementations§
Source§impl PublicKey1024
impl PublicKey1024
Sourcepub fn from_bytes(bytes: &[u8; 1568]) -> Result<Self, MlKemError>
pub fn from_bytes(bytes: &[u8; 1568]) -> Result<Self, MlKemError>
Parses an encapsulation key from its FIPS 203 encoding.
Returns MlKemError::InvalidKey when the encoded t̂ is not
canonical, i.e. when any of its coefficients is not in [0, q-1]
(FIPS 203 Section 7.2 modulus check).
Sourcepub fn encapsulate(&self) -> Result<([u8; 32], [u8; 1568]), MlKemError>
pub fn encapsulate(&self) -> Result<([u8; 32], [u8; 1568]), MlKemError>
Encapsulates a fresh random shared secret against this public key.
Returns MlKemError::Random when the operating system’s random
number generator is unavailable or fails.
Sourcepub fn encapsulate_derand(&self, coins: &[u8; 32]) -> ([u8; 32], [u8; 1568])
pub fn encapsulate_derand(&self, coins: &[u8; 32]) -> ([u8; 32], [u8; 1568])
Encapsulates a shared secret against this public key using the provided
32-byte coins as the encapsulation randomness.
This is the deterministic counterpart of PublicKey1024::encapsulate,
useful for reproducing FIPS 203 / ACVP test vectors. It must not be used
with repeated coins.