Skip to content

Commit 2492182

Browse files
committed
fix foc-tests (ignored because mock_deps creates a non functional deps.api)
1 parent 5801330 commit 2492182

File tree

2 files changed

+34
-14
lines changed

2 files changed

+34
-14
lines changed

packages/crypto/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ cosmwasm-std = { package = "secret-cosmwasm-std", version = "0.10" }
2828
[dev-dependencies]
2929
secp256k1-test = { package = "secp256k1", version = "0.17", features = [
3030
"rand-std",
31-
"recovery"
31+
"recovery",
3232
] }
33+
base64 = "0.11"

packages/crypto/src/lib.rs

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,59 @@
33
//! running on the Secret Network.
44
//!
55
//! Note: It has a deep dependency tree and increases compilation times significantly.
6-
//!
6+
//!
77
//! Add the following to your `cargo.toml` file:
8-
//!
8+
//!
99
//! ```toml
1010
//! [dependencies]
1111
//! secret-toolkit = { version = "0.3.0", features = ["crypto"] }
1212
//! secret-toolkit-crypto = { version = "0.3.0", features = ["hash", "rand", "ecc-secp256k1"] }
1313
//! ```
14-
//!
14+
//!
1515
//! ## Example usage:
16-
//! ```rust
17-
//! use secret_toolkit::{
18-
//! crypto::secp256k1::{PrivateKey, PublicKey, Signature},
19-
//! crypto::{sha_256, Prng},
20-
//! };
2116
//!
17+
//! ```ignore
18+
//! # extern crate secret_toolkit_crypto;
19+
//!
20+
//! # use secret_toolkit_crypto::{sha_256, Prng, secp256k1::{PrivateKey, PublicKey, Signature}};
21+
//! # use base64;
22+
//! # use cosmwasm_std::{StdError, testing::mock_dependencies};
23+
//!
24+
//! # fn main() -> Result<(), StdError> {
25+
//! # let deps = mock_dependencies(20, &[]);
2226
//! let entropy: String = "secret".to_owned();
23-
//! let prng_seed: Vec<u8> = sha_256(base64::encode(entropy.clone()).as_bytes()).to_vec();
27+
//! let prng_seed: Vec<u8> = sha_256(base64::encode(&entropy.clone()).as_bytes()).to_vec();
2428
//!
25-
//! let mut rng = Prng::new(prng_seed, entropy.as_bytes());
29+
//! let mut rng = Prng::new(&prng_seed, entropy.as_bytes());
2630
//!
27-
//! let private_key: PrivateKey = PrivateKey::parse(&rng.randbytes());
31+
//! let private_key: PrivateKey = PrivateKey::parse(&rng.rand_bytes())?;
2832
//! let public_key: PublicKey = private_key.pubkey();
2933
//!
3034
//! let message: &[u8] = b"message";
3135
//! let signature: Signature = private_key.sign(message, deps.api);
36+
//! # Ok(())
37+
//! # }
3238
//! ```
33-
//!
39+
//!
3440
//! ### Cargo Features
3541
//! - `["hash"]` - Provides an easy-to-use `sha256` function. Uses [sha2](https://crates.io/crates/sha2).
3642
//! - `["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,
43+
//! - `["ecc-secp256k1"]` - Contains types and methods for working with secp256k1 keys and signatures,
3844
//! as well as standard constants for key sizes. Uses [secp256k1](https://crates.io/crates/secp256k1).
3945
//!
46+
47+
// fn hello() {
48+
// sha_256(data)
49+
// }
50+
51+
// mod tom {
52+
// use crate::sha_256;
53+
54+
// fn langer() {
55+
// sha_256(data)
56+
// }
57+
// }
58+
4059
#[cfg(feature = "hash")]
4160
mod hash;
4261
#[cfg(feature = "rand")]

0 commit comments

Comments
 (0)