diff --git a/descriptions.go b/descriptions.go index 069c1fe17..b8dd6dbcc 100644 --- a/descriptions.go +++ b/descriptions.go @@ -611,19 +611,14 @@ func (ct *CredentialType) RandomBlindAttributeIndices() []int { return indices } -func (ct *CredentialType) attributeTypeIdentifiers(indices []int) (ids []string) { - for i, at := range ct.AttributeTypes { - for _, j := range indices { - if i == j { - ids = append(ids, at.ID) - } +func (ct *CredentialType) RandomBlindAttributeNames() []string { + names := []string{} + for _, at := range ct.AttributeTypes { + if at.RandomBlind { + names = append(names, at.ID) } } - return -} - -func (ct *CredentialType) RandomBlindAttributeNames() []string { - return ct.attributeTypeIdentifiers(ct.RandomBlindAttributeIndices()) + return names } func (ct *CredentialType) RevocationSupported() bool { diff --git a/internal/sessiontest/session_test.go b/internal/sessiontest/session_test.go index d77aef937..4f153d3fc 100644 --- a/internal/sessiontest/session_test.go +++ b/internal/sessiontest/session_test.go @@ -571,6 +571,7 @@ func TestBlindIssuanceSessionDifferentAmountOfRandomBlinds(t *testing.T) { require.Truef(t, client.Configuration.ContainsAttributeType(attrID1), "AttributeType %s not found", attrID1) require.Truef(t, client.Configuration.ContainsAttributeType(attrID2), "AttributeType %s not found", attrID2) require.True(t, client.Configuration.AttributeTypes[attrID2].RandomBlind, "AttributeType votingnumber is not of type random blind") + require.ElementsMatch(t, []string{"votingnumber"}, client.Configuration.CredentialTypes[credID].RandomBlindAttributeNames()) request := irma.NewIssuanceRequest([]*irma.CredentialRequest{ { diff --git a/server/irmaserver/api.go b/server/irmaserver/api.go index 2ed2b004f..b7a9883ac 100644 --- a/server/irmaserver/api.go +++ b/server/irmaserver/api.go @@ -173,7 +173,8 @@ func (s *Server) StartSession(req interface{}, handler server.SessionHandler) (* // This way, the client can check prematurely, i.e., before the session, // if it has the same random blind attributes in it's configuration. for _, cred := range request.(*irma.IssuanceRequest).Credentials { - cred.RandomBlindAttributeTypeIDs = s.conf.IrmaConfiguration.CredentialTypes[cred.CredentialTypeID].RandomBlindAttributeNames() + credType := s.conf.IrmaConfiguration.CredentialTypes[cred.CredentialTypeID] + cred.RandomBlindAttributeTypeIDs = credType.RandomBlindAttributeNames() } if err := s.validateIssuanceRequest(request.(*irma.IssuanceRequest)); err != nil {