mirror of
https://github.com/saymrwulf/risc0-curve25519-dalek-source.git
synced 2026-09-04 20:03:40 +00:00
Add a doctest for Scalar::from_u64().
This commit is contained in:
parent
3854eb0fd8
commit
61daa9dce6
1 changed files with 20 additions and 0 deletions
|
|
@ -527,6 +527,26 @@ impl Scalar {
|
|||
}
|
||||
|
||||
/// Construct a scalar from the given `u64`.
|
||||
///
|
||||
/// # Inputs
|
||||
///
|
||||
/// An `u64` to convert to a `Scalar`.
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// A `Scalar` corresponding to the input `u64`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// use curve25519_dalek::scalar::Scalar;
|
||||
///
|
||||
/// let fourtytwo = Scalar::from_u64(42);
|
||||
/// let six = Scalar::from_u64(6);
|
||||
/// let seven = Scalar::from_u64(7);
|
||||
///
|
||||
/// assert!(fourtytwo == six * seven);
|
||||
/// ```
|
||||
pub fn from_u64(x: u64) -> Scalar {
|
||||
let mut s_bytes = [0u8; 32];
|
||||
for i in 0..8 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue