Adding a hash type to CipherSuite (#24)
This commit is contained in:
+4
-3
@@ -11,8 +11,9 @@ use curve25519_dalek::{edwards::EdwardsPoint, ristretto::RistrettoPoint};
|
||||
|
||||
use generic_array::GenericArray;
|
||||
use hkdf::Hkdf;
|
||||
use sha2::{Sha256, Sha512};
|
||||
|
||||
/// A subtrait of Group specifying how to has a password into a point
|
||||
/// A subtrait of Group specifying how to hash a password into a point
|
||||
pub trait GroupWithMapToCurve: Group {
|
||||
/// transforms a password and optional pepper into a curve point
|
||||
fn map_to_curve(password: &[u8], pepper: Option<&[u8]>) -> Self;
|
||||
@@ -20,14 +21,14 @@ pub trait GroupWithMapToCurve: Group {
|
||||
|
||||
impl GroupWithMapToCurve for RistrettoPoint {
|
||||
fn map_to_curve(password: &[u8], pepper: Option<&[u8]>) -> Self {
|
||||
let (hashed_input, _) = Hkdf::<sha2::Sha512>::extract(pepper, password);
|
||||
let (hashed_input, _) = Hkdf::<Sha512>::extract(pepper, password);
|
||||
<Self as Group>::hash_to_curve(GenericArray::from_slice(&hashed_input))
|
||||
}
|
||||
}
|
||||
|
||||
impl GroupWithMapToCurve for EdwardsPoint {
|
||||
fn map_to_curve(password: &[u8], pepper: Option<&[u8]>) -> Self {
|
||||
let (hashed_input, _) = Hkdf::<sha2::Sha256>::extract(pepper, password);
|
||||
let (hashed_input, _) = Hkdf::<Sha256>::extract(pepper, password);
|
||||
<Self as Group>::hash_to_curve(GenericArray::from_slice(&hashed_input))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user