{"id":16616893,"url":"https://github.com/sebastienrousseau/kyberlib","last_synced_at":"2025-04-09T07:10:18.635Z","repository":{"id":207989908,"uuid":"720537009","full_name":"sebastienrousseau/kyberlib","owner":"sebastienrousseau","description":"A Robust Rust Library for CRYSTALS-Kyber Post-Quantum Cryptography 🦀","archived":false,"fork":false,"pushed_at":"2025-03-21T20:22:58.000Z","size":433,"stargazers_count":35,"open_issues_count":6,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T05:08:05.614Z","etag":null,"topics":["cryptography","cryptography-algorithms","cryptography-library","crystals-kyber","kyber","kyberlib","no-std","post-quantum","post-quantum-cryptography","post-quantum-kem","quantum-cryptography"],"latest_commit_sha":null,"homepage":"https://kyberlib.com/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sebastienrousseau.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/funding.yml","license":null,"code_of_conduct":".github/CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"sebastienrousseau","custom":"https://paypal.me/wwdseb"}},"created_at":"2023-11-18T19:33:06.000Z","updated_at":"2025-03-10T08:39:55.000Z","dependencies_parsed_at":"2023-11-18T23:25:40.209Z","dependency_job_id":"16afe67c-d57d-45a8-bcd0-7bda6a1a3ee9","html_url":"https://github.com/sebastienrousseau/kyberlib","commit_stats":{"total_commits":115,"total_committers":2,"mean_commits":57.5,"dds":0.4521739130434783,"last_synced_commit":"1aca51d1e951647322bdc53c3c5103f70916ef12"},"previous_names":["sebastienrousseau/kyberlib"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastienrousseau%2Fkyberlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastienrousseau%2Fkyberlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastienrousseau%2Fkyberlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sebastienrousseau%2Fkyberlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sebastienrousseau","download_url":"https://codeload.github.com/sebastienrousseau/kyberlib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247994122,"owners_count":21030050,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cryptography","cryptography-algorithms","cryptography-library","crystals-kyber","kyber","kyberlib","no-std","post-quantum","post-quantum-cryptography","post-quantum-kem","quantum-cryptography"],"created_at":"2024-10-12T02:14:35.040Z","updated_at":"2025-04-09T07:10:18.608Z","avatar_url":"https://github.com/sebastienrousseau.png","language":"Rust","funding_links":["https://github.com/sponsors/sebastienrousseau","https://paypal.me/wwdseb"],"categories":[],"sub_categories":[],"readme":"\u003c!-- markdownlint-disable MD033 MD041 --\u003e\n\n\u003cimg\nsrc=\"https://kura.pro/kyberlib/images/logos/kyberlib.webp\"\nalign=\"right\"\nalt=\"kyberlib's logo\"\nheight=\"261\"\nwidth=\"261\"\n/\u003e\n\n\u003c!-- markdownlint-enable MD033 MD041 --\u003e\n\n# kyberlib\n\nA Robust Rust Library for CRYSTALS-Kyber Post-Quantum Cryptography.\n\n\u003c!-- markdownlint-disable MD033 MD041 --\u003e\n\u003ccenter\u003e\n\u003c!-- markdownlint-enable MD033 MD041 --\u003e\n\n[![Made With Love][made-with-rust]][05] [![Crates.io][crates-badge]][07] [![Lib.rs][libs-badge]][09] [![Docs.rs][docs-badge]][08] [![License][license-badge]][02] [![Codecov][codecov-badge]][15]\n\n• [Website][00] • [Documentation][08] • [Report Bug][03] • [Request Feature][03] • [Contributing Guidelines][04]\n\n\u003c!-- markdownlint-disable MD033 MD041 --\u003e\n\u003c/center\u003e\n\u003c!-- markdownlint-enable MD033 MD041 --\u003e\n\n![divider][divider]\n\n## Overview 📖\n\nKyberLib is a robust Rust library designed for **CRYSTALS-Kyber Post-Quantum Cryptography**, offering strong security guarantees. This library is compatible with `no_std`, making it suitable for embedded devices and avoids memory allocations. Additionally, it contains reference implementations with no unsafe code and provides an optimized AVX2 version by default on x86_64 platforms. You can also compile it to WebAssembly (WASM) using wasm-bindgen.\n\n## Features ✨\n\n### Core Features\n\n- **`no_std` compatible**: No dependence on the Rust standard library\n- **Avoid allocations**: Uses stack-based data structures only\n- **Configurable**: Features to enable different parameter sets\n- **Optimised x86_64**: Uses assembly for performance-critical code, including an optimised AVX2 version by default.\n- **Safe code**: Reference implementations have no `unsafe` blocks\n- **WebAssembly Support**: Can be compiled to WASM using wasm-bindgen.\n\n### Advanced Features\n\n- **Allocation-free Guarantee**: KyberLib guarantees all its core cryptography operations are free of heap allocations.\n- **Assembly Optimizations**: The x86_64 assembly implementations use AVX2 instructions for high performance.\n- **Security**: KyberLib contains no unsafe code in its public API surface.\n\n## Functionality 📚\n\n- **Key Generation**: Create public/private key pairs\n- **Encapsulation**: Encapsulate a shared secret with a public key\n- **Decapsulation**: Decapsulate a shared secret with a private key\n- **Key Exchange**: Perform authenticated key exchanges\n\nSee [Documentation][08] for full API details.\n\n## Getting Started 🚀\n\nIt takes just a few minutes to get up and running with `kyberlib`.\n\n### Requirements\n\nThe minimum supported Rust toolchain version is currently Rust\n**1.60** or later (stable).\n\n### Installation\n\nTo install `kyberlib`, you need to have the Rust toolchain installed on\nyour machine. You can install the Rust toolchain by following the\ninstructions on the [Rust website][13].\n\nOnce you have the Rust toolchain installed, you can install `kyberlib`\nusing the following command:\n\n```shell\ncargo install kyberlib\n```\n\n## Usage 📖\n\nTo use the `kyberlib` library in your project, add the following to your\n`Cargo.toml` file:\n\n```toml\n[dependencies]\nkyberlib = \"0.0.6\"\n```\n\nAdd the following to your `main.rs` file:\n\n```rust\nextern crate kyberlib;\nuse kyberlib::*;\n```\n\nthen you can use the functions in your application code.\n\nFor optimisations on x86 platforms enable the `avx2` feature and the following RUSTFLAGS:\n\n```shell\nexport RUSTFLAGS=\"-C target-feature=+aes,+avx2,+sse2,+sse4.1,+bmi2,+popcnt\"\n```\n\n## Crate Features 📦\n\n### Key Encapsulation\n\n```rust\n// Generate Keypair\nlet keys_bob = keypair(\u0026mut rng)?;\n\n// Alice encapsulates a shared secret using Bob's public key\nlet (ciphertext, shared_secret_alice) = encapsulate(\u0026keys_bob.public, \u0026mut rng)?;\n\n// Bob decapsulates a shared secret using the ciphertext sent by Alice\nlet shared_secret_bob = decapsulate(\u0026ciphertext, \u0026keys_bob.secret)?;\n\nassert_eq!(shared_secret_alice, shared_secret_bob);\n```\n\n### Unilaterally Authenticated Key Exchange\n\n```rust\nlet mut rng = rand::thread_rng();\n\n// Initialize the key exchange structs\nlet mut alice = Uake::new();\nlet mut bob = Uake::new();\n\n// Generate Bob's Keypair\nlet bob_keys = keypair(\u0026mut rng)?;\n\n// Alice initiates key exchange\nlet client_init = alice.client_init(\u0026bob_keys.public, \u0026mut rng)?;\n\n// Bob authenticates and responds\nlet server_response = bob.server_receive(\n  client_init, \u0026bob_keys.secret, \u0026mut rng\n)?;\n\n// Alice decapsulates the shared secret\nalice.client_confirm(server_response)?;\n\n// Both key exchange structs now have the same shared secret\nassert_eq!(alice.shared_secret, bob.shared_secret);\n```\n\n### Mutually Authenticated Key Exchange\n\nFollows the same workflow except Bob requires Alice's public keys:\n\n```rust\nlet mut alice = Ake::new();\nlet mut bob = Ake::new();\n\nlet alice_keys = keypair(\u0026mut rng)?;\nlet bob_keys = keypair(\u0026mut rng)?;\n\nlet client_init = alice.client_init(\u0026bob_keys.public, \u0026mut rng)?;\n\nlet server_response = bob.server_receive(\n  client_init, \u0026alice_keys.public, \u0026bob_keys.secret, \u0026mut rng\n)?;\n\nalice.client_confirm(server_response, \u0026alice_keys.secret)?;\n\nassert_eq!(alice.shared_secret, bob.shared_secret);\n```\n\n## Macros 🦀\n\nThe KyberLib crate provides several macros to simplify common cryptographic operations:\n\n- [`kyberlib_generate_key_pair!`](https://docs.rs/kyberlib/latest/kyberlib/macro.kyberlib_generate_key_pair.html): Generates a public and private key pair for CCA-secure Kyber key encapsulation mechanism.\n\n- [`kyberlib_encrypt_message!`](https://docs.rs/kyberlib/latest/kyberlib/macro.kyberlib_encrypt_message.html): Generates cipher text and a shared secret for a given public key.\n\n- [`kyberlib_decrypt_message!`](https://docs.rs/kyberlib/latest/kyberlib/macro.kyberlib_decrypt_message.html): Generates a shared secret for a given cipher text and private key.\n\n- [`kyberlib_uake_client_init!`](https://docs.rs/kyberlib/latest/kyberlib/macro.kyberlib_uake_client_init.html): Initiates a Unilaterally Authenticated Key Exchange.\n\n- [`kyberlib_uake_server_receive!`](https://docs.rs/kyberlib/latest/kyberlib/macro.kyberlib_uake_server_receive.html): Handles the output of a `kyberlib_uake_client_init()` request.\n\n- [`kyberlib_uake_client_confirm!`](https://docs.rs/kyberlib/latest/kyberlib/macro.kyberlib_uake_client_confirm.html): Decapsulates and authenticates the shared secret from the output of `kyberlib_uake_server_receive()`.\n\n- [`kyberlib_ake_client_init!`](https://docs.rs/kyberlib/latest/kyberlib/macro.kyberlib_ake_client_init.html): Initiates a Mutually Authenticated Key Exchange.\n\n- [`kyberlib_ake_server_receive!`](https://docs.rs/kyberlib/latest/kyberlib/macro.kyberlib_uake_server_receive.html): Handles and authenticates the output of a `kyberlib_ake_client_init()` request.\n\n- [`kyberlib_ake_client_confirm!`](https://docs.rs/kyberlib/latest/kyberlib/macro.kyberlib_ake_client_confirm.html): Decapsulates and authenticates the shared secret from the output of `kyberlib_ake_server_receive()`.\n\nSee the [macros module documentation](https://docs.rs/kyberlib/latest/kyberlib/index.html#macros) for more details and usage examples.\n\n## Errors\n\nThe KyberLibError enum has two variants:\n\n- **InvalidInput** - One or more inputs to a function are incorrectly sized. A possible cause of this is two parties using different security levels while trying to negotiate a key exchange.\n- **InvalidKey** - Error when generating keys.\n- **Decapsulation** - The ciphertext was unable to be authenticated. The shared secret was not decapsulated.\n- **RandomBytesGeneration** - Error trying to fill random bytes (i.e., external (hardware) RNG modules can fail).\n\n## Examples\n\nTo get started with `kyberlib`, you can use the examples provided in the\n`examples` directory of the project.\n\nTo run the examples, clone the repository and run the following command\nin your terminal from the project root directory.\n\n### Example 1: Implements an authenticated key exchange protocol\n\nAlice and Bob exchange public keys to derive a shared secret in a way that authenticates each party.\n\nRun the following command in your terminal from the project root directory.\n\n```shell\ncargo run --example ake\n```\n\n### Example 2: Demonstrates key encapsulation and decapsulation\n\nAlice generates a keypair. Bob encapsulates a secret using Alice's public key. Alice decapsulates the secret using her private key. This allows secure communication.\n\nRun the following command in your terminal from the project root directory.\n\n```shell\ncargo run --example kem\n```\n\n### Example 3: Implements an unauthenticated key exchange protocol\n\nAlice and Bob exchange public information to derive a shared secret without authenticating each other. Provides confidentiality but not authentication.\n\nRun the following command in your terminal from the project root directory.\n\n```shell\ncargo run --example uake\n```\n\n### Platform support\n\n`kyberlib` supports a variety of CPU architectures. It is supported and tested on MacOS, Linux, and Windows.\n\n### Documentation\n\n**Info:** Please check out our [website][00] for more information. You can find our documentation on [docs.rs][08], [lib.rs][09] and\n[crates.io][07].\n\n## Semantic Versioning Policy 🚥\n\nFor transparency into our release cycle and in striving to maintain\nbackward compatibility, `kyberlib` follows [semantic versioning][06].\n\n## License 📝\n\nKyberLib is distributed under the terms of both the MIT license and the\nApache License (Version 2.0).\n\nSee [LICENSE-APACHE][01] and [LICENSE-MIT][02] for details.\n\n## Contribution 🤝\n\nWe welcome all people who want to contribute. Please see the\n[contributing instructions][04] for more information.\n\nContributions in any form (issues, pull requests, etc.) to this project\nmust adhere to the [Rust's Code of Conduct][11].\n\nUnless you explicitly state otherwise, any contribution intentionally\nsubmitted for inclusion in the work by you, as defined in the\nApache-2.0 license, shall be dual licensed as above, without any\nadditional terms or conditions.\n\n## Acknowledgements 💙\n\nA big thank you to all the awesome contributors of [kyberlib][05] for their\nhelp and support.\n\nThis repo is a fork of the innovative Rust implementation of the Kyber\npost-quantum KEM from [Argyle-Software/kyber][14]. We are deeply grateful for\nthe inspiration and contribution of the original project, which has provided a\nsolid foundation for our work and study. Thank you! You can find the original\nrepo [here][14].\n\nA special thank you goes to the [Rust Reddit][12] community for\nproviding a lot of useful suggestions on how to improve this project.\n\n[00]: https://kyberlib.com/ \"KyberLib, A Robust Rust Library for CRYSTALS-Kyber Post-Quantum Cryptography\"\n[01]: http://opensource.org/licenses/Apache-2.0 \"Apache License, Version 2.0\"\n[02]: http://opensource.org/licenses/MIT \"MIT License\"\n[03]: https://github.com/sebastienrousseau/kyberlib/kyberlib/issues \"KyberLib Issues\"\n[04]: https://github.com/sebastienrousseau/kyberlib/kyberlib/blob/main/CONTRIBUTING.md \"KyberLib Contributing Guidelines\"\n[05]: https://github.com/sebastienrousseau/kyberlib/kyberlib/graphs/contributors \"KyberLib Contributors\"\n[06]: http://semver.org/ \"SemVer\"\n[07]: https://crates.io/crates/kyberlib \"KyberLib on Crates.io\"\n[08]: https://docs.rs/kyberlib \"KyberLib on Docs.rs\"\n[09]: https://lib.rs/crates/kyberlib \"KyberLib on Lib.rs\"\n[11]: https://www.rust-lang.org/policies/code-of-conduct \"KyberLib Code of Conduct\"\n[12]: https://www.reddit.com/r/rust/ \"Reddit\"\n[13]: https://www.rust-lang.org/learn/get-started \"Rust\"\n[14]: https://github.com/Argyle-Software/kyber \"Kyber from Argyle-Software\"\n[15]: https://codecov.io/gh/sebastienrousseau/kyberlib \"Codecov\"\n\n[crates-badge]: https://img.shields.io/crates/v/kyberlib.svg?style=for-the-badge 'Crates.io'\n[codecov-badge]: https://img.shields.io/codecov/c/github/sebastienrousseau/kyberlib?style=for-the-badge\u0026token=oEisyTucB5 'Codecov'\n[divider]: https://kura.pro/common/images/elements/divider.svg \"divider\"\n[docs-badge]: https://img.shields.io/docsrs/kyberlib.svg?style=for-the-badge 'Docs.rs'\n[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.6-orange.svg?style=for-the-badge 'Lib.rs'\n[license-badge]: https://img.shields.io/crates/l/kyberlib.svg?style=for-the-badge 'License'\n[made-with-rust]: https://img.shields.io/badge/rust-f04041?style=for-the-badge\u0026labelColor=c0282d\u0026logo=rust 'Made With Rust'\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastienrousseau%2Fkyberlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsebastienrousseau%2Fkyberlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsebastienrousseau%2Fkyberlib/lists"}