Skip to content

Commit 5d454c8

Browse files
committed
refactor: adjust example
1 parent e220db2 commit 5d454c8

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

examples/0_basic/6_create_vp.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -76,35 +76,33 @@ async fn main() -> anyhow::Result<()> {
7676
create_did(&client, &mut secret_manager_issuer, &storage_issuer).await?;
7777

7878
// 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(
8080
StrongholdSecretManager::builder()
8181
.password(Password::from("secure_password_2".to_owned()))
8282
.build(random_stronghold_path())?,
8383
);
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?;
8787

8888
// ===========================================================================
8989
// Step 2: Issuer creates and signs a Verifiable Credential.
9090
// ===========================================================================
9191

92-
// Create a credential subject indicating the degree earned by Alice.
92+
// Create a credential subject indicating some trustworthy certificate for the holder.
9393
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+
}
10199
}))?;
102100

103101
// Build credential using subject above and issuer.
104102
let credential: Credential = CredentialBuilder::default()
105-
.id(Url::parse("https://example.edu/credentials/3732")?)
103+
.id(Url::parse("https://example.org/accreditations/1337")?)
106104
.issuer(Url::parse(issuer_document.id().as_str())?)
107-
.type_("UniversityDegreeCredential")
105+
.type_("AccreditationCredential")
108106
.subject(subject)
109107
.build()?;
110108

@@ -156,22 +154,24 @@ async fn main() -> anyhow::Result<()> {
156154

157155
// Create an unsigned Presentation from the previously issued Verifiable Credential.
158156
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())
160158
.credential(credential_jwt)
161159
.build()?;
162160

163161
// Create a JWT verifiable presentation using the holder's verification method
164162
// and include the requested challenge and expiry timestamp.
165-
let presentation_jwt: Jwt = alice_document
163+
let presentation_jwt: Jwt = holder_document
166164
.create_presentation_jwt(
167165
&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),
172170
)
173171
.await?;
174172

173+
println!("{:?}", presentation_jwt);
174+
175175
// ===========================================================================
176176
// Step 6: Holder sends a verifiable presentation to the verifier.
177177
// ===========================================================================

0 commit comments

Comments
 (0)