Commit 0e3802dc authored by Sietse Ringers's avatar Sietse Ringers
Browse files

refactor: reuse AttributeRequest.Satify() in irmaclient candidate attribute search algorithm

parent 585938ed
...@@ -477,17 +477,20 @@ outer: ...@@ -477,17 +477,20 @@ outer:
var candidateSet []*irma.AttributeIdentifier var candidateSet []*irma.AttributeIdentifier
for _, cred := range s { for _, cred := range s {
for _, attr := range con { for _, attr := range con {
if attr.Type.CredentialTypeIdentifier() == cred.Type { if attr.Type.CredentialTypeIdentifier() != cred.Type {
id := &irma.AttributeIdentifier{Type: attr.Type, CredentialHash: cred.Hash} continue
if attr.Value != nil { }
attrs, _ := client.attributesByHash(cred.Hash) attrs, _ := client.attributesByHash(cred.Hash)
val := attrs.UntranslatedAttribute(id.Type) val := attrs.UntranslatedAttribute(attr.Type)
if val == nil || *attr.Value != *val { if !attr.Satisfy(attr.Type, val) {
continue outer // if the attribute in this credential instance has the wrong value, then we have
} // to discard the entire candidate set
} continue outer
candidateSet = append(candidateSet, id)
} }
candidateSet = append(candidateSet, &irma.AttributeIdentifier{
Type: attr.Type,
CredentialHash: cred.Hash,
})
} }
} }
result = append(result, candidateSet) result = append(result, candidateSet)
......
...@@ -50,8 +50,8 @@ type AttributeConDisCon []AttributeDisCon ...@@ -50,8 +50,8 @@ type AttributeConDisCon []AttributeDisCon
type DisclosureRequest struct { type DisclosureRequest struct {
BaseRequest BaseRequest
Disclose AttributeConDisCon `json:"disclose"` Disclose AttributeConDisCon `json:"disclose,omitempty"`
Labels map[int]TranslatedString `json:"labels"` Labels map[int]TranslatedString `json:"labels,omitempty"`
} }
// A SignatureRequest is a a request to sign a message with certain attributes. Construct new // A SignatureRequest is a a request to sign a message with certain attributes. Construct new
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment