Skip to main content

KeyEncapsulation

Trait KeyEncapsulation 

Source
pub trait KeyEncapsulation:
    Identified
    + Send
    + Sync {
    // Required methods
    fn generate(&self) -> Result<(String, String)>;
    fn encapsulate(&self, public_key_hex: &str) -> Result<(String, String)>;
    fn decapsulate(
        &self,
        ciphertext_hex: &str,
        private_key_hex: &str,
    ) -> Result<String>;
}
Expand description

密钥封装(KEM,FIPS 203 ML-KEM):公钥封装 → (密文, 共享密钥);私钥解封装。 公钥、私钥、密文与共享密钥均为十六进制。

Required Methods§

Source

fn generate(&self) -> Result<(String, String)>

生成密钥对,返回 (公钥 hex, 私钥 hex)。

Source

fn encapsulate(&self, public_key_hex: &str) -> Result<(String, String)>

用公钥封装,返回 (密文 hex, 共享密钥 hex)。

Source

fn decapsulate( &self, ciphertext_hex: &str, private_key_hex: &str, ) -> Result<String>

用私钥解封装,返回共享密钥 hex。 注意:ML-KEM 对非法密文执行隐式拒绝(不报错,返回与封装端不同的 伪随机密钥),这是标准行为,不视为错误。

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§