Skip to main content

public_key_from_slice

Function public_key_from_slice 

Source
pub fn public_key_from_slice<P: MlKemParams>(
    bytes: &[u8],
) -> Result<P::PublicKeyBytes, KyberLibError>
Expand description

Validate a borrowed byte slice and copy it into the parameter-set’s concrete PublicKeyBytes buffer.

§Errors

KyberLibError::InvalidLength if bytes.len() != P::PUBLIC_KEY_BYTES.

§Example

use kyberlib::{MlKem768, paramsets::public_key_from_slice};

let pk_bytes = [0u8; 1184];
let buf = public_key_from_slice::<MlKem768>(&pk_bytes).unwrap();
assert_eq!(buf.len(), 1184);