Skip to content

Commit b90bb2b

Browse files
docs(kyberlib): 📝 updates on documentation macros and KyberLibError
1 parent ffbbe37 commit b90bb2b

File tree

2 files changed

+49
-35
lines changed

2 files changed

+49
-35
lines changed

README.md

+25-18
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ A Robust Rust Library for CRYSTALS-Kyber Post-Quantum Cryptography.
3030

3131
## Overview 📖
3232

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.
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.
3434

3535
## Features ✨
3636

@@ -105,6 +105,8 @@ For optimisations on x86 platforms enable the `avx2` feature and the following R
105105
export RUSTFLAGS="-C target-feature=+aes,+avx2,+sse2,+sse4.1,+bmi2,+popcnt"
106106
```
107107

108+
## Crate Features 📦
109+
108110
### Key Encapsulation
109111

110112
```rust
@@ -169,32 +171,38 @@ alice.client_confirm(server_response, &alice_keys.secret)?;
169171
assert_eq!(alice.shared_secret, bob.shared_secret);
170172
```
171173

172-
## Macros
174+
## Macros 🦀
173175

174176
The KyberLib crate provides several macros to simplify common cryptographic operations:
175177

176-
- `kyberlib_assert!`: Asserts that a given expression is true. Panics if the assertion fails.
177-
- `kyberlib_min!`: Returns the minimum of the given values.
178-
- `kyberlib_max!`: Returns the maximum of the given values.
179-
- `kyberlib_generate_key_pair!`: Generates a public and private key pair for CCA-secure Kyber key encapsulation mechanism.
180-
- `kyberlib_encrypt_message!`: Generates cipher text and a shared secret for a given public key.
181-
- `kyberlib_decrypt_message!`: Generates a shared secret for a given cipher text and private key.
182-
- `kyberlib_uake_client_init!`: Initiates a Unilaterally Authenticated Key Exchange.
183-
- `kyberlib_uake_server_receive!`: Handles the output of a `kyberlib_uake_client_init()` request.
184-
- `kyberlib_uake_client_confirm!`: Decapsulates and authenticates the shared secret from the output of `kyberlib_uake_server_receive()`.
185-
- `kyberlib_ake_client_init!`: Initiates a Mutually Authenticated Key Exchange.
186-
- `kyberlib_ake_server_receive!`: Handles and authenticates the output of a `kyberlib_ake_client_init()` request.
187-
- `kyberlib_ake_client_confirm!`: Decapsulates and authenticates the shared secret from the output of `kyberlib_ake_server_receive()`.
188-
189-
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.
190197

191198
## Errors
192199

193200
The KyberLibError enum has two variants:
194201

195202
- **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.
196204
- **Decapsulation** - The ciphertext was unable to be authenticated. The shared secret was not decapsulated.
197-
- **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).
198206

199207
## Examples
200208

@@ -281,7 +289,6 @@ A special thank you goes to the [Rust Reddit][12] community for
281289
providing a lot of useful suggestions on how to improve this project.
282290

283291
[00]: https://kyberlib.com/ "KyberLib, A Robust Rust Library for CRYSTALS-Kyber Post-Quantum Cryptography"
284-
[01]: https://kura.pro/common/images/elements/divider.svg "Divider"
285292
[02]: http://opensource.org/licenses/MIT "KyberLib license"
286293
[03]: https://github.com/sebastienrousseau/kyberlib/kyberlib/issues "KyberLib Issues"
287294
[04]: https://github.com/sebastienrousseau/kyberlib/kyberlib/blob/main/CONTRIBUTING.md "KyberLib Contributing Guidelines"

src/lib.rs

+24-17
Original file line numberDiff line numberDiff line change
@@ -122,27 +122,34 @@
122122
//!
123123
//! The KyberLib crate provides several macros to simplify common cryptographic operations:
124124
//!
125-
//! - `kyberlib_assert!`: Asserts that a given expression is true. Panics if the assertion fails.
126-
//! - `kyberlib_min!`: Returns the minimum of the given values.
127-
//! - `kyberlib_max!`: Returns the maximum of the given values.
128-
//! - `kyberlib_generate_key_pair!`: Generates a public and private key pair for CCA-secure Kyber key encapsulation mechanism.
129-
//! - `kyberlib_encrypt_message!`: Generates cipher text and a shared secret for a given public key.
130-
//! - `kyberlib_decrypt_message!`: Generates a shared secret for a given cipher text and private key.
131-
//! - `kyberlib_uake_client_init!`: Initiates a Unilaterally Authenticated Key Exchange.
132-
//! - `kyberlib_uake_server_receive!`: Handles the output of a `kyberlib_uake_client_init()` request.
133-
//! - `kyberlib_uake_client_confirm!`: Decapsulates and authenticates the shared secret from the output of `kyberlib_uake_server_receive()`.
134-
//! - `kyberlib_ake_client_init!`: Initiates a Mutually Authenticated Key Exchange.
135-
//! - `kyberlib_ake_server_receive!`: Handles and authenticates the output of a `kyberlib_ake_client_init()` request.
136-
//! - `kyberlib_ake_client_confirm!`: Decapsulates and authenticates the shared secret from the output of `kyberlib_ake_server_receive()`.
137-
//!
138-
//! See the [macros module documentation](https://docs.rs/kyberlib/latest/kyberlib/macros/index.html) for more details and usage examples.
125+
//! - [`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.
126+
//!
127+
//! - [`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.
128+
//!
129+
//! - [`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.
130+
//!
131+
//! - [`kyberlib_uake_client_init!`](https://docs.rs/kyberlib/latest/kyberlib/macro.kyberlib_uake_client_init.html): Initiates a Unilaterally Authenticated Key Exchange.
132+
//!
133+
//! - [`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.
134+
//!
135+
//! - [`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()`.
136+
//!
137+
//! - [`kyberlib_ake_client_init!`](https://docs.rs/kyberlib/latest/kyberlib/macro.kyberlib_ake_client_init.html): Initiates a Mutually Authenticated Key Exchange.
138+
//!
139+
//! - [`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.
140+
//!
141+
//! - [`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()`.
142+
//!
143+
//! See the [macros module documentation](https://docs.rs/kyberlib/latest/kyberlib/index.html#macros) for more details and usage examples.
139144
//!
140145
//! ## Errors
141146
//!
142-
//! The [KyberLibError](enum.KyberLibError.html) enum handles errors with two variants:
147+
//! The [KyberLibError](https://docs.rs/kyberlib/latest/kyberlib/error/enum.KyberLibError.html) enum handles errors with two variants:
143148
//!
144-
//! - **InvalidInput**: Occurs when one or more byte inputs to a function are incorrectly sized. This typically happens when two parties use different security levels while attempting to negotiate a key exchange.
145-
//! - **Decapsulation**: This error indicates that the ciphertext could not be authenticated, and the shared secret was not successfully decapsulated.
149+
//! - **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.
150+
//! - **InvalidKey** - Error when generating keys.
151+
//! - **Decapsulation** - The ciphertext was unable to be authenticated. The shared secret was not decapsulated.
152+
//! - **RandomBytesGeneration** - Error trying to fill random bytes (i.e., external (hardware) RNG modules can fail).
146153
//!
147154
#![doc(
148155
html_favicon_url = "https://kura.pro/kyberlib/images/favicon.ico",

0 commit comments

Comments
 (0)