karak-kms 0.2.0

Karak Key Management SDK
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::{error::Error, fmt::Display};

pub trait Keypair: Display {
    type SecretKey;
    type PublicKey;

    fn generate() -> Self;
    // TODO: Add from methods to "load" keys
    fn secret_key(&self) -> &Self::SecretKey;
    fn public_key(&self) -> &Self::PublicKey;
}

pub trait Encryptable: Sized {
    type EncryptionError: Error + Send + Sync;

    fn encrypt(&self, passphrase: &str) -> Result<Vec<u8>, Self::EncryptionError>;
    fn decrypt(encrypted_keypair: &[u8], passphrase: &str) -> Result<Self, Self::EncryptionError>;
}