kyber-rust

Crates.iokyber-rust
lib.rskyber-rust
version0.2.1
sourcesrc
created_at2024-09-20 11:46:48.183396
updated_at2024-09-24 02:43:08.278769
descriptionA Rust wrapper for the Kyber post-quantum key encapsulation mechanism
homepage
repositoryhttps://github.com/goldenhippo58/kyber-rust
max_upload_size
id1381158
size113,773
(goldenhippo58)

documentation

README

Kyber-Rust

A Rust wrapper for the Kyber post-quantum key encapsulation mechanism.

Overview

This crate provides a safe Rust interface to the Kyber algorithm, which is a finalist in the NIST Post-Quantum Cryptography standardization process. Kyber is a key encapsulation mechanism (KEM) that is believed to be secure against attacks by quantum computers.

Features

  • Generate Kyber keypairs
  • Encapsulate shared secrets
  • Decapsulate shared secrets
  • Easy-to-use high-level API

Installation

Add this to your Cargo.toml:

[dependencies]
kyber-rust = "0.2.1"

Usage

Here's a basic example of how to use the Kyber-Rust library:

use kyber_rust::{generate_keypair, encapsulate, decapsulate};

fn main() -> Result<(), String> {
    // Generate a keypair
    let (public_key, secret_key) = generate_keypair()?;

    // Encapsulate a shared secret
    let (ciphertext, shared_secret_enc) = encapsulate(&public_key)?;

    // Decapsulate the shared secret
    let shared_secret_dec = decapsulate(&ciphertext, &secret_key)?;

    // Verify that the shared secrets match
    assert_eq!(shared_secret_enc, shared_secret_dec);

    Ok(())
}

Safety

This crate uses unsafe Rust to interface with the C implementation of Kyber. While efforts have been made to ensure safety, users should be aware of the potential risks associated with FFI and unsafe code.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contribution

Contributions are welcome! Please feel free to submit a Pull Request.

Disclaimer

This implementation is for educational and research purposes only. It has not been audited for production use.

Commit count: 5

cargo fmt