use crate::error::AptosResult;
pub trait Signer {
type Signature: Signature;
fn sign(&self, message: &[u8]) -> Self::Signature;
fn public_key(&self) -> <Self::Signature as Signature>::PublicKey;
}
pub trait Verifier {
type Signature: Signature;
fn verify(&self, message: &[u8], signature: &Self::Signature) -> AptosResult<()>;
}
pub trait PublicKey: Clone + Sized {
const LENGTH: usize;
fn from_bytes(bytes: &[u8]) -> AptosResult<Self>;
fn to_bytes(&self) -> Vec<u8>;
fn to_hex(&self) -> String {
const_hex::encode_prefixed(self.to_bytes())
}
}
pub trait Signature: Clone + Sized {
type PublicKey: PublicKey;
const LENGTH: usize;
fn from_bytes(bytes: &[u8]) -> AptosResult<Self>;
fn to_bytes(&self) -> Vec<u8>;
fn to_hex(&self) -> String {
const_hex::encode_prefixed(self.to_bytes())
}
}