1
1
2
+ #![ allow( unused_variables) ]
3
+ #![ allow( dead_code) ]
4
+
5
+ type CredentialSubject = serde_json:: Value ;
6
+ type CredentialTypes = [ VerifiableCredential ] ;
7
+
2
8
3
9
// #[derive(Deserialize, Debug)]
4
10
pub struct VerifiableCredential {
5
11
context : String ,
6
12
id : String ,
7
- credType : String ,
13
+ cred_type : String ,
8
14
issuer : String ,
9
- issuanceDate : String ,
15
+ issuance_date : String ,
10
16
subject : CredentialSubject ,
11
17
proof : * mut CredentialProof ,
12
18
}
13
19
14
20
impl < ' a > VerifiableCredential {
15
- pub fn init ( credType : & ' a str , credSubject : serde_json:: Value ) -> Self {
21
+ pub fn init ( cred_type : & ' a str , cred_subject : serde_json:: Value ) -> Self {
16
22
Self {
17
- context : String :: default ( ) , // array defined by us
18
- id : String :: default ( ) , // provided by client
19
- credType : String :: from ( credType) ,
20
- issuer : String :: default ( ) , // provided by client
21
- issuanceDate : String :: default ( ) ,
22
- subject : credSubject, //
23
- proof : & mut CredentialProof { // we don't have it
24
- proofType : String :: default ( ) ,
23
+ /// context is a slice, it is defined by us based on parsed cred type and cred subject
24
+ context : String :: default ( ) ,
25
+ /// provided by client
26
+ id : String :: default ( ) ,
27
+ cred_type : String :: from ( cred_type) ,
28
+ /// provided by client
29
+ issuer : String :: default ( ) ,
30
+ issuance_date : String :: default ( ) ,
31
+ subject : cred_subject,
32
+ /// created empty object on VerifiableCredential init step, will be filled on "create_data_integrity_proof" step
33
+ proof : & mut CredentialProof {
34
+ proof_type : String :: default ( ) ,
25
35
created : String :: default ( ) ,
26
- verificationMethod : String :: default ( ) ,
27
- proofPurpose : String :: default ( ) ,
28
- proofValue : String :: default ( ) ,
36
+ verification_method : String :: default ( ) ,
37
+ proof_purpose : String :: default ( ) ,
38
+ proof_value : String :: default ( ) ,
29
39
} ,
30
40
}
31
41
}
42
+
43
+ pub fn serialize ( self ) -> serde_json:: Value {
44
+ return self . subject
45
+ }
32
46
}
33
47
34
48
35
49
pub struct CredentialProof {
36
- proofType : String ,
50
+ proof_type : String ,
37
51
created : String ,
38
- verificationMethod : String ,
39
- proofPurpose : String ,
40
- proofValue : String ,
52
+ verification_method : String ,
53
+ proof_purpose : String ,
54
+ proof_value : String ,
41
55
}
42
56
43
- type CredentialSubject = serde_json:: Value ;
44
-
57
+ pub struct VerifiablePresentation {
58
+ nonce : String ,
59
+ endpoint : String ,
60
+ credential_types : CredentialTypes ,
61
+ }
0 commit comments