docs

你正在阅读 v0.1.2 的文档。Nabi 0.1.2 已不再提供支持。 最新版本:v0.1.3 →

core::crypto::mlkem

本页内容

API 参考只有英文版,由标准库源代码中的英文文档注释生成。

ML-KEM-768 (FIPS 203): k = 3, eta1 = eta2 = 2, du = 10, dv = 4.

Polynomials are 256 coefficients in [0, q) held in secret storage (SecretWords; a vector of k polynomials is one buffer of 256k), and so are the secret seeds, keys and messages. Secret values never steer a branch or an index: reduction is an exact multiply-shift division by q, the re-encryption compare and the implicit-rejection key select are masks. Only the rejection sampling of the public matrix branches.

Structs

DecapsulationKey768Source

pub struct DecapsulationKey768

An ML-KEM-768 decapsulation key (the 2400-byte expanded encoding) in secret storage. It has one owner (let b = a moves it); wipe and its release clear it.

  • pub fn from_seed<D: AsBytes, Z: AsBytes>(d: D, z: Z) throws (ValueError) -> DecapsulationKey768§

    Source

    KeyGen from 32-byte seeds d and z (the deterministic _internal form: the caller supplies the random seeds).

  • pub fn from_expanded_bytes<B: AsBytes>(bytes: B) throws (ValueError) -> DecapsulationKey768§

    Source

    From the 2400-byte expanded encoding dk_pke || ek || H(ek) || z (FIPS 203 7.3): the low-level form, for keys stored expanded. The stored H(ek) must match the encapsulation key.

  • pub fn to_expanded_bytes(self) -> Secret§

    Source

    A copy of the 2400-byte expanded encoding.

  • pub fn encapsulation_key(self) -> EncapsulationKey768§

    Source

    The public key that pairs with this one.

  • pub fn decapsulate<C: AsBytes>(self, c: C) throws (ValueError) -> Secret§

    Source

    Decaps: the shared key, or (implicit rejection) a key derived from z and c when c does not re-encrypt to itself.

  • pub fn wipe(self)§

    Source

    Overwrite the key with zeros now (every copy shares it).

Trait implementations 3
  • impl !Sync for DecapsulationKey768
  • impl Drop for DecapsulationKey768
  • impl Debug for DecapsulationKey768

EncapsulationKey768Source

pub struct EncapsulationKey768

An ML-KEM-768 encapsulation key, checked (FIPS 203 7.2).

  • pub const LEN: usize = 1184§

    Source

    The encoded key length in bytes.

  • pub const CIPHERTEXT_LEN: usize = 1088§

    Source

    The ciphertext length in bytes.

  • pub fn from_bytes<B: AsBytes>(bytes: B) throws (ValueError) -> EncapsulationKey768§

    Source

    From the 1184-byte encoding: every coefficient below q (the modulus check of FIPS 203 7.2).

  • pub const fn to_bytes(self) -> List<u8>§

    Source

    The key's encoded bytes.

  • pub fn encapsulate<M: AsBytes>(self, m: M) throws (ValueError) -> (Secret, List<u8>)§

    Source

    Encaps with the 32-byte message m (the deterministic _internal form): (shared key, ciphertext).

Trait implementations 1
  • impl Debug for EncapsulationKey768

Constants

SHARED_KEY_LENSource

pub const SHARED_KEY_LEN: usize = 32

The shared key length.