Skip to content

Commit 5801330

Browse files
authored
Merge pull request #50 from kent-3/master
added description for secret-toolkit-crypto crate docs
2 parents 1058647 + 5b49162 commit 5801330

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

packages/crypto/src/lib.rs

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
1+
//! # Crypto
2+
//! This crate contains common cryptography tools used in the development of Secret Contracts
3+
//! running on the Secret Network.
4+
//!
5+
//! Note: It has a deep dependency tree and increases compilation times significantly.
6+
//!
7+
//! Add the following to your `cargo.toml` file:
8+
//!
9+
//! ```toml
10+
//! [dependencies]
11+
//! secret-toolkit = { version = "0.3.0", features = ["crypto"] }
12+
//! secret-toolkit-crypto = { version = "0.3.0", features = ["hash", "rand", "ecc-secp256k1"] }
13+
//! ```
14+
//!
15+
//! ## Example usage:
16+
//! ```rust
17+
//! use secret_toolkit::{
18+
//! crypto::secp256k1::{PrivateKey, PublicKey, Signature},
19+
//! crypto::{sha_256, Prng},
20+
//! };
21+
//!
22+
//! let entropy: String = "secret".to_owned();
23+
//! let prng_seed: Vec<u8> = sha_256(base64::encode(entropy.clone()).as_bytes()).to_vec();
24+
//!
25+
//! let mut rng = Prng::new(prng_seed, entropy.as_bytes());
26+
//!
27+
//! let private_key: PrivateKey = PrivateKey::parse(&rng.randbytes());
28+
//! let public_key: PublicKey = private_key.pubkey();
29+
//!
30+
//! let message: &[u8] = b"message";
31+
//! let signature: Signature = private_key.sign(message, deps.api);
32+
//! ```
33+
//!
34+
//! ### Cargo Features
35+
//! - `["hash"]` - Provides an easy-to-use `sha256` function. Uses [sha2](https://crates.io/crates/sha2).
36+
//! - `["rand"]` - Used to generate pseudo-random numbers. Uses [rand_chacha] and [rand_core].
37+
//! - `["ecc-secp256k1"]` - Contains types and methods for working with secp256k1 keys and signatures,
38+
//! as well as standard constants for key sizes. Uses [secp256k1](https://crates.io/crates/secp256k1).
39+
//!
140
#[cfg(feature = "hash")]
241
mod hash;
342
#[cfg(feature = "rand")]

0 commit comments

Comments
 (0)