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

Rule pick with count allows multiple credentials for a single input_descriptor #115

Closed
TimoGlastra opened this issue Jun 6, 2023 · 1 comment
Assignees

Comments

@TimoGlastra
Copy link
Contributor

  • I'm submitting a ...
    [x] bug report

  • Summary

The PEX v1 specification mentions:

The Submission Requirement Object MAY contain a count property. If present, its value MUST be an integer greater than zero. This indicates the number of input Descriptors or Submission Requirement Objects to be submitted.

To me this indicates that if you have e.g. a count of 2, at least 2 of the input descriptors need to be submitted. When i query the PEX library using a presentation definition that has a count: 2 it will allow 2 credentials that match the same input descriptor to satisfy the definition requirements. However, I think it should throw an error in this case, as the presentation definition cannot be satisfied. It needs at least two input descriptors, and in this case it will only satisfy one input descriptor, but have two credential for that one input descriptor.

See the JSON documents below for an example of what I mean.

  • Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)
Credentials
[
   {
      "@context":[
         "https://www.w3.org/2018/credentials/v1",
         "https://www.w3.org/2018/credentials/examples/v2"
      ],
      "id":"http://example.gov/credentials/1231231",
      "type":[
         "VerifiableCredential",
         "UniversityDegreeCredential"
      ],
      "issuer":"did:web:animo.id",
      "issuanceDate":"2020-03-16T22:37:26.544Z",
      "credentialSubject":{
         "id":"did:key:z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd",
         "degree":{
            "type":"BachelorDegree",
            "name":"Bachelor of Fights"
         }
      },
      "proof":{
         "type":"Ed25519Signature2018",
         "created":"2020-04-02T18:28:08Z",
         "verificationMethod":"did:web:animo.id#z6MksHh7qHWvybLg5QTPPdG2DgEjjduBDArV9EF9mRiRzMBN",
         "proofPurpose":"assertionMethod",
         "jws":"eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..YtqjEYnFENT7fNW-COD0HAACxeuQxPKAmp4nIl8jYAu__6IH2FpSxv81w-l5PvE1og50tS9tH8WyXMlXyo45CA"
      }
   },
   {
      "@context":[
         "https://www.w3.org/2018/credentials/v1",
         "https://www.w3.org/2018/credentials/examples/v1"
      ],
      "id":"http://example.gov/credentials/131313123",
      "type":[
         "VerifiableCredential",
         "UniversityDegreeCredential"
      ],
      "issuer":"did:web:animo.id",
      "issuanceDate":"2020-03-16T22:37:26.544Z",
      "credentialSubject":{
         "id":"did:key:z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd",
         "degree":{
            "type":"BachelorDegree",
            "name":"Bachelor of Something"
         }
      },
      "proof":{
         "type":"Ed25519Signature2018",
         "created":"2020-04-02T18:28:08Z",
         "verificationMethod":"did:web:animo.id#z6MksHh7qHWvybLg5QTPPdG2DgEjjduBDArV9EF9mRiRzMBN",
         "proofPurpose":"assertionMethod",
         "jws":"eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..YtqjEYnFENT7fNW-COD0HAACxeuQxPKAmp4nIl8jYAu__6IH2FpSxv81w-l5PvE1og50tS9tH8WyXMlXyo45CA"
      }
   }
]
Presentation Definition
{
   "id":"31e2f0f1-6b70-411d-b239-56aed5321884",
   "purpose":"To check if you have a valid college degree.",
   "input_descriptors":[
      {
         "id":"df2accf9-1ecb-4f4e-af6d-21be152a881b",
         "group":[
            "A"
         ],
         "purpose":"You must have a valid Bachelor Degree issued by Animo.",
         "schema":[
            {
               "uri":"https://www.w3.org/2018/credentials/v1"
            }
         ],
         "constraints":{
            "fields":[
               {
                  "path":[
                     "$.issuer",
                     "$.vc.issuer",
                     "$.iss"
                  ],
                  "filter":{
                     "type":"string",
                     "pattern":"did:web:animo.id"
                  }
               }
            ]
         }
      },
      {
         "id":"867bfe7a-5b91-46b2-9ba4-70028b8d9cc8",
         "purpose":"You must have a valid Bachelor Degree issued by Transmute.",
         "group":[
            "A"
         ],
         "schema":[
            {
               "uri":"https://www.w3.org/2018/credentials/v1"
            }
         ],
         "constraints":{
            "fields":[
               {
                  "path":[
                     "$.issuer",
                     "$.vc.issuer",
                     "$.iss"
                  ],
                  "filter":{
                     "type":"string",
                     "pattern":"did:web:vc.transmute.world"
                  }
               }
            ]
         }
      }
   ],
   "submission_requirements":[
      {
         "name":"Pick Count",
         "rule":"pick",
         "from":"A",
         "count":2
      }
   ]
}
Select Results
{
   "errors":[
      
   ],
   "matches":[
      {
         "rule":"pick",
         "from":[
            "A"
         ],
         "vc_path":[
            "$.verifiableCredential[0]",
            "$.verifiableCredential[1]"
         ],
         "name":"df2accf9-1ecb-4f4e-af6d-21be152a881b",
         "count":2
      }
   ],
   "areRequiredCredentialsPresent":"info",
   "verifiableCredential":[
      {
         "@context":[
            "https://www.w3.org/2018/credentials/v1",
            "https://www.w3.org/2018/credentials/examples/v2"
         ],
         "id":"http://example.gov/credentials/1231231",
         "type":[
            "VerifiableCredential",
            "UniversityDegreeCredential"
         ],
         "issuer":"did:web:animo.id",
         "issuanceDate":"2020-03-16T22:37:26.544Z",
         "credentialSubject":{
            "id":"did:key:z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd",
            "degree":{
               "type":"BachelorDegree",
               "name":"Bachelor of Fights"
            }
         },
         "proof":{
            "type":"Ed25519Signature2018",
            "created":"2020-04-02T18:28:08Z",
            "verificationMethod":"did:web:animo.id#z6MksHh7qHWvybLg5QTPPdG2DgEjjduBDArV9EF9mRiRzMBN",
            "proofPurpose":"assertionMethod",
            "jws":"eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..YtqjEYnFENT7fNW-COD0HAACxeuQxPKAmp4nIl8jYAu__6IH2FpSxv81w-l5PvE1og50tS9tH8WyXMlXyo45CA"
         }
      },
      {
         "@context":[
            "https://www.w3.org/2018/credentials/v1",
            "https://www.w3.org/2018/credentials/examples/v1"
         ],
         "id":"http://example.gov/credentials/131313123",
         "type":[
            "VerifiableCredential",
            "UniversityDegreeCredential"
         ],
         "issuer":"did:web:animo.id",
         "issuanceDate":"2020-03-16T22:37:26.544Z",
         "credentialSubject":{
            "id":"did:key:z6MkjRagNiMu91DduvCvgEsqLZDVzrJzFrwahc4tXLt9DoHd",
            "degree":{
               "type":"BachelorDegree",
               "name":"Bachelor of Something"
            }
         },
         "proof":{
            "type":"Ed25519Signature2018",
            "created":"2020-04-02T18:28:08Z",
            "verificationMethod":"did:web:animo.id#z6MksHh7qHWvybLg5QTPPdG2DgEjjduBDArV9EF9mRiRzMBN",
            "proofPurpose":"assertionMethod",
            "jws":"eyJhbGciOiJFZERTQSIsImI2NCI6ZmFsc2UsImNyaXQiOlsiYjY0Il19..YtqjEYnFENT7fNW-COD0HAACxeuQxPKAmp4nIl8jYAu__6IH2FpSxv81w-l5PvE1og50tS9tH8WyXMlXyo45CA"
         }
      }
   ],
   "warnings":[
      
   ]
}
@nklomp
Copy link
Contributor

nklomp commented Jul 10, 2023

Should be fixed in release 2.1.0

@nklomp nklomp closed this as completed Jul 10, 2023
@nklomp nklomp removed the in progress Work is being done label Jul 10, 2023
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

No branches or pull requests

3 participants