From cd35ac1bc8fafd908bec6b173d8105ba12b6df8d Mon Sep 17 00:00:00 2001 From: Daniel Armengod Date: Wed, 22 Nov 2023 14:09:08 +0100 Subject: [PATCH] Added support for VP issuance --- idhub_ssikit/__init__.py | 27 ++++++ .../__pycache__/__init__.cpython-311.pyc | Bin 3241 -> 4621 bytes main.py | 86 +++++++++++++----- vc_templates/academic.jsonld.j2 | 23 ----- vc_templates/affiliation.jsonld.j2 | 17 ---- vc_templates/exo.json | 30 ++++++ .../{member-credential.json => member.json} | 0 vc_templates/openarms.json | 33 +++++++ vc_templates/paremanel.json | 30 ++++++ vc_templates/rescue.jsonld.j2 | 23 ----- vc_templates/verifiable_presentation.json | 11 +++ vc_templates/wikipedia.jsonld.j2 | 23 ----- 12 files changed, 195 insertions(+), 108 deletions(-) delete mode 100644 vc_templates/academic.jsonld.j2 delete mode 100644 vc_templates/affiliation.jsonld.j2 create mode 100644 vc_templates/exo.json rename vc_templates/{member-credential.json => member.json} (100%) create mode 100644 vc_templates/openarms.json create mode 100644 vc_templates/paremanel.json delete mode 100644 vc_templates/rescue.jsonld.j2 create mode 100644 vc_templates/verifiable_presentation.json delete mode 100644 vc_templates/wikipedia.jsonld.j2 diff --git a/idhub_ssikit/__init__.py b/idhub_ssikit/__init__.py index f8e03b6..2d2ef27 100644 --- a/idhub_ssikit/__init__.py +++ b/idhub_ssikit/__init__.py @@ -3,6 +3,8 @@ import datetime import didkit import json import jinja2 +from jinja2 import Environment, FileSystemLoader, select_autoescape + def generate_did_controller_key(): @@ -56,3 +58,28 @@ def verify_credential(vc, proof_options): return didkit.verify_credential(vc, proof_options) return asyncio.run(inner()) + + +def issue_verifiable_presentation(vc_list: list[str], jwk_holder: str, holder_did: str) -> str: + async def inner(): + unsigned_vp = unsigned_vp_template.render(data) + signed_vp = await didkit.issue_presentation( + unsigned_vp, + '{"proofFormat": "ldp"}', + jwk_holder + ) + return signed_vp + + env = Environment( + loader=FileSystemLoader("vc_templates"), + autoescape=select_autoescape() + ) + unsigned_vp_template = env.get_template("verifiable_presentation.json") + data = { + "holder_did": holder_did, + "verifiable_credential_list": "[" + ",".join(vc_list) + "]" + } + + return asyncio.run(inner()) + + diff --git a/idhub_ssikit/__pycache__/__init__.cpython-311.pyc b/idhub_ssikit/__pycache__/__init__.cpython-311.pyc index 04f337611627aa851287f44a51c4d6a8805a65f3..ef2f1d4f1c9fd1697eb4d9e134f5368c97fecdc8 100644 GIT binary patch delta 1738 zcmZ`(-D^}w6rcOKH+y&Uxo%^k$)(0k)_iHK*tF3G))pJZmq-f{yIFT8dXu|%!`zz` zMae>K4MHEnJoKdn>4PR!sNlQxPsqwr!-as*KG>&5tTcocdd}S>#-hW$zd18=K4#AO z%`ENywxjb-JRT*`y8b@T{;474Hyms=V^essxX{@*N2u(m1#L_#=wo^zG8T~tRj!jU zgQ|cvR0E7sovD-NmIE4LF&1a>33>O{6q!(|aa|p&r8S^mN29Es#b2#blf^06P_!~= zEoe4SX_TbvKKKJ&oJlKz`LR1|^P*c|t{>EYVmoZ~vgfnH>0*vD9yEB&VR=8BoAHax z%jc%q!jA=MMAS63sC2-JgHKF=*8or=t7b#ROqI>9irKZSc5zeu zAf0W;JOt4xb~)=8v(%<(iPxcx1Yq%)sF!zXXkRN1$Ze7-K9xr@=#+@GZ`thQ=7V45Zxm@soY(hDhWJV!+O-STc>*;x z0Lv;{|75H9+P`?fJReEa92N5{4V|#uOo&0htd#UJP&7##FlN;!q`7_+jqo=Kg$Hnmr19E;tx}n|B zza#V7yfm**C{(&`TvL3k#%A*s(W|r^^wDgy-G=_|)_~koZp$!+zuK;;SJhjJ$SH{y zs@?`qcelOW)UV1^qxvlsm#wSh_2nzzfJQ6L#)`^Ln_xA*YznIo|O;+XZ3{gNb(zVEq|+20UCz z9(a;G^f-Cwen&ZZw30kJZ?3jjm6pR|ATl%;7BdFL+}=T24s@q_2cxep-<3TO{*BQm zy`sAzo!gLlHl*{ws)G${@s>bZUtceg zHCgl;&0^Tl;8)$3jl@i@*0tZN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