Skip to content

"bad @context cardinality" test #96

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

Closed
kdimak opened this issue Oct 3, 2019 · 7 comments · Fixed by #106
Closed

"bad @context cardinality" test #96

kdimak opened this issue Oct 3, 2019 · 7 comments · Fixed by #106

Comments

@kdimak
Copy link

kdimak commented Oct 3, 2019

Could you please explain the meaning of @context bad cardinality check from basic group? I just cannot understand what's wrong with this definition of VC (from example-1-bad-cardinality.jsonld):

{
  "@context": [
    "https://www.w3.org/2018/credentials/v1"
  ],
  "id": "http://example.edu/credentials/58473",
  "type": ["VerifiableCredential", "AlumniCredential"],
  "issuer": "https://example.edu/issuers/14",
  "issuanceDate": "2010-01-01T19:23:24Z",
  "credentialSubject": {
    "id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
    "alumniOf": "Example University"
  },
  "proof": {
    "type": "RsaSignature2018"
  }
}
@TallTed
Copy link
Member

TallTed commented Oct 3, 2019

I believe that @context should not be an array since it has a single member. In other words, this --

  "@context": [
    "https://www.w3.org/2018/credentials/v1"
  ],

-- should be --

  "@context": "https://www.w3.org/2018/credentials/v1",

@dlongley
Copy link
Contributor

dlongley commented Oct 3, 2019

That example should include a second context that defines the terms used in the VC (such as AlumniCredential) that are not present in the base context.

@llorllale
Copy link

@dlongley how can an implementation reasonably deduce the correct context in this scenario?

@dlongley
Copy link
Contributor

dlongley commented Oct 3, 2019

@llorllale,

How can an implementation reasonably deduce the correct context in this scenario?

Real world implementations will do more than just check the data model (they will verify proofs, etc.). They may, for example, either use JSON-LD to detect that that certain terms are undefined or have an API that allows callers to specify known/expected contexts and types. So, such an implementation would not be guessing, but would rather be relying on JSON-LD processing or parameters that are explicitly passed via the API.

As for checking against the data model only, we could probably make this test more lenient. I think as long as the first context is appropriate, the test could pass. I think a long term goal of the test suite is to cover both data model tests and, optionally, more -- but this will be up to the CCG to take on. This could result in making this test more lenient in the "data model section" of the test suite but adding more restrictive tests in an optional section elsewhere.

@llorllale
Copy link

llorllale commented Oct 3, 2019

@dlongley can you please clarify on this:

I think as long as the first context is appropriate, the test could pass.

Do you mean the test should just ensure that when @context is an array:

a. the order of @context is preserved
b. the first element of @context is "https://www.w3.org/2018/credentials/v1"
c. type should also be an array, and
d. the first element of type should be "VerifiableCredential"

?

@dlongley
Copy link
Contributor

dlongley commented Oct 3, 2019

For a VerifiableCredential:

  1. If @context is an array, the first element must be https://www.w3.org/2018/credentials/v1 and order is preserved. If @context is a string, it must be https://www.w3.org/2018/credentials/v1.
  2. If type is an array, VerifiableCredential must be present and should be the first element, but the array is considered an unordered set. If type is a string, it must be VerifiableCredential.

clehner added a commit to spruceid/vc-test-suite that referenced this issue Aug 19, 2020
The context cardinality test specifies 'one or more URIs' but rejects
the case of one URI. Change it to allow the one-URI case.

Fixes w3c#96
@peacekeeper
Copy link
Contributor

I think this can be closed?

msporny pushed a commit that referenced this issue Mar 31, 2021
The context cardinality test specifies 'one or more URIs' but rejects
the case of one URI. Change it to allow the one-URI case.

Fixes #96
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 a pull request may close this issue.

5 participants