Skip to content

Commit a8d3285

Browse files
Merge pull request #33 from sebastienrousseau/feat/kyberlib
v0.0.5
2 parents bf741cc + c3989cc commit a8d3285

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1838
-589
lines changed

Cargo.lock

+32-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+12-7
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,36 @@ license = "MIT OR Apache-2.0"
3030
name = "kyberlib"
3131
readme = "README.md"
3232
repository = "https://github.com/sebastienrousseau/kyberlib"
33-
version = "0.0.4"
33+
version = "0.0.5"
3434

3535
[dependencies]
36+
# Dependencies for the library
3637
aes = { version = "0.8.4", optional = true }
3738
ctr = { version = "0.9.2", optional = true }
39+
pqc_core = { version = "0.3.0", features = ["zero"]}
3840
rand = { version = "0.8.5", default-features = false, features = ["getrandom"] }
3941
rand_core = { version = "0.6.4", default-features = false }
4042
rlg = "0.0.4"
4143
sha2 = { version = "0.10.8", optional = true }
4244
tokio = { version = "1.37.0", optional = true }
4345
wasm-bindgen = "0.2.92"
46+
zeroize = { version = "1.7.0", features = ["derive"] }
4447

4548
[dev-dependencies]
49+
# Dependencies for testing
4650
criterion = "0.5.1"
47-
rand = "0.8.5"
4851
wasm-bindgen-test = "0.3.42"
4952

5053
# benchmarking = ["criterion"]
5154

5255
[build-dependencies]
56+
# Dependencies for the build script
5357
cc = {version = "1.0.97", optional = true }
5458
nasm-rs = {version = "0.3.0", optional = true }
5559

5660
[lib]
57-
crate-type = ["cdylib", "rlib"]
61+
# Metadata about the library
62+
crate-type = ["cdylib", "rlib", "staticlib"]
5863
name = "kyberlib"
5964
path = "src/lib.rs"
6065

@@ -108,12 +113,12 @@ std = []
108113

109114
## Warn
110115
# box_pointers = "warn"
111-
# missing_copy_implementations = "warn"
112-
# missing_docs = "warn"
113-
# unstable_features = "warn"
116+
missing_copy_implementations = "warn"
117+
missing_docs = "warn"
118+
unstable_features = "warn"
114119
# unused_crate_dependencies = "warn"
115120
# unused_extern_crates = "warn"
116-
# unused_results = "warn"
121+
unused_results = "warn"
117122

118123
## Allow
119124
bare_trait_objects = "allow"

README.md

+44-41
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,9 @@ A Robust Rust Library for CRYSTALS-Kyber Post-Quantum Cryptography.
1818
<center>
1919
<!-- markdownlint-enable MD033 MD041 -->
2020

