import asyncio import didkit import json from jinja2 import Environment, FileSystemLoader, select_autoescape import idhub_ssikit def issue_vc_test(): jwk_issuer = didkit.generate_ed25519_key() jwk_subject = didkit.generate_ed25519_key() did_issuer = didkit.key_to_did("key", jwk_issuer) did_subject = didkit.key_to_did("key", jwk_subject) env = Environment( loader=FileSystemLoader("vc_templates"), autoescape=select_autoescape() ) unsigned_vc_template = env.get_template("member.json") data = { "vc_id": "http://example.org/credentials/3731", "issuer_did": did_issuer, "subject_did": did_subject, "issuance_date": "2020-08-19T21:41:50Z", } signed_credential = idhub_ssikit.render_and_sign_credential( unsigned_vc_template, jwk_issuer, data ) print(signed_credential) def issue_vp_test(): jwk_issuer = didkit.generate_ed25519_key() jwk_issuer2 = didkit.generate_ed25519_key() jwk_subject = didkit.generate_ed25519_key() did_issuer = didkit.key_to_did("key", jwk_issuer) did_issuer2 = didkit.key_to_did("key", jwk_issuer2) did_subject = didkit.key_to_did("key", jwk_subject) print(did_issuer) print(did_issuer2) print(did_subject) env = Environment( loader=FileSystemLoader("vc_templates"), autoescape=select_autoescape() ) unsigned_vc_template = env.get_template("member.json") data = { "vc_id": "http://example.org/credentials/3731", "issuer_did": did_issuer, "subject_did": did_subject, "issuance_date": "2020-08-19T21:41:50Z", "subject_is_member_of": "Pangea" } signed_credential = idhub_ssikit.render_and_sign_credential( unsigned_vc_template, jwk_issuer, data ) data2 = data data2["issuer_did"] = did_issuer2 signed_credential2 = idhub_ssikit.render_and_sign_credential( unsigned_vc_template, jwk_issuer2, data2 ) signed_presentation = idhub_ssikit.issue_verifiable_presentation([signed_credential, signed_credential2], jwk_subject, did_subject) print(signed_presentation)