Docs, testing

This commit is contained in:
Deirdre Connolly 2020-05-08 22:21:19 -04:00 committed by Deirdre Connolly
parent 85ac7e8966
commit b235675464
4 changed files with 31 additions and 59 deletions

View File

@ -32,6 +32,21 @@ jobs:
command: build
args: --verbose --release
doctest-nightly:
name: Run doctests via nightly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
# Because we use nightly features for building docs,
# using --all-features will fail without nightly toolchain.
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
- uses: actions-rs/cargo@v1
with:
command: test
args: --all-features
coverage:
name: Code Coverage

View File

@ -19,6 +19,9 @@ exclude = [
".github/*",
]
[package.metadata.docs.rs]
features = ["nightly"]
[dependencies]
curve25519-dalek = { version = "2.0.0", features = ["serde"] }
rand_core = "0.5.1"
@ -29,3 +32,6 @@ zeroize = "1.1.0"
bincode = "1.2.1"
proptest = "0.9"
proptest-derive = "0.1.0"
[features]
nightly = []

View File

@ -1,13 +1,17 @@
# ristretto255-dh
Diffie-Hellman key exchange using the [Ristretto255][ristretto] group, in pure Rust.
# ristretto255-dh [![](https://img.shields.io/crates/v/ristretto255-dh.svg)](https://crates.io/crates/ristretto255-dh) [![](https://docs.rs/ristretto255-dh/badge.svg)](https://docs.rs/ristretto255-dh) [![](https://github.com/ZcashFoundation/ristretto255-dh/workflows/CI/badge.svg?branch=main)](https://github.com/ZcashFoundation/ristretto255-dh/actions?query=workflow%3ACI+branch%3Amain)
This crate provides a high-level API for static and ephemeral Diffie-Hellman in the Ristretto255 prime order group, as specified the [IETF draft][ietf-draft], implemented internally over Curve25519 using [curve25519-dalek].
Diffie-Hellman key exchange using the [Ristretto255][ristretto] group,
in pure Rust.
This crate provides a high-level API for static and ephemeral
Diffie-Hellman in the Ristretto255 prime order group, as specified the
[IETF draft][ietf-draft], implemented internally over Curve25519 using
[curve25519-dalek].
## Example
```
use rand::rngs::OsRng;
use rand_core::OsRng;
use ristretto255_dh::EphemeralSecret;
use ristretto255_dh::PublicKey;
@ -30,15 +34,6 @@ let bob_shared_secret = bob_secret.diffie_hellman(&alice_public);
assert_eq!(<[u8; 32]>::from(alice_shared_secret), <[u8; 32]>::from(bob_shared_secret));
```
# Installation
To install, add the following to your project's `Cargo.toml`:
```toml
[dependencies.ristretto255-dh]
version = "0.1.0"
```
## About
The high-level Diffie-Hellman API is inspired by [x25519-dalek].

View File

@ -1,49 +1,5 @@
//! Diffie-Hellman key exchange using the [Ristretto255][ristretto]
//! group, in pure Rust.
//!
//! This crate provides a high-level API for static and ephemeral
//! Diffie-Hellman in the Ristretto255 prime order group as specified
//! in the [IETF draft][ietf-draft], implemented internally over (the
//! Edwards form of) Curve25519 using [curve25519-dalek].
//!
//! ## Example
//!
//! ```
//! use rand_core::OsRng;
//!
//! use ristretto255_dh::EphemeralSecret;
//! use ristretto255_dh::PublicKey;
//!
//! // Alice's side
//! let alice_secret = EphemeralSecret::new(&mut OsRng);
//! let alice_public = PublicKey::from(&alice_secret);
//!
//! // Bob's side
//! let bob_secret = EphemeralSecret::new(&mut OsRng);
//! let bob_public = PublicKey::from(&bob_secret);
//!
//! // Alice again
//! let alice_shared_secret = alice_secret.diffie_hellman(&bob_public);
//!
//! // Bob again
//! let bob_shared_secret = bob_secret.diffie_hellman(&alice_public);
//!
//! // Each peer's computed shared secret should be the same.
//! assert_eq!(
//! <[u8; 32]>::from(alice_shared_secret),
//! <[u8; 32]>::from(bob_shared_secret)
//! );
//! ```
//!
//! ## About
//!
//! The high-level Diffie-Hellman API is inspired by [x25519-dalek].
//!
//! [curve25519-dalek]: https://github.com/dalek-cryptography/curve25519-dalek
//! [ietf-draft]: https://ietf.org/id/draft-irtf-cfrg-ristretto255-00.html
//! [ristretto]: https://ristretto.group
//! [x25519-dalek]: https://github.com/dalek-cryptography/x25519-dalek
#![doc(html_root_url = "https://docs.rs/ristretto255-dh/0.1.0")]
#![cfg_attr(feature = "nightly", feature(external_doc))]
#![cfg_attr(feature = "nightly", doc(include = "../README.md"))]
use curve25519_dalek::{
constants,