41 lines
No EOL
1.1 KiB
Rust
41 lines
No EOL
1.1 KiB
Rust
use crate::domain::entities::*;
|
|
use crate::domain::error::DomainError;
|
|
|
|
pub trait MnemonicGenerator {
|
|
type Error: Into<DomainError>;
|
|
|
|
fn generate(&self) -> Result<RecoveryPhrase, Self::Error>;
|
|
fn validate(&self, words: &[String]) -> Result<(), Self::Error>;
|
|
}
|
|
|
|
pub trait KeyDeriver {
|
|
type Error: Into<DomainError>;
|
|
|
|
fn derive_from_seed(&self, seed: &Seed) -> Result<(PublicKey, PrivateKey), Self::Error>;
|
|
fn derive_from_mnemonic(&self, mnemonic: &RecoveryPhrase) -> Result<Seed, Self::Error>;
|
|
}
|
|
|
|
pub trait FileEncryptor {
|
|
type Error: Into<DomainError>;
|
|
|
|
fn encrypt(
|
|
&self,
|
|
seed: &Seed,
|
|
password: &str,
|
|
public_key: &PublicKey,
|
|
did: &Did,
|
|
) -> Result<PassportFile, Self::Error>;
|
|
|
|
fn decrypt(
|
|
&self,
|
|
file: &PassportFile,
|
|
password: &str,
|
|
) -> Result<(Seed, PublicKey, PrivateKey), Self::Error>;
|
|
}
|
|
|
|
pub trait FileStorage {
|
|
type Error: Into<DomainError>;
|
|
|
|
fn save(&self, file: &PassportFile, path: &str) -> Result<(), Self::Error>;
|
|
fn load(&self, path: &str) -> Result<PassportFile, Self::Error>;
|
|
} |