1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use crate::algo as base;
pub trait KeyPair: base::Key {
type Private;
type Public;
fn public_key(&self) -> &Self::Public;
fn private_key(&self) -> Option<&Self::Private>;
}
pub trait Algo: base::Algo
where
<Self as base::Algo>::Key: KeyPair,
{
type SigningError;
type VerifyError;
fn sign_public(
msg: &[u8],
key: &<Self::Key as KeyPair>::Public,
) -> Result<Vec<u8>, Self::SigningError>;
fn verify_public(
msg: &[u8],
signature: &[u8],
key: &<Self::Key as KeyPair>::Public,
) -> Result<bool, Self::VerifyError>;
fn sign_private(
msg: &[u8],
key: Option<&<Self::Key as KeyPair>::Private>,
) -> Result<Vec<u8>, Self::SigningError>;
fn verify_private(
msg: &[u8],
signature: &[u8],
key: Option<&<Self::Key as KeyPair>::Private>,
) -> Result<bool, Self::VerifyError>;
}