pyvckit #1

Merged
cayop merged 17 commits from pyvckit into release 2024-06-11 15:10:32 +00:00
1 changed files with 8 additions and 4 deletions
Showing only changes of commit 32ad6edd9d - Show all commits

View File

@ -1,11 +1,12 @@
import json import json
import uuid
from django import forms from django import forms
from django.template.loader import get_template from django.template.loader import get_template
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from utils.idhub_ssikit import create_verifiable_presentation from pyvckit.sign import sign
from idhub.models import VerificableCredential from idhub.models import VerificableCredential
@ -72,13 +73,16 @@ class AuthorizeForm(forms.Form):
def get_verificable_presentation(self): def get_verificable_presentation(self):
did = self.subject_did did = self.subject_did
vc_list = [json.loads(x) for x in self.list_credentials]
vp_template = get_template('credentials/verifiable_presentation.json') vp_template = get_template('credentials/verifiable_presentation.json')
vc_list = json.dumps([json.loads(x) for x in self.list_credentials])
context = { context = {
"holder_did": did.did, "holder_did": did.did,
"verifiable_credential_list": vc_list "verificable_credentials": vc_list,
"id": str(uuid.uuid4())
} }
unsigned_vp = vp_template.render(context) unsigned_vp = vp_template.render(context)
key_material = did.get_key_material() key_material = did.get_key_material()
self.vp = create_verifiable_presentation(key_material, unsigned_vp) self.vp = sign(key_material, unsigned_vp, did.did)