use crate::{Error, Multisig};
use multi_codec::Codec;
pub mod bls12381;
pub mod ed25519;
pub(crate) mod ed25519_hybrid;
pub(crate) mod ed25519_mayo2;
pub mod fn_dsa;
pub mod mayo;
pub mod ml_dsa;
pub mod nist_p;
pub mod rsa;
pub mod secp256k1;
pub mod slh_dsa;
pub mod threshold_meta;
pub use threshold_meta::{
decrypt_threshold_meta, disclosure_mode, encrypt_threshold_meta, generate_meta_key,
read_threshold_params, stamp_disclosure_attrs, DisclosureView, ThresholdDisclosure,
ThresholdMetaCipher, ThresholdMetadata,
};
pub trait AttrView {
fn payload_encoding(&self) -> Result<Codec, Error>;
fn scheme(&self) -> Result<u8, Error>;
}
pub trait DataView {
fn sig_bytes(&self) -> Result<Vec<u8>, Error>;
}
pub trait ConvView {
fn to_ssh_signature(&self) -> Result<ssh_key::Signature, Error>;
}
pub trait ThresholdAttrView {
fn threshold(&self) -> Result<usize, Error>;
fn limit(&self) -> Result<usize, Error>;
fn identifier(&self) -> Result<&[u8], Error>;
fn threshold_data(&self) -> Result<&[u8], Error>;
}
pub trait ThresholdView {
fn shares(&self) -> Result<Vec<Multisig>, Error>;
fn shares_with_disclosure(
&self,
mode: ThresholdDisclosure,
meta_key: Option<&[u8]>,
) -> Result<Vec<Multisig>, Error>;
fn add_share(&self, share: &Multisig) -> Result<Multisig, Error>;
fn add_share_with_meta(
&self,
share: &Multisig,
meta_key: Option<&[u8]>,
) -> Result<Multisig, Error>;
fn combine(&self) -> Result<Multisig, Error>;
fn combine_with_meta(&self, meta_key: Option<&[u8]>) -> Result<Multisig, Error>;
}
pub trait ThresholdDisclosureView {
fn disclosure_mode(&self) -> Result<ThresholdDisclosure, Error>;
fn read_threshold_params(&self, meta_key: Option<&[u8]>) -> Result<(usize, usize), Error>;
fn to_disclosure(
&self,
target: ThresholdDisclosure,
meta_key: Option<&[u8]>,
current_meta_key: Option<&[u8]>,
) -> Result<Multisig, Error>;
}
pub trait Views {
fn attr_view<'a>(&'a self) -> Result<Box<dyn AttrView + 'a>, Error>;
fn data_view<'a>(&'a self) -> Result<Box<dyn DataView + 'a>, Error>;
fn conv_view<'a>(&'a self) -> Result<Box<dyn ConvView + 'a>, Error>;
fn threshold_attr_view<'a>(&'a self) -> Result<Box<dyn ThresholdAttrView + 'a>, Error>;
fn threshold_view<'a>(&'a self) -> Result<Box<dyn ThresholdView + 'a>, Error>;
fn disclosure_view<'a>(&'a self) -> Result<Box<dyn ThresholdDisclosureView + 'a>, Error>;
}