mod code;
mod password;
mod phrase;
mod token;
pub use code::Code;
pub use password::{Password, set_options};
pub use phrase::Phrase;
pub use token::Token;
use crate::{Error, Hash};
pub trait Proof {
fn generate(&self) -> Result<Vec<u8>, Error>;
fn hasher(&self) -> &dyn Hash;
fn hasher_mut(&mut self) -> &mut dyn Hash;
fn set_hash(&mut self, hash: Box<dyn Hash>);
fn hash(&self, proof: &[u8]) -> Result<Vec<u8>, Error> {
self.hasher().hash(proof)
}
fn verify(&self, proof: &[u8], hash: &[u8]) -> Result<bool, Error> {
self.hasher().verify(proof, hash)
}
}
macro_rules! proof_hash {
() => {
fn hasher(&self) -> &dyn $crate::Hash {
self.hash.as_ref()
}
fn hasher_mut(&mut self) -> &mut dyn $crate::Hash {
self.hash.as_mut()
}
fn set_hash(&mut self, hash: Box<dyn $crate::Hash>) {
self.hash = hash;
}
};
}
pub(crate) use proof_hash;