Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DIF presentation exchange context and cache document #3093

Merged
merged 3 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ include aries_cloudagent/vc/ld_proofs/resources/status_list_context.jsonld
include aries_cloudagent/vc/ld_proofs/resources/security-v1-context.jsonld
include aries_cloudagent/vc/ld_proofs/resources/security-v2-context.jsonld
include aries_cloudagent/vc/ld_proofs/resources/ed25519-2020-context.jsonld
include aries_cloudagent/vc/ld_proofs/resources/bbs-v1-context.jsonld
include aries_cloudagent/vc/ld_proofs/resources/dif-presentation-exchange-submission-v1.jsonld
include README.md
25 changes: 16 additions & 9 deletions aries_cloudagent/protocols/present_proof/dif/pres_exch_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1261,9 +1261,7 @@ async def create_vp(
)
if not issuer_id and len(filtered_creds_list) == 0:
vp = await create_presentation(credentials=applicable_creds_list)
jamshale marked this conversation as resolved.
Show resolved Hide resolved
vp["presentation_submission"] = submission_property.serialize()
if self.proof_type is BbsBlsSignature2020.signature_type:
vp["@context"].append(SECURITY_CONTEXT_BBS_URL)
vp = self.__add_dif_fields_to_vp(vp, submission_property)
result_vp.append(vp)
continue
else:
Expand All @@ -1280,19 +1278,15 @@ async def create_vp(
vp = await create_presentation(
credentials=applicable_creds_list
)
vp["presentation_submission"] = submission_property.serialize()
if self.proof_type is BbsBlsSignature2020.signature_type:
vp["@context"].append(SECURITY_CONTEXT_BBS_URL)
vp = self.__add_dif_fields_to_vp(vp, submission_property)
result_vp.append(vp)
continue
else:
vp = await create_presentation(credentials=filtered_creds_list)
else:
issuer_id = self.pres_signing_did
vp = await create_presentation(credentials=applicable_creds_list)
vp["presentation_submission"] = submission_property.serialize()
if self.proof_type is BbsBlsSignature2020.signature_type:
vp["@context"].append(SECURITY_CONTEXT_BBS_URL)
vp = self.__add_dif_fields_to_vp(vp, submission_property)
issue_suite = await self._get_issue_suite(
issuer_id=issuer_id,
)
Expand All @@ -1307,6 +1301,19 @@ async def create_vp(
return result_vp[0]
return result_vp

def __add_dif_fields_to_vp(
self,
vp: dict,
submission_property: PresentationSubmission
) -> dict:
vp["@context"].append(PRESENTATION_SUBMISSION_JSONLD_CONTEXT)
vp["type"].append(PRESENTATION_SUBMISSION_JSONLD_TYPE)
vp["presentation_submission"] = submission_property.serialize()
if self.proof_type is BbsBlsSignature2020.signature_type:
vp["@context"].append(SECURITY_CONTEXT_BBS_URL)

return vp

def check_if_cred_id_derived(self, id: str) -> bool:
"""Check if credential or credentialSubject id is derived."""
if id.startswith("urn:bnid:_:c14n"):
Expand Down
2 changes: 2 additions & 0 deletions aries_cloudagent/vc/ld_proofs/document_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class StaticCacheJsonLdDownloader:
"https://w3id.org/security/v2": "security-v2-context.jsonld",
"https://w3id.org/security/suites/ed25519-2020/v1": "ed25519-2020-context.jsonld",
"https://w3id.org/security/bbs/v1": "bbs-v1-context.jsonld",
"https://identity.foundation/presentation-exchange/submission/v1":
"dif-presentation-exchange-submission-v1.jsonld",
}

def __init__(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"@context": {
"@version": 1.1,
"PresentationSubmission": {
"@id": "https://identity.foundation/presentation-exchange/#presentation-submission",
"@context": {
"@version": 1.1,
"presentation_submission": {
"@id": "https://identity.foundation/presentation-exchange/#presentation-submission",
"@type": "@json"
}
}
}
}
}
2 changes: 2 additions & 0 deletions aries_cloudagent/vc/tests/contexts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .did_v1 import DID_V1
from .dif_presentation_submission_v1 import DIF_PRESENTATION_SUBMISSION_V1
from .security_v1 import SECURITY_V1
from .security_v2 import SECURITY_V2
from .security_v3_unstable import SECURITY_V3_UNSTABLE
Expand All @@ -14,6 +15,7 @@

__all__ = [
"DID_V1",
"DIF_PRESENTATION_SUBMISSION_V1",
"SECURITY_V1",
"SECURITY_V2",
"SECURITY_V3_UNSTABLE",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
DIF_PRESENTATION_SUBMISSION_V1 = {
"@context": {
"@version": 1.1,
"PresentationSubmission": {
"@id": "https://identity.foundation/presentation-exchange/#presentation-submission",
"@context": {
"@version": 1.1,
"presentation_submission": {
"@id": "https://identity.foundation/presentation-exchange/#presentation-submission",
"@type": "@json"
}
}
}
}
}
2 changes: 2 additions & 0 deletions aries_cloudagent/vc/tests/document_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
VACCINATION_V1,
ODRL,
SCHEMA_ORG,
DIF_PRESENTATION_SUBMISSION_V1,
)
from ..ld_proofs.constants import (
SECURITY_CONTEXT_V2_URL,
Expand Down Expand Up @@ -49,6 +50,7 @@
"https://www.w3.org/ns/odrl.jsonld": ODRL,
"http://schema.org/": SCHEMA_ORG,
"https://w3id.org/vaccination/v1": VACCINATION_V1,
"https://identity.foundation/presentation-exchange/submission/v1": DIF_PRESENTATION_SUBMISSION_V1,
}


Expand Down
Loading