Skip to content

Commit

Permalink
[#63] Add prelude for easier importing (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
clintfred authored Mar 1, 2019
1 parent b675747 commit 4f20dc6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
//!
//! ## Basic Encrypt/Decrypt Example
//! ```
//! use recrypt::prelude::*;
//! use recrypt::Revealed;
//! use recrypt::api::*;
//!
//! // create a new recrypt
//! let mut recrypt = Recrypt::new();
//!
Expand All @@ -34,8 +35,9 @@
//! Encrypt a message to public key `initial_pub_key` and decrypt it with `target_priv_key`
//! after transforming the encrypted message.
//! ```
//! use recrypt::prelude::*;
//! use recrypt::Revealed;
//! use recrypt::api::*;
//!
//! // create a new recrypt
//! let mut recrypt = Recrypt::new();
//!
Expand All @@ -62,7 +64,7 @@
//! &signing_keypair).unwrap();
//!
//! // Transform the plaintext to be encrypted to the target!
//! // The data is _not_ be decrypted here. Simply transformed!
//! // The data is _not_ decrypted here. Simply transformed!
//! let transformed_val = recrypt.transform(
//! encrypted_val,
//! initial_to_target_transform_key,
Expand All @@ -87,6 +89,7 @@
#[macro_use]
extern crate proptest; // shouldn't be needed in Rust 2018, but hoping proptest will better document how to import

pub mod prelude;
#[macro_use] // this is still required in Rust 2018
mod internal; // this needs to come before `api` as api relies on macros defined in `internal`
pub mod api;
Expand Down
20 changes: 20 additions & 0 deletions src/prelude.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//! Convenience re-export of common structs and traits needed for using Recrypt
//!
//! ```
//! use recrypt::prelude::*;
//! use rand::rngs::ThreadRng;
//!
//! let recrypt: Recrypt<Sha256, Ed25519, RandomBytes<ThreadRng>> = Recrypt::new();
//! ```
// necessary for instantiating and storing a Recrypt as a struct member
pub use crate::api::Ed25519;
pub use crate::api::RandomBytes;
pub use crate::api::Recrypt;
pub use crate::api::Sha256;

// traits that define functionality on Recrypt
pub use crate::api::CryptoOps;
pub use crate::api::Ed25519Ops;
pub use crate::api::KeyGenOps;
pub use crate::api::SchnorrOps;

0 comments on commit 4f20dc6

Please sign in to comment.