mod ecvrf_impl;
mod traits;
pub use crate::ecvrf::ecvrf_impl::{
Output, Proof, VRFExpandedPrivateKey, VRFPrivateKey, VRFPublicKey,
};
pub use crate::ecvrf::traits::VRFKeyStorage;
#[cfg(feature = "nostd")]
use alloc::boxed::Box;
#[cfg(feature = "nostd")]
use alloc::format;
#[cfg(feature = "nostd")]
use alloc::string::String;
#[cfg(feature = "nostd")]
use alloc::string::ToString;
#[cfg(feature = "nostd")]
use alloc::vec::Vec;
#[cfg(test)]
mod tests;
#[derive(Debug, Eq, PartialEq)]
pub enum VrfError {
PublicKey(String),
SigningKey(String),
Verification(String),
}
impl core::fmt::Display for VrfError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let code = match &self {
VrfError::PublicKey(msg) => format!("(Public Key) - {msg}"),
VrfError::SigningKey(msg) => format!("(Signing Key) - {msg}"),
VrfError::Verification(msg) => format!("(Verification) - {msg}"),
};
write!(f, "Verifiable random function error {code}")
}
}
#[derive(Clone)]
pub struct HardCodedAkdVRF;
unsafe impl Sync for HardCodedAkdVRF {}
unsafe impl Send for HardCodedAkdVRF {}
#[async_trait::async_trait]
impl VRFKeyStorage for HardCodedAkdVRF {
async fn retrieve(&self) -> Result<Vec<u8>, VrfError> {
hex::decode("c9afa9d845ba75166b5c215767b1d6934e50c3db36e89b127b8a622b120f6721")
.map_err(|hex_err| VrfError::PublicKey(hex_err.to_string()))
}
}