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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use crate::{didcore::Config, Document, Error, VerificationMethod};
use json_patch::PatchOperation;
pub trait KeyMaterial {
fn public_key_bytes(&self) -> Vec<u8>;
fn private_key_bytes(&self) -> Vec<u8>;
}
pub trait Generate: KeyMaterial {
fn new() -> Self;
fn new_with_seed(seed: &[u8]) -> Self;
fn from_public_key(public_key: &[u8]) -> Self;
fn from_secret_key(private_key: &[u8]) -> Self;
}
pub trait CoreSign {
fn sign(&self, payload: &[u8]) -> Vec<u8>;
fn verify(&self, payload: &[u8], signature: &[u8]) -> Result<(), Error>;
}
pub trait ECDH {
fn key_exchange(&self, their_public: &Self) -> Vec<u8>;
}
pub trait DIDCore {
fn get_verification_methods(&self, config: Config, controller: &str) -> Vec<VerificationMethod>;
fn get_did_document(&self, config: Config) -> Document;
}
pub trait Fingerprint {
fn fingerprint(&self) -> String;
}
pub trait AddDIDJsonPatches {
fn add_patches(&mut self, patches: Vec<PatchOperation>);
}