diff --git a/examples/threshold_sig.rs b/examples/threshold_sig.rs index 0bb4c74..8d369e9 100644 --- a/examples/threshold_sig.rs +++ b/examples/threshold_sig.rs @@ -10,7 +10,7 @@ type Msg = String; // The database schema that validator nodes use to store messages they receive from users. // Messages are first indexed numerically by user ID then alphabetically by message. Each message -// is mapped to its list of valdidator signatures. +// is mapped to its list of validator signatures. type MsgDatabase = BTreeMap>>; // An append-only list of chat message "blocks". Each block contains the user ID for the user who diff --git a/src/lib.rs b/src/lib.rs index f0fa164..59b45e1 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -299,6 +299,10 @@ impl Default for SecretKey { } impl Distribution for Standard { + /// Creates a new random instance of `SecretKey`. If you do not need to specify your own RNG, + /// you should use the [`SecretKey::random()`](struct.SecretKey.html#method.random) constructor, + /// which uses [`rand::thread_rng()`](https://docs.rs/rand/0.6.1/rand/fn.thread_rng.html) + /// internally as its RNG. fn sample(&self, rng: &mut R) -> SecretKey { SecretKey(Box::new(rng.gen04())) } @@ -353,10 +357,12 @@ impl SecretKey { } /// Creates a new random instance of `SecretKey`. If you want to use/define your own random - /// number generator, you should use the constructor: `SecretKey::rand()`. If you do not need - /// to specify your own RNG, you should use the `SecretKey::random()` constructor, which uses - /// [`rand::thead_rng()`](https://docs.rs/rand/0.6.1/rand/fn.thread_rng.html) internally as - /// its RNG. + /// number generator, you should use the constructor: + /// [`SecretKey::sample()`](struct.SecretKey.html#impl-Distribution). If you do not + /// need to specify your own RNG, you should use the + /// [`SecretKey::random()`](struct.SecretKey.html#method.random) constructor, which uses + /// [`rand::thread_rng()`](https://docs.rs/rand/0.6.1/rand/fn.thread_rng.html) internally as its + /// RNG. pub fn random() -> Self { rand::random() } @@ -406,6 +412,8 @@ impl SecretKey { #[derive(Clone, PartialEq, Eq, Default)] pub struct SecretKeyShare(SecretKey); +/// Can be used to create a new random instance of `SecretKeyShare`. This is only useful for testing +/// purposes as such a key has not been derived from a `SecretKeySet`. impl Distribution for Standard { fn sample(&self, rng: &mut R) -> SecretKeyShare { SecretKeyShare(rng.gen()) @@ -633,7 +641,7 @@ impl From for SecretKeySet { impl SecretKeySet { /// Creates a set of secret key shares, where any `threshold + 1` of them can collaboratively - /// sign and decrypt. This constuctor is identical to the `SecretKey::try_random()` in every + /// sign and decrypt. This constructor is identical to the `SecretKeySet::try_random()` in every /// way except that this constructor panics if the other returns an error. /// /// # Panic @@ -645,7 +653,7 @@ impl SecretKeySet { } /// Creates a set of secret key shares, where any `threshold + 1` of them can collaboratively - /// sign and decrypt. This constuctor is identical to the `SecretKey::random()` in every + /// sign and decrypt. This constructor is identical to the `SecretKeySet::random()` in every /// way except that this constructor returns an `Err` where the `random` would panic. pub fn try_random(threshold: usize, rng: &mut R) -> Result { Poly::try_random(threshold, rng).map(SecretKeySet::from) diff --git a/src/mock/ms8.rs b/src/mock/ms8.rs index b8a832a..d61d43d 100644 --- a/src/mock/ms8.rs +++ b/src/mock/ms8.rs @@ -1,4 +1,4 @@ -//! Eigth Mersenne prime field +//! Eighth Mersenne prime field //! //! The eighth [Mersenne Prime](https://en.wikipedia.org/wiki/Mersenne_prime) (`MS8 := 2^31-1) can //! be used to construct a finite field supporting addition and multiplication. This module provides @@ -43,7 +43,7 @@ fn modular_pow(base: u32, mut exp: u32, modulus: u32) -> u32 { result as u32 } -/// Eigth Mersenne prime, aka `i32::MAX`. +/// Eighth Mersenne prime, aka `i32::MAX`. pub const MS8: u32 = 0x7fff_ffff; /// Eighth Mersenne prime field element diff --git a/src/poly.rs b/src/poly.rs index f0d24a4..faab349 100644 --- a/src/poly.rs +++ b/src/poly.rs @@ -816,7 +816,7 @@ mod tests { let faulty_num = 2; // For distributed key generation, a number of dealers, only one of who needs to be honest, - // generates random bivariate polynomials and publicly commits to them. In partice, the + // generates random bivariate polynomials and publicly commits to them. In practice, the // dealers can e.g. be any `faulty_num + 1` nodes. let bi_polys: Vec = (0..dealer_num) .map(|_| BivarPoly::random(faulty_num, &mut rng)) diff --git a/src/secret.rs b/src/secret.rs index af9df2e..4cec30b 100644 --- a/src/secret.rs +++ b/src/secret.rs @@ -34,7 +34,7 @@ pub(crate) trait ContainsSecret { } } -/// A wrapper around temporary values to ensuer that they are cleared on drop. +/// A wrapper around temporary values to ensure that they are cleared on drop. /// /// `Safe` is meant to be used a wrapper around `T`, where `T` is either an `&mut U` or /// `Box`.