33 lines
982 B
Python
33 lines
982 B
Python
|
import asyncio
|
||
|
import didkit
|
||
|
import json
|
||
|
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
||
|
|
||
|
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)
|
||
|
|
||
|
|
||
|
async def main():
|
||
|
env = Environment(
|
||
|
loader=FileSystemLoader("vc_templates"),
|
||
|
autoescape=select_autoescape()
|
||
|
)
|
||
|
unsigned_vc_template = env.get_template("affiliation.jsonld.j2")
|
||
|
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"
|
||
|
}
|
||
|
unsigned_vc = unsigned_vc_template.render(data)
|
||
|
signed_credential = await didkit.issue_credential(
|
||
|
unsigned_vc,
|
||
|
json.dumps({"proofFormat": "ldp"}),
|
||
|
jwk_issuer)
|
||
|
print(signed_credential)
|
||
|
|
||
|
asyncio.run(main())
|