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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
use async_trait::async_trait;
pub mod one_or_many;
pub mod uri;
#[async_trait]
pub trait VerificationMethod<SP, C> {
type Error;
async fn verify(&self, signed_payload: SP, context_properties: C) -> Result<(), Self::Error>;
}
#[async_trait]
pub trait SigningMethod<P, C, O> {
type Error;
async fn sign(&self, payload: P, context_properties: C) -> Result<O, Self::Error>;
}
#[async_trait]
pub trait ProofConstruction<P, C, I, O, S> {
type Error;
async fn prepare(payload: P, context_properties: C) -> Result<I, Self::Error>;
fn complete(payload: P, context_properties: C, proof: S) -> Result<O, Self::Error>;
}
#[async_trait]
pub trait Verifiable<V, C> {
type Error;
async fn verify_with(&self, vm: V, c: C) -> Result<(), Self::Error>;
}
pub trait Authenticated {
type Id;
fn authenticator(&self) -> Self::Id;
}
#[async_trait]
pub trait VerificationMethodRegistry<I> {
type Error;
type VM;
async fn get_method(&self, id: I) -> Result<Option<Self::VM>, Self::Error>;
}
pub enum VDRError<R, V> {
Registry(R),
IdUnresolvable,
Verification(V),
}
pub trait SemanticallyVerifiable<P> {
type Error;
fn verify_claims(&self, policy: P) -> Result<(), Self::Error>;
}
pub trait ChronologicallyVerifiable<T> {
fn valid_now(&self) -> bool;
fn valid_at(&self, time: T) -> bool;
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
let result = 2 + 2;
assert_eq!(result, 4);
}
}