use crate::{Error, Multikey};
use multi_codec::Codec;
use multi_hash::Multihash;
use multi_sig::Multisig;
use zeroize::Zeroizing;
pub(crate) mod bcrypt;
pub(crate) mod bls12381;
pub(crate) mod bls12381_g1_fndsa512;
pub(crate) mod bls12381_g1_mayo1;
pub(crate) mod bls12381_g1_mayo2;
pub(crate) mod bls12381_g1_mldsa65;
pub(crate) mod bls12381_hybrid;
pub(crate) mod chacha20;
pub(crate) mod classic_mceliece;
pub(crate) mod dkg_threshold;
pub(crate) mod ed25519;
pub(crate) mod ed25519_fndsa512;
pub(crate) mod ed25519_mayo2;
pub(crate) mod ed25519_mldsa65;
pub(crate) mod fn_dsa;
pub(crate) mod frodokem;
pub(crate) mod frodokem_helper;
pub(crate) mod mayo;
pub(crate) mod ml_dsa;
pub(crate) mod ml_kem;
pub(crate) mod nist_p;
pub(crate) mod rsa;
pub(crate) mod secp256k1;
pub(crate) mod slh_dsa;
pub(crate) mod sntrup;
pub mod threshold_marker;
pub(crate) mod x25519;
pub(crate) mod x25519_frodokem640;
pub(crate) mod x25519_mceliece348864;
pub(crate) mod x25519_mlkem768;
pub(crate) mod x25519_sntrup761;
pub(crate) mod aead;
pub trait AttrView {
fn is_encrypted(&self) -> bool;
fn is_public_key(&self) -> bool;
fn is_secret_key(&self) -> bool;
fn is_secret_key_share(&self) -> bool;
}
pub trait CipherAttrView {
fn cipher_codec(&self) -> Result<Codec, Error>;
fn nonce_bytes(&self) -> Result<Zeroizing<Vec<u8>>, Error>;
fn key_length(&self) -> Result<usize, Error>;
}
pub trait DataView {
fn key_bytes(&self) -> Result<Zeroizing<Vec<u8>>, Error>;
fn secret_bytes(&self) -> Result<Zeroizing<Vec<u8>>, Error>;
}
pub trait KdfAttrView {
fn kdf_codec(&self) -> Result<Codec, Error>;
fn salt_bytes(&self) -> Result<Zeroizing<Vec<u8>>, Error>;
fn rounds(&self) -> Result<usize, 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 CipherView {
fn decrypt(&self) -> Result<Multikey, Error>;
fn encrypt(&self) -> Result<Multikey, Error>;
}
pub trait ConvView {
fn to_public_key(&self) -> Result<Multikey, Error>;
fn to_ssh_public_key(&self) -> Result<ssh_key::PublicKey, Error>;
fn to_ssh_private_key(&self) -> Result<ssh_key::PrivateKey, Error>;
}
pub trait FingerprintView {
fn fingerprint(&self, hash: Codec) -> Result<Multihash, Error>;
}
pub trait KdfView {
fn derive_key(&self, passphrase: &[u8]) -> Result<Multikey, Error>;
}
pub trait SealView {
fn seal(
&self,
plaintext: &[u8],
aead_codec: Codec,
aad: &[u8],
) -> Result<(Vec<u8>, Option<Multikey>), Error>;
}
pub trait OpenView {
fn open(
&self,
sealed_msg: &[u8],
ephemeral: Option<&Multikey>,
aad: &[u8],
) -> Result<Zeroizing<Vec<u8>>, Error>;
}
pub trait SignView {
fn sign(&self, msg: &[u8], combined: bool, scheme: Option<u8>) -> Result<Multisig, Error>;
}
pub trait ThresholdView {
fn split(&self, threshold: usize, limit: usize) -> Result<Vec<Multikey>, Error>;
fn add_share(&self, share: &Multikey) -> Result<Multikey, Error>;
fn combine(&self) -> Result<Multikey, Error>;
}
pub trait ThresholdKeyView {
fn group_pubkey(&self) -> Result<Vec<u8>, Error>;
fn is_threshold_key(&self) -> bool;
fn participant_count(&self) -> Result<u16, Error>;
fn threshold(&self) -> Result<u16, Error>;
fn owner_vlad(&self) -> Result<Vec<u8>, Error>;
}
pub trait VerifyView {
fn verify(&self, sig: &Multisig, msg: Option<&[u8]>) -> Result<(), Error>;
}
pub trait Views {
fn attr_view<'a>(&'a self) -> Result<Box<dyn AttrView + 'a>, Error>;
fn cipher_attr_view<'a>(&'a self) -> Result<Box<dyn CipherAttrView + 'a>, Error>;
fn data_view<'a>(&'a self) -> Result<Box<dyn DataView + 'a>, Error>;
fn kdf_attr_view<'a>(&'a self) -> Result<Box<dyn KdfAttrView + 'a>, Error>;
fn threshold_attr_view<'a>(&'a self) -> Result<Box<dyn ThresholdAttrView + 'a>, Error>;
fn threshold_key_view<'a>(&'a self) -> Result<Box<dyn ThresholdKeyView + 'a>, Error>;
fn cipher_view<'a>(&'a self, cipher: &'a Multikey) -> Result<Box<dyn CipherView + 'a>, Error>;
fn conv_view<'a>(&'a self) -> Result<Box<dyn ConvView + 'a>, Error>;
fn fingerprint_view<'a>(&'a self) -> Result<Box<dyn FingerprintView + 'a>, Error>;
fn kdf_view<'a>(&'a self, kdf: &'a Multikey) -> Result<Box<dyn KdfView + 'a>, Error>;
fn seal_view<'a>(&'a self) -> Result<Box<dyn SealView + 'a>, Error>;
fn open_view<'a>(&'a self) -> Result<Box<dyn OpenView + 'a>, Error>;
fn sign_view<'a>(&'a self) -> Result<Box<dyn SignView + 'a>, Error>;
fn threshold_view<'a>(&'a self) -> Result<Box<dyn ThresholdView + 'a>, Error>;
fn verify_view<'a>(&'a self) -> Result<Box<dyn VerifyView + 'a>, Error>;
}