21-
[![Made With Rust][made-with-rust-badge]][05]
22-
[![Crates.io][crates-badge]][07]
23-
[![Lib.rs][libs-badge]][09]
24-
[![Docs.rs][docs-badge]][08]
25-
[![License][license-badge]][02]
26-
27-
[Website][00]
28-
[Documentation][08]
29-
[Report Bug][03]
30-
[Request Feature][03]
31-
[Contributing Guidelines][04]
21+
[![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]
22+
23+
[Website][00][Documentation][08][Report Bug][03][Request Feature][03][Contributing Guidelines][04]
3224

3325
<!-- markdownlint-disable MD033 MD041 -->
3426
</center>
@@ -38,7 +30,7 @@ A Robust Rust Library for CRYSTALS-Kyber Post-Quantum Cryptography.
3830

3931
## Overview 📖
4032

41-
KyberLib 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.
33+
KyberLib 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.
4234

4335
## Features ✨
4436

@@ -73,7 +65,7 @@ It takes just a few minutes to get up and running with `kyberlib`.
7365
### Requirements
7466

7567
The minimum supported Rust toolchain version is currently Rust
76-
**1.56.0** or later (stable).
68+
**1.60** or later (stable).
7769

7870
### Installation
7971

@@ -95,7 +87,7 @@ To use the `kyberlib` library in your project, add the following to your
9587

9688
```toml
9789
[dependencies]
98-
kyberlib = "0.0.4"
90+
kyberlib = "0.0.5"
9991
```
10092

10193
Add the following to your `main.rs` file:
@@ -113,6 +105,8 @@ For optimisations on x86 platforms enable the `avx2` feature and the following R
113105
export RUSTFLAGS="-C target-feature=+aes,+avx2,+sse2,+sse4.1,+bmi2,+popcnt"
114106
```
115107

108+
## Crate Features 📦
109+
116110
### Key Encapsulation
117111

118112
```rust
@@ -177,32 +171,38 @@ alice.client_confirm(server_response, &alice_keys.secret)?;
177171
assert_eq!(alice.shared_secret, bob.shared_secret);
178172
```
179173

180-
## Macros
174+
## Macros 🦀
181175

182176
The KyberLib crate provides several macros to simplify common cryptographic operations:
183177

184-
- `kyberlib_assert!`: Asserts that a given expression is true. Panics if the assertion fails.
185-
- `kyberlib_min!`: Returns the minimum of the given values.
186-
- `kyberlib_max!`: Returns the maximum of the given values.
187-
- `kyberlib_generate_key_pair!`: Generates a public and private key pair for CCA-secure Kyber key encapsulation mechanism.
188-
- `kyberlib_encrypt_message!`: Generates cipher text and a shared secret for a given public key.
189-
- `kyberlib_decrypt_message!`: Generates a shared secret for a given cipher text and private key.
190-
- `kyberlib_uake_client_init!`: Initiates a Unilaterally Authenticated Key Exchange.
191-
- `kyberlib_uake_server_receive!`: Handles the output of a `kyberlib_uake_client_init()` request.
192-
- `kyberlib_uake_client_confirm!`: Decapsulates and authenticates the shared secret from the output of `kyberlib_uake_server_receive()`.
193-
- `kyberlib_ake_client_init!`: Initiates a Mutually Authenticated Key Exchange.
194-
- `kyberlib_ake_server_receive!`: Handles and authenticates the output of a `kyberlib_ake_client_init()` request.
195-
- `kyberlib_ake_client_confirm!`: Decapsulates and authenticates the shared secret from the output of `kyberlib_ake_server_receive()`.
196-
197-
See the [macros module documentation](https://docs.rs/kyberlib/latest/kyberlib/macros/index.html) for more details and usage examples.
178+
- [`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.
179+
180+
- [`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.
181+
182+
- [`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.
183+
184+
- [`kyberlib_uake_client_init!`](https://docs.rs/kyberlib/latest/kyberlib/macro.kyberlib_uake_client_init.html): Initiates a Unilaterally Authenticated Key Exchange.
185+
186+
- [`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.
187+
188+
- [`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()`.
189+
190+
- [`kyberlib_ake_client_init!`](https://docs.rs/kyberlib/latest/kyberlib/macro.kyberlib_ake_client_init.html): Initiates a Mutually Authenticated Key Exchange.
191+
192+
- [`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.
193+
194+
- [`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()`.
195+
196+
See the [macros module documentation](https://docs.rs/kyberlib/latest/kyberlib/index.html#macros) for more details and usage examples.
198197

199198
## Errors
200199

201200
The KyberLibError enum has two variants:
202201

203202
- **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.
203+
- **InvalidKey** - Error when generating keys.
204204
- **Decapsulation** - The ciphertext was unable to be authenticated. The shared secret was not decapsulated.
205-
- **RandomBytesGeneration** - Error trying to fill random bytes (i.e external (hardware) RNG modules can fail).
205+
- **RandomBytesGeneration** - Error trying to fill random bytes (i.e., external (hardware) RNG modules can fail).
206206

207207
## Examples
208208

@@ -244,7 +244,7 @@ cargo run --example uake
244244

245245
### Platform support
246246

247-
`kyberlib` is supported and tested on MacOS, Linux, and Windows. The [GitHub Actions][10] shows the platforms in which the `kyberlib` library tests are run.
247+
`kyberlib` supports a variety of CPU architectures. It is supported and tested on MacOS, Linux, and Windows.
248248

249249
### Documentation
250250

@@ -258,8 +258,10 @@ backward compatibility, `kyberlib` follows [semantic versioning][06].
258258

259259
## License 📝
260260

261-
The project is licensed under the terms of Apache License, Version 2.0 and the
262-
MIT license.
261+
KyberLib is distributed under the terms of both the MIT license and the
262+
Apache License (Version 2.0).
263+
264+
See [LICENSE-APACHE][01] and [LICENSE-MIT][02] for details.
263265

264266
## Contribution 🤝
265267

@@ -289,24 +291,25 @@ A special thank you goes to the [Rust Reddit][12] community for
289291
providing a lot of useful suggestions on how to improve this project.
290292

291293
[00]: https://kyberlib.com/ "KyberLib, A Robust Rust Library for CRYSTALS-Kyber Post-Quantum Cryptography"
292-
[01]: https://kura.pro/common/images/elements/divider.svg "Divider"
293-
[02]: http://opensource.org/licenses/MIT "KyberLib license"
294+
[01]: http://opensource.org/licenses/Apache-2.0 "Apache License, Version 2.0"
295+
[02]: http://opensource.org/licenses/MIT "MIT License"
294296
[03]: https://github.com/sebastienrousseau/kyberlib/kyberlib/issues "KyberLib Issues"
295297
[04]: https://github.com/sebastienrousseau/kyberlib/kyberlib/blob/main/CONTRIBUTING.md "KyberLib Contributing Guidelines"
296298
[05]: https://github.com/sebastienrousseau/kyberlib/kyberlib/graphs/contributors "KyberLib Contributors"
297299
[06]: http://semver.org/ "SemVer"
298300
[07]: https://crates.io/crates/kyberlib "KyberLib on Crates.io"
299301
[08]: https://docs.rs/kyberlib "KyberLib on Docs.rs"
300302
[09]: https://lib.rs/crates/kyberlib "KyberLib on Lib.rs"
301-
[10]: https://github.com/sebastienrousseau/kyberlib/kyberlib/actions "KyberLib on GitHub Actions"
302303
[11]: https://www.rust-lang.org/policies/code-of-conduct "KyberLib Code of Conduct"
303304
[12]: https://www.reddit.com/r/rust/ "Reddit"
304305
[13]: https://www.rust-lang.org/learn/get-started "Rust"
305306
[14]: https://github.com/Argyle-Software/kyber "Kyber from Argyle-Software"
307+
[15]: https://codecov.io/gh/sebastienrousseau/kyberlib "Codecov"
306308

307-
[crates-badge]: https://img.shields.io/crates/v/kyberlib.svg?style=for-the-badge 'Crates.io badge'
309+
[crates-badge]: https://img.shields.io/crates/v/kyberlib.svg?style=for-the-badge 'Crates.io'
310+
[codecov-badge]: https://img.shields.io/codecov/c/github/sebastienrousseau/kyberlib?style=for-the-badge&token=oEisyTucB5 'Codecov'
308311
[divider]: https://kura.pro/common/images/elements/divider.svg "divider"
309-
[docs-badge]: https://img.shields.io/docsrs/kyberlib.svg?style=for-the-badge 'Docs.rs badge'
310-
[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.1-orange.svg?style=for-the-badge 'Lib.rs badge'
311-
[license-badge]: https://img.shields.io/crates/l/kyberlib.svg?style=for-the-badge 'License badge'
312-
[made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust badge'
312+
[docs-badge]: https://img.shields.io/docsrs/kyberlib.svg?style=for-the-badge 'Docs.rs'
313+
[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.5-orange.svg?style=for-the-badge 'Lib.rs'
314+
[license-badge]: https://img.shields.io/crates/l/kyberlib.svg?style=for-the-badge 'License'
315+
[made-with-rust]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust'

TEMPLATE.md

+1-26
Original file line numberDiff line numberDiff line change
@@ -40,30 +40,6 @@ A Robust Rust Library for CRYSTALS-Kyber Post-Quantum Cryptography
4040

4141
A Robust Rust Library for CRYSTALS-Kyber Post-Quantum Cryptography
4242

43-
## Features ✨
44-
45-
### Core Features
46-
47-
- **`no_std` compatible**: No dependence on the Rust standard library
48-
- **Avoid allocations**: Uses stack-based data structures only
49-
- **Configurable**: Features to enable different parameter sets
50-
- **Optimised x86_64**: Uses assembly for performance-critical code, including an optimised AVX2 version by default.
51-
- **Safe code**: Reference implementations have no `unsafe` blocks
52-
- **WebAssembly Support**: Can be compiled to WASM using wasm-bindgen.
53-
54-
### Advanced Features
55-
56-
- **Allocation-free Guarantee**: KyberLib guarantees all its core cryptography operations are free of heap allocations.
57-
- **Assembly Optimizations**: The x86_64 assembly implementations use AVX2 instructions for high performance.
58-
- **Security**: KyberLib contains no unsafe code in its public API surface.
59-
60-
## Functionality 📚
61-
62-
- **Key Generation**: Create public/private key pairs
63-
- **Encapsulation**: Encapsulate a shared secret with a public key
64-
- **Decapsulation**: Decapsulate a shared secret with a private key
65-
- **Key Exchange**: Perform authenticated key exchanges
66-
6743
[0]: https://kyberlib.com/
6844
[2]: http://opensource.org/licenses/MIT
6945
[3]: https://github.com/sebastienrousseau/kyberlib/kyberlib/issues
@@ -73,11 +49,10 @@ A Robust Rust Library for CRYSTALS-Kyber Post-Quantum Cryptography
7349
[8]: https://docs.rs/kyberlib
7450
[9]: https://lib.rs/crates/kyberlib
7551

76-
[banner]: https://via.placeholder.com/1500x500.png/000000/FFFFFF?text=kyberlib "kyberlib's banner"
7752
[crates-badge]: https://img.shields.io/crates/v/kyberlib.svg?style=for-the-badge 'Crates.io badge'
7853
[divider]: https://via.placeholder.com/1024x1.png/d8dee4/FFFFFF?text=− "kyberlib's divider"
7954
[docs-badge]: https://img.shields.io/docsrs/kyberlib.svg?style=for-the-badge 'Docs.rs badge'
80-
[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.1-orange.svg?style=for-the-badge 'Lib.rs badge'
55+
[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.5-orange.svg?style=for-the-badge 'Lib.rs badge'
8156
[license-badge]: https://img.shields.io/crates/l/kyberlib.svg?style=for-the-badge 'License badge'
8257
[made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust badge'
8358

0 commit comments

Comments
 (0)