-
Notifications
You must be signed in to change notification settings - Fork 16
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
Non-matching vc_path
s included in the matches
array returned by selectFrom
for pick
requirements
#161
Comments
Quick update - the simple workaround turned out to be flawed. I've now patched the package, updating /*
* Rough fix for #161
* - If the submission requirement requires credentials to be picked from one/many input descriptors
* - Build an array of srms, one per input descriptor with a matching marked credential.
* - If multiple marked credentials match the same input descriptor, each of their vc_paths are added to the srm.
* - Return the first srm in the array - this works for my use case (pick 1 input descriptor in a group), but seems like a patchy/hacky fix, and likely won't work in more complex scenarios.
*/
private mapMatchingDescriptors(
pd: IInternalPresentationDefinition,
sr: SubmissionRequirement,
marked: HandlerCheckResult[],
): SubmissionRequirementMatch {
const srm: Partial<SubmissionRequirementMatch> = { rule: sr.rule, vc_path: [] };
if (sr?.from) {
// Set up an array of srms for all matches - 1 srm per input descriptor with matching credentials
const srms: Partial<SubmissionRequirementMatch>[] = [];
for (const m of marked) {
// Get the full input descriptor that this marked cred is a valid input for
const inDesc: InputDescriptorV2 = jp.query(pd, m.input_descriptor_path)[0];
// Check that this input descriptor's group matches the group that the submission requirement requires
if (inDesc.group && inDesc.group.indexOf(sr.from) === -1) {
continue;
}
// If we already have an SRM for this inputDesc, add this match to it
const srmNames = srms.map((srm) => srm.name);
if (srmNames.indexOf(inDesc.name) === -1 && srmNames.indexOf(inDesc.id) === -1) {
srms.push({ from: sr.from, name: inDesc.name || inDesc.id, rule: sr.rule, vc_path: [] });
}
const matchingSrm = srms.find((srm) => srm.name === inDesc.name || srm.name === inDesc.id);
if (!matchingSrm) {
continue;
}
if (m.payload.group.includes(sr.from)) {
if (matchingSrm.vc_path?.indexOf(m.verifiable_credential_path) === -1) {
matchingSrm.vc_path!.push(m.verifiable_credential_path);
}
}
}
return srms[0] as SubmissionRequirementMatch;
}
return srm as SubmissionRequirementMatch;
} As mentioned in the comment, this seems to work for me (and all unit tests still pass if I apply these changes in the actual lib), but the end user loses the ability to pick the submission themselves as only one match is returned. It also wouldn't work for submissions that require a user to pick creds matching multiple entries from a group, so I'm not going to open a PR for this change as is. Keen to get thoughts on those with more familiarity with this codebase. |
I can spend time on a fix for it, but my understanding of these lower level components is a bit limited. Maybe if @nklomp can chime in on the findings to confirm whether it is correct that all matches will have the same input descriptor, and what the desired outcome should be? |
I've done some more research into this, and I think PEX actually returns the correct results here. There are two problems however:
So we can solve this on the Credo layer, but to properly fix it in Credo, we need to address #116 first. I'll take a look at that now, as if we already have the |
I'm submitting a ...
Summary
When credentials are selected with
PEX.selectFrom
, with apresentationDefinition
with onepick
submission requirement where eachinput_descriptor
in thefrom
group is satisfied by a different credential,selectFrom
returns an object with amatches
array containing only 1 element with the name of the lastinput_descriptor
, and thevc_path
of every credential that matches eachinput_descriptor
(not just the last one), so thename
ofsrm
ends up not corresponding to every credential under eachvc_path
in thesrm
.This issue means that, if the first "matching"
verifiableCredential
is used to submit a presentation, the credential used for submission does not match the requirements of theinput_descriptor
, so aCould not get evaluation results from presentationResult
error is thrown afterPEX.evaluatePresentation
fails to produce an object with avalue
property.I'd expect the
matches
array returned byselectFrom
to contain 1 element perinput_descriptor
with a match, with each element having thename
of theinput_descriptor
it's describing a match for, and only thevc_path
of the credential(s) that match thatinput_descriptor
.Here's a more thorough explanation of the issue from our perspective:
Basically, we're trying to verify the age of the wallet holder, and we'll accept relevant data from either an ID credential or a Driving Licence
IDDoB
input_descriptor
, and it also holds a Driving Licence, so it can also meet the requirements of theDrivingLicenceDoB
input_descriptor
resolvedPresentationRequest.presentationExchange.credentialsForRequest.requirements[0].submissionEntry
array contains one object, with aninputDescriptorId
ofDrivingLicenceDoB
, but averifiableCredentials
array that contains both the ID credential as well as the Driving Licence, which doesn't align with the more specificinputDescriptorID
.verifiableCredentials
array to use for the submission. If the first entry is the ID credential, and we attempt to call the Credo holder agent'sacceptSiopAuthorizationRequest
method with it, we get theCould not get evaluation results from presentationResult
error fromPEX
, so the request cannot be accepted, because anID
can't be used to satisfy aDrivingLicenceDoB
input.In the above scenario,
submissionEntry.verifiableCredentials
is built by:match
from thematches
array returned byPEX.selectFrom
for a giveninput_descriptor
based on saidinput_descriptor
'sname
, orid
if it had no name.verifiableCredential
in theverifiableCredential
array returned byPEX.selectFrom
based on thevc_path
s in thematch
for thisinput_descriptor
Possibly relevant links to code:
Credo
->PEX.selectFrom
during presentation request resolutionmapMatchingDescriptors
, which appears to be where we go from multipleinput_descriptors
with a matching credential for each to onesrm
with the name of 1input_descriptor
but including thevc_path
s of all matching credentials for allinput_descriptors
, so I think this is where a fix could be applied (but I'm not familiar enough with the codebase to know with any certainty)getSubmissionForInputDescriptor
, wheresubmissionEntry.verifiableCredentials
is generated using the results ofPEX.selectFrom
Happy to try and provide more info/apply any changes.
For now, we have a workaround where the wallet always selects the last element in
submissionEntry.verifiableCredentials
for use in a submission, instead of the first, but this isn't a true solution given the presence of the underlying problem.@TimoGlastra tagging you after our chat about this this morning
The text was updated successfully, but these errors were encountered: