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

fix: handle range proofs in presentation #3347

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hallazzang
Copy link

Problem

If I specify multiple predicates on the same attribute when çreating a presentation request, like this:

requested_predicates: {
  age_gte: {
    name: "age",
    p_type: ">=",
    p_value: 20
  },
  age_lt: {
    name: "age",
    p_type: "<",
    p_value: 30
  }
}

The agent crashes due to this:

if not (
Predicate.get(proof_pred_spec["p_type"]) is req_pred
and proof_pred_spec["value"] == req_value
):
raise V20PresFormatHandlerError(
f"Presentation predicate on {req_name} "
"mismatches proposal request"
)

It happens when reft is age_lt(the second one) and ge_proof["predicate"] is { "attr_name": "age", "p_type": "GE", "value": 20 }(the first one).
It should just skip the first ge_proof but the current implementation raises an exception instead.

Solution

By checking both "attr_name" and "p_type" of proof_pred_spec, it is now possible to specify more than one predicate on a single attribute, enabling doing a range proof on an attribute.

by checking attr_name and p_type, it is now possible to specify more
than one predicate on a single attribute
this enables range proof for an attribute
@swcurran
Copy link
Contributor

Thanks for the contribution. As per note on Discord, I'm not sure this is needed (can use restrictions instead), but I don't think it is harmful either.

Can you please fix the DCO checks that are failing (above). See DCO - Developer Certificate of Origin - https://github.com/apps/dco. To fix, see: https://github.com/src-d/guide/blob/master/developer-community/fix-DCO.md and the details link beside the failed checks.

Perhaps also add a test for this?

Copy link

sonarcloud bot commented Nov 25, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants