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

W3C CredentialSubjectId property not set correctly #308

Closed
auer-martin opened this issue Jan 24, 2024 · 2 comments
Closed

W3C CredentialSubjectId property not set correctly #308

auer-martin opened this issue Jan 24, 2024 · 2 comments

Comments

@auer-martin
Copy link

In the current implementation of the W3C credentials, there is a issue with the credential subject id property.
When converting a credential from JSON to a W3cCredential, the subject id property of the credential is not set correctly.
When the credential is processed, we get the following error: " Invalid state: Credential attribute 'id' value not provided".

    const _credential = W3cCredential.create({
      credentialDefinition,
      credentialDefinitionPrivate,
      credentialOffer,
      credentialRequest,
      attributeRawValues: { id: 'http://example.com', name: 'Alex', height: '175', age: '28', sex: 'male' },
      revocationConfiguration: new CredentialRevocationConfig({
        registryDefinition: revocationRegistryDefinition,
        registryDefinitionPrivate: revocationRegistryDefinitionPrivate,
        statusList: revocationStatusList,
        registryIndex: 9
      })
    })

    const tmp = _credential.toJson()
    const credential = W3cCredential.fromJson(tmp)

    // " Invalid state: Credential attribute 'id' value not provided".
    const credentialReceived = credential.process({
      credentialDefinition,
      credentialRequestMetadata,
      linkSecret,
      revocationRegistryDefinition
    })

@Artemkaaas can you take a look at this?

@auer-martin auer-martin changed the title W3C fromJson CredentialSubjectId property not set. W3C CredentialSubjectId property not set correctly Jan 24, 2024
@Artemkaaas
Copy link
Contributor

I suppose that id property here attributeRawValues: { id: 'http://example.com' ... } is not part of credential definition.
attributeRawValues must match to credential definition. This is why you are getting the error.

Adding such non-anoncreds properties should be handled outside anoncreds library as @TimoGlastra mentioned here: #273 (comment)

@TimoGlastra
Copy link
Member

@Artemkaaas I think there is still logic in place that strips out the id. I think we should remove all special handling for the id property.

If you look at the credential subject, it separates the id from the other attributes, and then only the attributes are used in the actual credenital.:

pub struct CredentialSubject {

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