-
Notifications
You must be signed in to change notification settings - Fork 204
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
AnonCreds: support queries by credential attribute presence and value #1287
Comments
I will pick this! |
Example: // Verifier
const proofRequest = {
request_attributes: {
userDetails: {
names: ['name'],
restrictions: [{
cred_def_id: '123',
// 'attr::name::value': 'Victor',
// 'attr::age::marker': '1'
}]
}
}
}
// send to holder over DIDComm
// Holder has 100000
const credentials = [{
attributes: {
name: 'Timo',
age: 20
},
cred_def_id: '123'
}, {
attributes: {
name: 'Victor',
},
cred_def_id: '456'
}, {
attributes: {
age: '25',
},
cred_def_id: '123'
}]
// Filter based on request
const filteredCredentials = [{
name: 'Timo',
age: 20
}, {
age: '25',
}] |
When a record is stored, and the This code is currnetly here: https://github.com/hyperledger/aries-framework-javascript/blob/main/packages/anoncreds/src/repository/AnonCredsCredentialRecord.ts#LL73C55-L73C55 and just sets the following tag for attributes: Curent format: {
// ... other tags ...
attributes: ['name', 'age']
} Desired format: {
// ... other tags ...
// should exist for every attribute in the credential
'attr::${attributeName}::marker': true,
'attr::${attributeName}::value': attributeValue
} Then when querying credentials for a proof request, we need to query by these tags in the AnonCredsCredentialRecord. This method transforms proof request restrictions into a storage query, which would need to be extended to include the attribute value and marker restrictions: https://github.com/hyperledger/aries-framework-javascript/blob/main/packages/anoncreds-rs/src/services/AnonCredsRsHolderService.ts#L336 In here: https://github.com/hyperledger/aries-framework-javascript/blob/main/packages/anoncreds-rs/src/services/AnonCredsRsHolderService.ts#L369 add checks:
If one is found, we need to add the restriction to the query that algns with the tag structure in the AnonCredsCredentialRecord How to check if this is a attribute value restriction or a attribute marker restriction you can look here: https://github.com/hyperledger/aries-framework-javascript/blob/main/packages/anoncreds/src/models/AnonCredsRestriction.ts#L135-L143 |
AnonCreds spec defines a number of properties that can be set as restrictions in proof requests. Most of them are already supported in
@aries-framework/anoncreds-rs
module but we are missing two:attr::<attribute-name>::marker
attr::<attribute-name>::<attribute-value>
For that purpose,
AnonCredsRsHolderCredentialService
must be updated to properly query the wallet according to them, and apply the corresponding tags when storing the credentials.The text was updated successfully, but these errors were encountered: