mirror of
https://github.com/saymrwulf/curve25519-dalek-source.git
synced 2026-09-07 20:50:39 +00:00
Add doctest for Scalar::random().
This commit is contained in:
parent
87a1815b40
commit
37935674eb
1 changed files with 15 additions and 0 deletions
|
|
@ -436,6 +436,21 @@ impl Scalar {
|
||||||
/// # Returns
|
/// # Returns
|
||||||
///
|
///
|
||||||
/// A random scalar within ℤ/lℤ.
|
/// A random scalar within ℤ/lℤ.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// extern crate rand;
|
||||||
|
/// # extern crate curve25519_dalek;
|
||||||
|
/// #
|
||||||
|
/// # fn main() {
|
||||||
|
/// use curve25519_dalek::scalar::Scalar;
|
||||||
|
///
|
||||||
|
/// use rand::OsRng;
|
||||||
|
///
|
||||||
|
/// let mut csprng: OsRng = OsRng::new().unwrap();
|
||||||
|
/// let a: Scalar = Scalar::random(&mut csprng);
|
||||||
|
/// # }
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
pub fn random<T: Rng + CryptoRng>(rng: &mut T) -> Self {
|
pub fn random<T: Rng + CryptoRng>(rng: &mut T) -> Self {
|
||||||
let mut scalar_bytes = [0u8; 64];
|
let mut scalar_bytes = [0u8; 64];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue