@@ -76,35 +76,33 @@ async fn main() -> anyhow::Result<()> {
76
76
create_did ( & client, & mut secret_manager_issuer, & storage_issuer) . await ?;
77
77
78
78
// Create an identity for the holder, in this case also the subject.
79
- let mut secret_manager_alice : SecretManager = SecretManager :: Stronghold (
79
+ let mut secret_manager_holder : SecretManager = SecretManager :: Stronghold (
80
80
StrongholdSecretManager :: builder ( )
81
81
. password ( Password :: from ( "secure_password_2" . to_owned ( ) ) )
82
82
. build ( random_stronghold_path ( ) ) ?,
83
83
) ;
84
- let storage_alice : MemStorage = MemStorage :: new ( JwkMemStore :: new ( ) , KeyIdMemstore :: new ( ) ) ;
85
- let ( _, alice_document , fragment_alice ) : ( Address , IotaDocument , String ) =
86
- create_did ( & client, & mut secret_manager_alice , & storage_alice ) . await ?;
84
+ let storage_holder : MemStorage = MemStorage :: new ( JwkMemStore :: new ( ) , KeyIdMemstore :: new ( ) ) ;
85
+ let ( _, holder_document , fragment_holder ) : ( Address , IotaDocument , String ) =
86
+ create_did ( & client, & mut secret_manager_holder , & storage_holder ) . await ?;
87
87
88
88
// ===========================================================================
89
89
// Step 2: Issuer creates and signs a Verifiable Credential.
90
90
// ===========================================================================
91
91
92
- // Create a credential subject indicating the degree earned by Alice .
92
+ // Create a credential subject indicating some trustworthy certificate for the holder .
93
93
let subject: Subject = Subject :: from_json_value ( json ! ( {
94
- "id" : alice_document. id( ) . as_str( ) ,
95
- "name" : "Alice" ,
96
- "degree" : {
97
- "type" : "BachelorDegree" ,
98
- "name" : "Bachelor of Science and Arts" ,
99
- } ,
100
- "GPA" : "4.0" ,
94
+ "id" : holder_document. id( ) . as_str( ) ,
95
+ "certificate" : {
96
+ "type" : "Accreditation" ,
97
+ "level" : 3
98
+ }
101
99
} ) ) ?;
102
100
103
101
// Build credential using subject above and issuer.
104
102
let credential: Credential = CredentialBuilder :: default ( )
105
- . id ( Url :: parse ( "https://example.edu/credentials/3732 " ) ?)
103
+ . id ( Url :: parse ( "https://example.org/accreditations/1337 " ) ?)
106
104
. issuer ( Url :: parse ( issuer_document. id ( ) . as_str ( ) ) ?)
107
- . type_ ( "UniversityDegreeCredential " )
105
+ . type_ ( "AccreditationCredential " )
108
106
. subject ( subject)
109
107
. build ( ) ?;
110
108
@@ -156,22 +154,24 @@ async fn main() -> anyhow::Result<()> {
156
154
157
155
// Create an unsigned Presentation from the previously issued Verifiable Credential.
158
156
let presentation: Presentation < Jwt > =
159
- PresentationBuilder :: new ( alice_document . id ( ) . to_url ( ) . into ( ) , Default :: default ( ) )
157
+ PresentationBuilder :: new ( holder_document . id ( ) . to_url ( ) . into ( ) , Default :: default ( ) )
160
158
. credential ( credential_jwt)
161
159
. build ( ) ?;
162
160
163
161
// Create a JWT verifiable presentation using the holder's verification method
164
162
// and include the requested challenge and expiry timestamp.
165
- let presentation_jwt: Jwt = alice_document
163
+ let presentation_jwt: Jwt = holder_document
166
164
. create_presentation_jwt (
167
165
& presentation,
168
- & storage_alice ,
169
- & fragment_alice ,
170
- & JwsSignatureOptions :: default ( ) . nonce ( challenge. to_owned ( ) ) ,
171
- & JwtPresentationOptions :: default ( ) . expiration_date ( expires) ,
166
+ & storage_holder ,
167
+ & fragment_holder ,
168
+ & JwsSignatureOptions :: default ( ) , // .nonce(challenge.to_owned()),
169
+ & JwtPresentationOptions :: default ( ) , // .expiration_date(expires),
172
170
)
173
171
. await ?;
174
172
173
+ println ! ( "{:?}" , presentation_jwt) ;
174
+
175
175
// ===========================================================================
176
176
// Step 6: Holder sends a verifiable presentation to the verifier.
177
177
// ===========================================================================
0 commit comments