1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use crate::CurveGroup;
use ark_std::string::String;
use core::fmt;
pub mod curve_maps;
pub mod map_to_curve_hasher;
pub trait HashToCurve<T: CurveGroup>: Sized {
fn new(domain: &[u8]) -> Result<Self, HashToCurveError>;
fn hash(&self, message: &[u8]) -> Result<T::Affine, HashToCurveError>;
}
#[derive(Clone, Debug)]
pub enum HashToCurveError {
UnsupportedCurveError(String),
MapToCurveError(String),
}
impl ark_std::error::Error for HashToCurveError {}
impl fmt::Display for HashToCurveError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
match self {
HashToCurveError::UnsupportedCurveError(s) => write!(f, "{}", s),
HashToCurveError::MapToCurveError(s) => write!(f, "{}", s),
}
}
}
#[cfg(test)]
mod tests;