diff options
author | Brian Warner <warner@lothar.com> | 2018-05-22 17:15:46 -0700 |
---|---|---|
committer | Brian Warner <warner@lothar.com> | 2018-05-22 17:15:46 -0700 |
commit | 0c500f320f794ea3124533d6c35b677aa82ba93a (patch) | |
tree | 51cf3a474fa4d666239367d9d085f53fc0275239 | |
parent | 52326a626ad8b0283f70d76f0e5b0c35c65f560b (diff) | |
download | PAKEs-0c500f320f794ea3124533d6c35b677aa82ba93a.tar.xz |
cargo fmt
-rw-r--r-- | src/spake2.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/spake2.rs b/src/spake2.rs index 7f26958..d1cb4d9 100644 --- a/src/spake2.rs +++ b/src/spake2.rs @@ -1,13 +1,13 @@ #![allow(dead_code)] -use curve25519_dalek::scalar::Scalar as c2_Scalar; -use curve25519_dalek::edwards::EdwardsPoint as c2_Element; use curve25519_dalek::constants::ED25519_BASEPOINT_POINT; use curve25519_dalek::edwards::CompressedEdwardsY; -use rand::{OsRng, Rng, CryptoRng}; -use sha2::{Digest, Sha256}; +use curve25519_dalek::edwards::EdwardsPoint as c2_Element; +use curve25519_dalek::scalar::Scalar as c2_Scalar; use hkdf::Hkdf; use num_bigint::BigUint; +use rand::{CryptoRng, OsRng, Rng}; +use sha2::{Digest, Sha256}; //use hex::ToHex; @@ -35,7 +35,9 @@ pub trait Group { fn const_n() -> Self::Element; fn const_s() -> Self::Element; fn hash_to_scalar(s: &[u8]) -> Self::Scalar; - fn random_scalar<T>(cspring: &mut T) -> Self::Scalar where T: Rng+CryptoRng; + fn random_scalar<T>(cspring: &mut T) -> Self::Scalar + where + T: Rng + CryptoRng; fn scalar_neg(s: &Self::Scalar) -> Self::Scalar; fn element_to_bytes(e: &Self::Element) -> Vec<u8>; fn bytes_to_element(b: &[u8]) -> Option<Self::Element>; @@ -92,7 +94,9 @@ impl Group for Ed25519Group { ed25519_hash_to_scalar(s) } fn random_scalar<T>(cspring: &mut T) -> c2_Scalar - where T: Rng + CryptoRng { + where + T: Rng + CryptoRng, + { c2_Scalar::random(cspring) } fn scalar_neg(s: &c2_Scalar) -> c2_Scalar { @@ -467,10 +471,10 @@ mod test { deterministic RNG (used only for tests, of course) into the per-Group "random_scalar()" function, which results in some particular scalar. */ + use super::*; use curve25519_dalek::constants::ED25519_BASEPOINT_POINT; - use spake2::{Ed25519Group, SPAKE2}; use hex; - use super::*; + use spake2::{Ed25519Group, SPAKE2}; // the python tests show the long-integer form of scalars. the rust code // wants an array of bytes (little-endian). Make sure the way we convert |