mirror of
https://github.com/saymrwulf/risc0-curve25519-dalek-source.git
synced 2026-09-05 20:10:35 +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
|
||||
///
|
||||
/// 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")]
|
||||
pub fn random<T: Rng + CryptoRng>(rng: &mut T) -> Self {
|
||||
let mut scalar_bytes = [0u8; 64];
|
||||
|
|
|
|||
Loading…
Reference in a new issue