mod error;
mod hex;
mod key;
pub mod secp256k1;
mod signature;
pub use error::{ContextError, SignatureParseError, SigningError, VerificationError};
pub use key::{KeyParseError, PrivateKey, PublicKey};
pub use signature::Signature;
pub trait Signer: Send {
fn sign(&self, message: &[u8]) -> Result<Signature, SigningError>;
fn public_key(&self) -> Result<PublicKey, SigningError>;
fn clone_box(&self) -> Box<dyn Signer>;
}
impl Clone for Box<dyn Signer> {
fn clone(&self) -> Self {
self.clone_box()
}
}
pub trait Verifier: Send {
fn verify(
&self,
message: &[u8],
signature: &Signature,
public_key: &PublicKey,
) -> Result<bool, VerificationError>;
}
pub trait Context {
fn new_signer(&self, key: PrivateKey) -> Box<dyn Signer>;
fn new_verifier(&self) -> Box<dyn Verifier>;
fn new_random_private_key(&self) -> PrivateKey;
fn get_public_key(&self, private_key: &PrivateKey) -> Result<PublicKey, ContextError>;
}