#![allow(deprecated)]
#[cfg(feature = "wots_deprecated_do_not_use")]
#[cfg_attr(docsrs, doc(cfg(feature = "wots_deprecated_do_not_use")))]
#[cfg_attr(not(test), deprecated)]
pub mod wots;
use zeroize::Zeroize;
use crate::{
encoding::ternary::{T1B1Buf, TritBuf, Trits, T1B1},
hashes::ternary::{HASH_LENGTH, HASH_LENGTH_TRYTES},
};
pub const MESSAGE_FRAGMENT_LENGTH_TRYTES: usize = 27;
pub const MESSAGE_FRAGMENT_LENGTH_TRITS: usize = MESSAGE_FRAGMENT_LENGTH_TRYTES * 3;
pub const NUM_MESSAGE_FRAGMENTS: usize = HASH_LENGTH_TRYTES / MESSAGE_FRAGMENT_LENGTH_TRYTES;
pub const SIGNATURE_FRAGMENT_LENGTH: usize = MESSAGE_FRAGMENT_LENGTH_TRYTES * HASH_LENGTH;
pub trait PrivateKey: Zeroize {
type PublicKey: PublicKey;
type Signature: Signature;
type Error;
fn generate_public_key(&self) -> Result<Self::PublicKey, Self::Error>;
fn sign(&mut self, message: &Trits<T1B1>) -> Result<Self::Signature, Self::Error>;
fn from_trits(buf: TritBuf<T1B1Buf>) -> Result<Self, Self::Error>
where
Self: Sized;
fn as_trits(&self) -> &Trits<T1B1>;
}
pub trait PublicKey {
type Signature: Signature;
type Error;
fn verify(&self, message: &Trits<T1B1>, signature: &Self::Signature) -> Result<bool, Self::Error>;
fn size(&self) -> usize;
fn from_trits(buf: TritBuf<T1B1Buf>) -> Result<Self, Self::Error>
where
Self: Sized;
fn as_trits(&self) -> &Trits<T1B1>;
}
pub trait Signature {
type Error;
fn size(&self) -> usize;
fn from_trits(buf: TritBuf<T1B1Buf>) -> Result<Self, Self::Error>
where
Self: Sized;
fn as_trits(&self) -> &Trits<T1B1>;
}
pub trait RecoverableSignature: Signature {
type PublicKey: PublicKey;
type Error;
fn recover_public_key(
&self,
message: &Trits<T1B1>,
) -> Result<Self::PublicKey, <Self as RecoverableSignature>::Error>;
}