Conform to voprf spec (#71)

This commit is contained in:
Kevin Lewi
2020-11-02 20:15:08 -05:00
committed by François Garillot
parent 28645a7cea
commit c8cbf56336
6 changed files with 238 additions and 237 deletions
+8 -5
View File
@@ -15,19 +15,22 @@ use sha2::{Sha256, Sha512};
/// 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;
fn map_to_curve(password: &[u8], dst: Option<&[u8]>) -> Self;
}
// TODO: incorporate expand_message_xmd from https://www.ietf.org/archive/id/draft-irtf-cfrg-hash-to-curve-10.txt
// instead of using HKDF-extract here
impl GroupWithMapToCurve for RistrettoPoint {
fn map_to_curve(password: &[u8], pepper: Option<&[u8]>) -> Self {
let (hashed_input, _) = Hkdf::<Sha512>::extract(pepper, password);
fn map_to_curve(password: &[u8], dst: Option<&[u8]>) -> Self {
let (hashed_input, _) = Hkdf::<Sha512>::extract(dst, password);
<Self as Group>::hash_to_curve(&hashed_input)
}
}
impl GroupWithMapToCurve for EdwardsPoint {
fn map_to_curve(password: &[u8], pepper: Option<&[u8]>) -> Self {
let (hashed_input, _) = Hkdf::<Sha256>::extract(pepper, password);
fn map_to_curve(password: &[u8], dst: Option<&[u8]>) -> Self {
let (hashed_input, _) = Hkdf::<Sha256>::extract(dst, password);
<Self as Group>::hash_to_curve(&hashed_input)
}
}