use crate::CurveGroup;
use ark_std::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;