Skip to content

Commit

Permalink
WIP: vc di proof request
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthakvijayvergiya committed Jun 5, 2024
1 parent 42ac9c3 commit e344a1d
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 30 deletions.
3 changes: 3 additions & 0 deletions aries_cloudagent/protocols/present_proof/dif/pres_exch.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(
ldp: Mapping = None,
ldp_vc: Mapping = None,
ldp_vp: Mapping = None,
di_vc: Mapping = None,
):
"""Initialize format."""
self.jwt = jwt
Expand All @@ -45,6 +46,7 @@ def __init__(
self.ldp = ldp
self.ldp_vc = ldp_vc
self.ldp_vp = ldp_vp
self.di_vc = di_vc


class ClaimFormatSchema(BaseModelSchema):
Expand All @@ -62,6 +64,7 @@ class Meta:
ldp = fields.Dict(required=False)
ldp_vc = fields.Dict(required=False)
ldp_vp = fields.Dict(required=False)
di_vc = fields.Dict(required=False)


class SubmissionRequirements(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ async def create_pres(
domain = proof_request["options"].get("domain")
if not challenge:
challenge = str(uuid4())

# TODO handle vc_di format in the future
input_descriptors = pres_definition.input_descriptors
claim_fmt = pres_definition.fmt
dif_handler_proof_type = None
Expand Down
9 changes: 9 additions & 0 deletions aries_cloudagent/protocols/present_proof/v2_0/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,8 @@ async def present_proof_credentials_list(request: web.BaseRequest):
extra_query,
)
)
indy_credentials = await indy_holder.get_credentials(start, count, {})

except (IndyHolderError, AnonCredsHolderError) as err:
if pres_ex_record:
async with profile.session() as session:
Expand Down Expand Up @@ -718,6 +720,13 @@ async def present_proof_credentials_list(request: web.BaseRequest):
BbsBlsSignature2020.signature_type
]
break
elif claim_fmt.di_vc:
# raise web.HTTPBadRequest(
# reason=(
# "VC DI Not supported for credential fetch"
# )
# )
pass
else:
raise web.HTTPBadRequest(
reason=(
Expand Down
1 change: 1 addition & 0 deletions demo/runners/agent_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ async def handle_present_proof_v2_0(self, message):
creds = await self.admin_GET(
f"/present-proof-2.0/records/{pres_ex_id}/credentials"
)

if creds and 0 < len(creds):
# select only dif credentials
creds = [x for x in creds if "issuanceDate" in x]
Expand Down
63 changes: 34 additions & 29 deletions demo/runners/faber.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,54 +350,59 @@ def generate_proof_request_web_request(
"domain": "4jt78h47fh47",
},
"presentation_definition": {
"id": "32f54163-7166-48f1-93d8-ff217bdb0654",
"submission_requirements": [
{
"name": "Degree Verification",
"rule": "pick",
"min": 1,
"from": "A",
}
],
"id": "5591656f-5b5d-40f8-ab5c-9041c8e3a6a0",
"name": "Age Verification",
"purpose": "We need to verify your age before entering a bar",
"input_descriptors": [
{
"id": "degree_input_1",
"name": "Degree Certificate",
"group": ["A"],
"id": "age-verification",
"name": "A specific type of VC + Issuer",
"purpose": "We want a VC of this type generated by this issuer",
"schema": [
{
"uri": "https://www.w3.org/2018/credentials#VerifiableCredential"
},
{
"uri": "https://w3id.org/citizenship#PermanentResidentCard"
},
"uri": "https://www.w3.org/2018/credentials/v1"
}
],
"constraints": {
"statuses": {
"active": {"directive": "required"}
},
"limit_disclosure": "required",
"fields": [
{
"path": [
"$.credentialSubject.degree.name"
],
"purpose": "We need to verify that you have the required degree.",
"filter": {"type": "string"},
"path": ["$.issuer"],
"filter": {
"type": "string",
"const": "did:key:z6MkwXG2WjeQnNxSoynSGYU8V9j3QzP3JSqhdmkHc6SaVWoT",
},
},
{"path": ["$.credentialSubject.name"]},
{
"path": [
"$.credentialSubject.birthDate"
],
"purpose": "To ensure you meet the age requirement.",
"$.credentialSubject.height"
]
},
{
"path": ["$.credentialSubject.age"],
"predicate": "preferred",
"filter": {
"type": "string",
"pattern": birth_date.strftime(
birth_date_format
),
"type": "number",
"minimum": 18,
},
},
],
},
}
],
"format": {
"di_vc": {
"proof_type": ["DataIntegrityProof"],
"cryptosuite": [
"anoncreds-2023",
"eddsa-rdfc-2022",
],
}
},
},
},
},
Expand Down

0 comments on commit e344a1d

Please sign in to comment.