Skip to main content

Module post_quantum

Module post_quantum 

Source
Expand description

Copyright © 2025-2026 Wenze Wei. All Rights Reserved.

This file is part of Ri. The Ri project belongs to the Dunimd Team.

Licensed under the Apache License, Version 2.0 (the “License”); You may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

§Post-Quantum Cryptography Module

This module provides post-quantum cryptographic algorithms that are resistant to attacks from both classical and quantum computers. It implements:

  • Kyber: IND-CCA2 secure key encapsulation mechanism (KEM)
  • Dilithium: Strongly secure digital signature algorithm
  • Falcon: Compact digital signature algorithm

These algorithms are based on hard problems in lattice theory and have been selected by NIST for standardization in the post-quantum cryptography competition.

§Security Status

⚠️ IMPORTANT: This module provides the API structure for post-quantum cryptography. For production use, integrate an audited library:

  • liboqs (Recommended): https://github.com/open-quantum-safe/liboqs

    • NIST PQC competition reference implementation
    • Actively maintained and audited
    • Supports all major platforms including Windows, Linux, macOS
  • pqm4: https://github.com/mupq/pqm4

    • For ARM Cortex-M4 microcontrollers

§Integration Example

Add to your Cargo.toml:

[dependencies]
liboqs = "0.7"

Then enable the protocol feature:

cargo build --features protocol

§API Structure

use ri::protocol::post_quantum::{KyberKEM, DilithiumSigner};

// Kyber key encapsulation (requires liboqs integration)
let kem = KyberKEM::new();
let (public_key, secret_key) = kem.keygen()?;
let (ciphertext, shared_secret_1) = kem.encapsulate(&public_key)?;
let shared_secret_2 = kem.decapsulate(&ciphertext, &secret_key)?;

// Dilithium signing (requires liboqs integration)
let signer = DilithiumSigner::new();
let (pk, sk) = signer.keygen()?;
let message = b"Hello, Post-Quantum World!";
let signature = signer.sign(&sk, message)?;
assert!(signer.verify(&pk, message, &signature));

Re-exports§

pub use super::kyber::KyberKEM;
pub use super::kyber::KyberPublicKey;
pub use super::kyber::KyberSecretKey;
pub use super::kyber::KyberCiphertext;
pub use super::dilithium::DilithiumSigner;
pub use super::dilithium::DilithiumPublicKey;
pub use super::dilithium::DilithiumSecretKey;
pub use super::dilithium::DilithiumSignature;
pub use super::falcon::FalconSigner;
pub use super::falcon::FalconPublicKey;
pub use super::falcon::FalconSecretKey;
pub use super::falcon::FalconSignature;

Structs§

KEMResult
RiPostQuantumManager

Enums§

RiPostQuantumAlgorithm