key_resolver/
common.rs

1use fi_common::error::Error;
2use serde::{Deserialize, Serialize};
3
4#[derive(Serialize, Deserialize, Clone, Debug)]
5pub struct KeyPair {
6    pub id: Option<String>,
7    #[serde(rename = "type")]
8    pub _type: String,
9    #[serde(rename = "@context")]
10    pub context: Option<String>,
11    pub public_key_base58: Option<String>,
12    pub private_key_base58: Option<String>,
13    pub public_key_multibase: Option<String>,
14    pub private_key_multibase: Option<String>,
15    pub revoked: bool,
16    pub controller: Option<String>,
17}
18
19pub trait VerificationKey {
20    fn from_fingerprint(fingerprint: &str) -> Result<Self, Error>
21    where
22        Self: Sized;
23
24    fn get_suite_id() -> &'static str
25    where
26        Self: Sized;
27
28    fn get_current_suite_id(&self) -> &'static str;
29
30    fn get_suite_context() -> &'static str
31    where
32        Self: Sized;
33
34    fn get_current_suite_context(&self) -> &'static str;
35
36    fn get_controller(&self) -> &Option<String>;
37
38    fn get_type(&self) -> String;
39
40    fn get_private_key_content(&self) -> &Option<String>;
41    fn get_public_key_content(&self) -> &String;
42
43    fn export(&self, public_key: bool, private_key: bool, include_context: bool) -> KeyPair;
44}
45
46pub trait AgreementKey {
47    fn get_suite_context() -> &'static str
48    where
49        Self: Sized;
50
51    fn get_current_suite_context(&self) -> &'static str;
52
53    fn get_controller(&self) -> &Option<String>;
54
55    fn get_private_key_content(&self) -> &Option<String>;
56    fn get_public_key_content(&self) -> &String;
57
58    fn export(&self, public_key: bool, private_key: bool, include_context: bool) -> KeyPair;
59}