Skip to content
Snippets Groups Projects
Commit 1ac89c33 authored by Éloïs's avatar Éloïs
Browse files

KeyPair : add accesseurs

parent bf3867cb
No related branches found
No related tags found
1 merge request!9Resolve "Add keyPair type"
......@@ -236,8 +236,19 @@ impl Eq for KeyPair {}
impl super::KeyPair for KeyPair {
type Signature = Signature;
type PublicKey = PublicKey;
type PrivateKey = PrivateKey;
fn public_key(&self) -> PublicKey {
self.pubkey
}
fn private_key(&self) -> PrivateKey {
self.privkey
}
fn sign(&self, message: &[u8]) -> Signature {
self.privkey.sign(message)
self.private_key().sign(message)
}
}
......
......@@ -152,6 +152,16 @@ pub trait PrivateKey: Clone + Display + Debug + PartialEq + Eq + ToBase58 {
pub trait KeyPair: Clone + Display + Debug + PartialEq + Eq {
/// Signature type of associated cryptosystem.
type Signature: Signature;
/// PublicKey type of associated cryptosystem.
type PublicKey: PublicKey;
/// PrivateKey type of associated cryptosystem.
type PrivateKey: PrivateKey;
/// Get `PublicKey`
fn public_key(&self) -> Self::PublicKey;
/// Get `PrivateKey`
fn private_key(&self) -> Self::PrivateKey;
/// Sign a message with privkey.
fn sign(&self, message: &[u8]) -> Self::Signature;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment