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

Fix randomblind attribute names in credential request #151

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 6 additions & 11 deletions descriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions internal/sessiontest/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
{
Expand Down
3 changes: 2 additions & 1 deletion server/irmaserver/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down