Create IOTA Verifiable Credential from existing DID?

I am currently trying to create Verifiable Credentials from existing DIDs in my IOTA Sandbox based on the “examples” code from github (https://github.com/iotaledger/identity.rs/blob/main/examples/0_basic/5_create_vc.rs).

I managed to create the credentials but it seems impossible for me to sign them: I used the existing wallet and stronghold (for the issuer), existing DIDs (for issuer and holder) and also managed to resolve these DIDs to DID-Documents in my code. That all works, the problem is the part where I have to call create_credential_jwt(). I have no idea how I can access the fragment variable when using resolved DID-Documents. It works when creating new ones (like in the examples-link above) but how can I access this variable from resolved DIDs?

Here is my code:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> let client: Client = Client::builder()
.with_primary_node(api_endpoint, None)?
.finish()
.await?;
// Set up resolver
let mut resolver = Resolver::<IotaDocument>::new();
resolver.attach_iota_handler(client.clone());
// Parse and resolve the DIDs
let issuer_did = IotaDID::parse(did_string_issuer)?;
let holder_did = IotaDID::parse(did_string_holder)?;
let issuer_document = resolver.resolve(&issuer_did).await?;
let holder_document = resolver.resolve(&holder_did).await?;
println!("{:#}", issuer_document);
println!("{:#}", holder_document);
// Set up the issuer's secret manager and storage
let mut secret_manager_issuer: SecretManager = SecretManager::Stronghold(
StrongholdSecretManager::builder()
.password(Password::from(password.to_owned()))
.build(stronghold_path)?
);
// Create storage and load the key from the stronghold
let mut issuer_storage: MemStorage = MemStorage::new(JwkMemStore::new(), KeyIdMemstore::new());
// Create a credential subject indicating the degree earned by the Holder.
let subject: Subject = Subject::from_json_value(json!({
"id": holder_document.id().as_str(),
"name": "Holder, BSc",
"degree": {
"type": "MastersDegree",
"name": "Master of Science in Computer Science",
},
"GPA": "4.0",
}))?;
// Build credential using subject above and issuer.
let credential: Credential = CredentialBuilder::default()
.id(Url::parse("https://example.edu/credentials/3732")?)
.issuer(Url::parse(issuer_document.id().as_str())?)
.type_("UniversityDegreeCredential")
.subject(subject)
.build()?;
//println!("Credential JSON > {:#}", credential);
// When creating the credential JWT, use the fragment_issuer variable:
let credential_jwt: Jwt = issuer_document
.create_credential_jwt(
&credential,
&issuer_storage,
&fragment, // got this from the link <- wtf is this? How can I get it?
&JwsSignatureOptions::default(),
None,
)
.await?;
</code>
<code> let client: Client = Client::builder() .with_primary_node(api_endpoint, None)? .finish() .await?; // Set up resolver let mut resolver = Resolver::<IotaDocument>::new(); resolver.attach_iota_handler(client.clone()); // Parse and resolve the DIDs let issuer_did = IotaDID::parse(did_string_issuer)?; let holder_did = IotaDID::parse(did_string_holder)?; let issuer_document = resolver.resolve(&issuer_did).await?; let holder_document = resolver.resolve(&holder_did).await?; println!("{:#}", issuer_document); println!("{:#}", holder_document); // Set up the issuer's secret manager and storage let mut secret_manager_issuer: SecretManager = SecretManager::Stronghold( StrongholdSecretManager::builder() .password(Password::from(password.to_owned())) .build(stronghold_path)? ); // Create storage and load the key from the stronghold let mut issuer_storage: MemStorage = MemStorage::new(JwkMemStore::new(), KeyIdMemstore::new()); // Create a credential subject indicating the degree earned by the Holder. let subject: Subject = Subject::from_json_value(json!({ "id": holder_document.id().as_str(), "name": "Holder, BSc", "degree": { "type": "MastersDegree", "name": "Master of Science in Computer Science", }, "GPA": "4.0", }))?; // Build credential using subject above and issuer. let credential: Credential = CredentialBuilder::default() .id(Url::parse("https://example.edu/credentials/3732")?) .issuer(Url::parse(issuer_document.id().as_str())?) .type_("UniversityDegreeCredential") .subject(subject) .build()?; //println!("Credential JSON > {:#}", credential); // When creating the credential JWT, use the fragment_issuer variable: let credential_jwt: Jwt = issuer_document .create_credential_jwt( &credential, &issuer_storage, &fragment, // got this from the link <- wtf is this? How can I get it? &JwsSignatureOptions::default(), None, ) .await?; </code>
    let client: Client = Client::builder()
        .with_primary_node(api_endpoint, None)?
        .finish()
        .await?;

    // Set up resolver
    let mut resolver = Resolver::<IotaDocument>::new();
    resolver.attach_iota_handler(client.clone());

    // Parse and resolve the DIDs
    let issuer_did = IotaDID::parse(did_string_issuer)?;
    let holder_did = IotaDID::parse(did_string_holder)?;

    let issuer_document = resolver.resolve(&issuer_did).await?;
    let holder_document = resolver.resolve(&holder_did).await?;

    println!("{:#}", issuer_document);
    println!("{:#}", holder_document);

   // Set up the issuer's secret manager and storage
    let mut secret_manager_issuer: SecretManager = SecretManager::Stronghold(
        StrongholdSecretManager::builder()
            .password(Password::from(password.to_owned()))
            .build(stronghold_path)?
    );

    // Create storage and load the key from the stronghold
    let mut issuer_storage: MemStorage = MemStorage::new(JwkMemStore::new(), KeyIdMemstore::new());

    // Create a credential subject indicating the degree earned by the Holder.
    let subject: Subject = Subject::from_json_value(json!({
      "id": holder_document.id().as_str(),
      "name": "Holder, BSc",
      "degree": {
        "type": "MastersDegree",
        "name": "Master of Science in Computer Science",
      },
      "GPA": "4.0",
    }))?;

    // Build credential using subject above and issuer.
    let credential: Credential = CredentialBuilder::default()
    .id(Url::parse("https://example.edu/credentials/3732")?)
    .issuer(Url::parse(issuer_document.id().as_str())?)
    .type_("UniversityDegreeCredential")
    .subject(subject)
    .build()?;

    //println!("Credential JSON > {:#}", credential);

    // When creating the credential JWT, use the fragment_issuer variable:
    let credential_jwt: Jwt = issuer_document
    .create_credential_jwt(
      &credential,
      &issuer_storage,
      &fragment, // got this from the link <- wtf is this? How can I get it?
      &JwsSignatureOptions::default(),
      None,
    )
    .await?;

And here is the part on where they get the fragment-variable from in the examples, when creating new DIDs (not in my code like that, because I resolved existing DID-Documents):

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code> let (_, issuer_document, fragment): (Address, IotaDocument, String) =
create_did(&client, &mut secret_manager_issuer, &issuer_storage).await?;
</code>
<code> let (_, issuer_document, fragment): (Address, IotaDocument, String) = create_did(&client, &mut secret_manager_issuer, &issuer_storage).await?; </code>
  let (_, issuer_document, fragment): (Address, IotaDocument, String) =
    create_did(&client, &mut secret_manager_issuer, &issuer_storage).await?;

Anyone know enough about Rust and/or the IOTA-SDK to help me get this fragment variable from resolved DID-Documents please?

Thank you in advance.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật