Commit bfd4746a authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Renaming, 5: irmago package -> irma

parent 37c9f00d
package irmago
package irma
import (
"crypto/sha256"
......
package irmago
package irma
import (
"encoding/base64"
......
package irmago
package irma
import (
"fmt"
......
package irmago
package irma
import (
"encoding/xml"
......
......@@ -3,4 +3,4 @@
// and be the client (like the IRMA Android app,
// https://github.com/credentials/irma_android_cardemu) in the IRMA protocol (see
// https://credentials.github.io/protocols/irma-protocol).
package irmago
package irma
package irmago
package irma
import "strings"
......
......@@ -37,9 +37,9 @@ import (
type Client struct {
// Stuff we manage on disk
secretkey *secretKey
attributes map[irmago.CredentialTypeIdentifier][]*irmago.AttributeList
credentials map[irmago.CredentialTypeIdentifier]map[int]*credential
keyshareServers map[irmago.SchemeManagerIdentifier]*keyshareServer
attributes map[irma.CredentialTypeIdentifier][]*irma.AttributeList
credentials map[irma.CredentialTypeIdentifier]map[int]*credential
keyshareServers map[irma.SchemeManagerIdentifier]*keyshareServer
paillierKeyCache *paillierPrivateKey
logs []*LogEntry
updates []update
......@@ -48,8 +48,8 @@ type Client struct {
storage storage
// Other state
ConfigurationStore *irmago.ConfigurationStore
UnenrolledSchemeManagers []irmago.SchemeManagerIdentifier
ConfigurationStore *irma.ConfigurationStore
UnenrolledSchemeManagers []irma.SchemeManagerIdentifier
irmaConfigurationPath string
androidStoragePath string
handler ClientHandler
......@@ -59,14 +59,14 @@ type Client struct {
// KeyshareHandler is used for asking the user for his email address and PIN,
// for enrolling at a keyshare server.
type KeyshareHandler interface {
EnrollmentError(manager irmago.SchemeManagerIdentifier, err error)
EnrollmentSuccess(manager irmago.SchemeManagerIdentifier)
EnrollmentError(manager irma.SchemeManagerIdentifier, err error)
EnrollmentSuccess(manager irma.SchemeManagerIdentifier)
}
type ClientHandler interface {
KeyshareHandler
UpdateConfigurationStore(new *irmago.IrmaIdentifierSet)
UpdateConfigurationStore(new *irma.IrmaIdentifierSet)
UpdateAttributes()
}
......@@ -101,15 +101,15 @@ func New(
}
cm := &Client{
credentials: make(map[irmago.CredentialTypeIdentifier]map[int]*credential),
keyshareServers: make(map[irmago.SchemeManagerIdentifier]*keyshareServer),
attributes: make(map[irmago.CredentialTypeIdentifier][]*irmago.AttributeList),
credentials: make(map[irma.CredentialTypeIdentifier]map[int]*credential),
keyshareServers: make(map[irma.SchemeManagerIdentifier]*keyshareServer),
attributes: make(map[irma.CredentialTypeIdentifier][]*irma.AttributeList),
irmaConfigurationPath: irmaConfigurationPath,
androidStoragePath: androidStoragePath,
handler: handler,
}
cm.ConfigurationStore, err = irmago.NewConfigurationStore(storagePath+"/irma_configuration", irmaConfigurationPath)
cm.ConfigurationStore, err = irma.NewConfigurationStore(storagePath+"/irma_configuration", irmaConfigurationPath)
if err != nil {
return nil, err
}
......@@ -154,8 +154,8 @@ func New(
}
// CredentialInfoList returns a list of information of all contained credentials.
func (client *Client) CredentialInfoList() irmago.CredentialInfoList {
list := irmago.CredentialInfoList([]*irmago.CredentialInfo{})
func (client *Client) CredentialInfoList() irma.CredentialInfoList {
list := irma.CredentialInfoList([]*irma.CredentialInfo{})
for _, attrlistlist := range client.attributes {
for index, attrlist := range attrlistlist {
......@@ -215,7 +215,7 @@ func generateSecretKey() (*secretKey, error) {
// Removal methods
func (client *Client) remove(id irmago.CredentialTypeIdentifier, index int, storenow bool) error {
func (client *Client) remove(id irma.CredentialTypeIdentifier, index int, storenow bool) error {
// Remove attributes
list, exists := client.attributes[id]
if !exists || index >= len(list) {
......@@ -242,20 +242,20 @@ func (client *Client) remove(id irmago.CredentialTypeIdentifier, index int, stor
return err
}
removed := map[irmago.CredentialTypeIdentifier][]irmago.TranslatedString{}
removed := map[irma.CredentialTypeIdentifier][]irma.TranslatedString{}
removed[id] = attrs.Strings()
if storenow {
return client.addLogEntry(&LogEntry{
Type: actionRemoval,
Time: irmago.Timestamp(time.Now()),
Time: irma.Timestamp(time.Now()),
Removed: removed,
})
}
return nil
}
func (client *Client) RemoveCredential(id irmago.CredentialTypeIdentifier, index int) error {
func (client *Client) RemoveCredential(id irma.CredentialTypeIdentifier, index int) error {
return client.remove(id, index, true)
}
......@@ -268,7 +268,7 @@ func (client *Client) RemoveCredentialByHash(hash string) error {
}
func (client *Client) RemoveAllCredentials() error {
removed := map[irmago.CredentialTypeIdentifier][]irmago.TranslatedString{}
removed := map[irma.CredentialTypeIdentifier][]irma.TranslatedString{}
for _, attrlistlist := range client.attributes {
for _, attrs := range attrlistlist {
if attrs.CredentialType() != nil {
......@@ -277,14 +277,14 @@ func (client *Client) RemoveAllCredentials() error {
client.storage.DeleteSignature(attrs)
}
}
client.attributes = map[irmago.CredentialTypeIdentifier][]*irmago.AttributeList{}
client.attributes = map[irma.CredentialTypeIdentifier][]*irma.AttributeList{}
if err := client.storage.StoreAttributes(client.attributes); err != nil {
return err
}
logentry := &LogEntry{
Type: actionRemoval,
Time: irmago.Timestamp(time.Now()),
Time: irma.Timestamp(time.Now()),
Removed: removed,
}
if err := client.addLogEntry(logentry); err != nil {
......@@ -296,17 +296,17 @@ func (client *Client) RemoveAllCredentials() error {
// Attribute and credential getter methods
// attrs returns cm.attributes[id], initializing it to an empty slice if neccesary
func (client *Client) attrs(id irmago.CredentialTypeIdentifier) []*irmago.AttributeList {
func (client *Client) attrs(id irma.CredentialTypeIdentifier) []*irma.AttributeList {
list, exists := client.attributes[id]
if !exists {
list = make([]*irmago.AttributeList, 0, 1)
list = make([]*irma.AttributeList, 0, 1)
client.attributes[id] = list
}
return list
}
// creds returns cm.credentials[id], initializing it to an empty map if neccesary
func (client *Client) creds(id irmago.CredentialTypeIdentifier) map[int]*credential {
func (client *Client) creds(id irma.CredentialTypeIdentifier) map[int]*credential {
list, exists := client.credentials[id]
if !exists {
list = make(map[int]*credential)
......@@ -316,7 +316,7 @@ func (client *Client) creds(id irmago.CredentialTypeIdentifier) map[int]*credent
}
// Attributes returns the attribute list of the requested credential, or nil if we do not have it.
func (client *Client) Attributes(id irmago.CredentialTypeIdentifier, counter int) (attributes *irmago.AttributeList) {
func (client *Client) Attributes(id irma.CredentialTypeIdentifier, counter int) (attributes *irma.AttributeList) {
list := client.attrs(id)
if len(list) <= counter {
return
......@@ -336,7 +336,7 @@ func (client *Client) credentialByHash(hash string) (*credential, int, error) {
return nil, 0, nil
}
func (client *Client) credentialByID(id irmago.CredentialIdentifier) (*credential, error) {
func (client *Client) credentialByID(id irma.CredentialIdentifier) (*credential, error) {
if _, exists := client.attributes[id.Type]; !exists {
return nil, nil
}
......@@ -349,7 +349,7 @@ func (client *Client) credentialByID(id irmago.CredentialIdentifier) (*credentia
}
// credential returns the requested credential, or nil if we do not have it.
func (client *Client) credential(id irmago.CredentialTypeIdentifier, counter int) (cred *credential, err error) {
func (client *Client) credential(id irma.CredentialTypeIdentifier, counter int) (cred *credential, err error) {
// If the requested credential is not in credential map, we check if its attributes were
// deserialized during New(). If so, there should be a corresponding signature file,
// so we read that, construct the credential, and add it to the credential map
......@@ -391,8 +391,8 @@ func (client *Client) credential(id irmago.CredentialTypeIdentifier, counter int
// Candidates returns a list of attributes present in this client
// that satisfy the specified attribute disjunction.
func (client *Client) Candidates(disjunction *irmago.AttributeDisjunction) []*irmago.AttributeIdentifier {
candidates := make([]*irmago.AttributeIdentifier, 0, 10)
func (client *Client) Candidates(disjunction *irma.AttributeDisjunction) []*irma.AttributeIdentifier {
candidates := make([]*irma.AttributeIdentifier, 0, 10)
for _, attribute := range disjunction.Attributes {
credID := attribute.CredentialTypeIdentifier()
......@@ -405,7 +405,7 @@ func (client *Client) Candidates(disjunction *irmago.AttributeDisjunction) []*ir
continue
}
for _, attrs := range creds {
id := &irmago.AttributeIdentifier{Type: attribute, Hash: attrs.Hash()}
id := &irma.AttributeIdentifier{Type: attribute, Hash: attrs.Hash()}
if attribute.IsCredential() {
candidates = append(candidates, id)
} else {
......@@ -427,12 +427,12 @@ func (client *Client) Candidates(disjunction *irmago.AttributeDisjunction) []*ir
// to satisfy the specifed disjunction list. If not, the unsatisfiable disjunctions
// are returned.
func (client *Client) CheckSatisfiability(
disjunctions irmago.AttributeDisjunctionList,
) ([][]*irmago.AttributeIdentifier, irmago.AttributeDisjunctionList) {
candidates := [][]*irmago.AttributeIdentifier{}
missing := irmago.AttributeDisjunctionList{}
disjunctions irma.AttributeDisjunctionList,
) ([][]*irma.AttributeIdentifier, irma.AttributeDisjunctionList) {
candidates := [][]*irma.AttributeIdentifier{}
missing := irma.AttributeDisjunctionList{}
for i, disjunction := range disjunctions {
candidates = append(candidates, []*irmago.AttributeIdentifier{})
candidates = append(candidates, []*irma.AttributeIdentifier{})
candidates[i] = client.Candidates(disjunction)
if len(candidates[i]) == 0 {
missing = append(missing, disjunction)
......@@ -441,8 +441,8 @@ func (client *Client) CheckSatisfiability(
return candidates, missing
}
func (client *Client) groupCredentials(choice *irmago.DisclosureChoice) (map[irmago.CredentialIdentifier][]int, error) {
grouped := make(map[irmago.CredentialIdentifier][]int)
func (client *Client) groupCredentials(choice *irma.DisclosureChoice) (map[irma.CredentialIdentifier][]int, error) {
grouped := make(map[irma.CredentialIdentifier][]int)
if choice == nil || choice.Attributes == nil {
return grouped, nil
}
......@@ -476,7 +476,7 @@ func (client *Client) groupCredentials(choice *irmago.DisclosureChoice) (map[irm
}
// ProofBuilders constructs a list of proof builders for the specified attribute choice.
func (client *Client) ProofBuilders(choice *irmago.DisclosureChoice) (gabi.ProofBuilderList, error) {
func (client *Client) ProofBuilders(choice *irma.DisclosureChoice) (gabi.ProofBuilderList, error) {
todisclose, err := client.groupCredentials(choice)
if err != nil {
return nil, err
......@@ -494,7 +494,7 @@ func (client *Client) ProofBuilders(choice *irmago.DisclosureChoice) (gabi.Proof
}
// Proofs computes disclosure proofs containing the attributes specified by choice.
func (client *Client) Proofs(choice *irmago.DisclosureChoice, request irmago.IrmaSession, issig bool) (gabi.ProofList, error) {
func (client *Client) Proofs(choice *irma.DisclosureChoice, request irma.IrmaSession, issig bool) (gabi.ProofList, error) {
builders, err := client.ProofBuilders(choice)
if err != nil {
return nil, err
......@@ -504,7 +504,7 @@ func (client *Client) Proofs(choice *irmago.DisclosureChoice, request irmago.Irm
// IssuanceProofBuilders constructs a list of proof builders in the issuance protocol
// for the future credentials as well as possibly any disclosed attributes.
func (client *Client) IssuanceProofBuilders(request *irmago.IssuanceRequest) (gabi.ProofBuilderList, error) {
func (client *Client) IssuanceProofBuilders(request *irma.IssuanceRequest) (gabi.ProofBuilderList, error) {
state, err := newIssuanceState()
if err != nil {
return nil, err
......@@ -534,7 +534,7 @@ func (client *Client) IssuanceProofBuilders(request *irmago.IssuanceRequest) (ga
// IssueCommitments computes issuance commitments, along with disclosure proofs
// specified by choice.
func (client *Client) IssueCommitments(request *irmago.IssuanceRequest) (*gabi.IssueCommitmentMessage, error) {
func (client *Client) IssueCommitments(request *irma.IssuanceRequest) (*gabi.IssueCommitmentMessage, error) {
proofBuilders, err := client.IssuanceProofBuilders(request)
if err != nil {
return nil, err
......@@ -545,7 +545,7 @@ func (client *Client) IssueCommitments(request *irmago.IssuanceRequest) (*gabi.I
// ConstructCredentials constructs and saves new credentials
// using the specified issuance signature messages.
func (client *Client) ConstructCredentials(msg []*gabi.IssueSignatureMessage, request *irmago.IssuanceRequest) error {
func (client *Client) ConstructCredentials(msg []*gabi.IssueSignatureMessage, request *irma.IssuanceRequest) error {
if len(msg) != len(client.state.builders) {
return errors.New("Received unexpected amount of signatures")
}
......@@ -606,8 +606,8 @@ func (client *Client) paillierKeyWorker(wait bool, ch chan bool) {
}
}
func (client *Client) unenrolledSchemeManagers() []irmago.SchemeManagerIdentifier {
list := []irmago.SchemeManagerIdentifier{}
func (client *Client) unenrolledSchemeManagers() []irma.SchemeManagerIdentifier {
list := []irma.SchemeManagerIdentifier{}
for name, manager := range client.ConfigurationStore.SchemeManagers {
if _, contains := client.keyshareServers[name]; manager.Distributed() && !contains {
list = append(list, manager.Identifier())
......@@ -617,10 +617,10 @@ func (client *Client) unenrolledSchemeManagers() []irmago.SchemeManagerIdentifie
}
// KeyshareEnroll attempts to enroll at the keyshare server of the specified scheme manager.
func (client *Client) KeyshareEnroll(manager irmago.SchemeManagerIdentifier, email, pin string) {
func (client *Client) KeyshareEnroll(manager irma.SchemeManagerIdentifier, email, pin string) {
go func() {
defer func() {
handlePanic(func(err *irmago.SessionError) {
handlePanic(func(err *irma.SessionError) {
if client.handler != nil {
client.handler.EnrollmentError(manager, err)
}
......@@ -638,7 +638,7 @@ func (client *Client) KeyshareEnroll(manager irmago.SchemeManagerIdentifier, ema
}
func (client *Client) keyshareEnrollWorker(managerID irmago.SchemeManagerIdentifier, email, pin string) error {
func (client *Client) keyshareEnrollWorker(managerID irma.SchemeManagerIdentifier, email, pin string) error {
manager, ok := client.ConfigurationStore.SchemeManagers[managerID]
if !ok {
return errors.New("Unknown scheme manager")
......@@ -650,7 +650,7 @@ func (client *Client) keyshareEnrollWorker(managerID irmago.SchemeManagerIdentif
return errors.New("PIN too short, must be at least 5 characters")
}
transport := irmago.NewHTTPTransport(manager.KeyshareServer)
transport := irma.NewHTTPTransport(manager.KeyshareServer)
kss, err := newKeyshareServer(client.paillierKey(true), manager.KeyshareServer, email)
if err != nil {
return err
......@@ -672,7 +672,7 @@ func (client *Client) keyshareEnrollWorker(managerID irmago.SchemeManagerIdentif
}
// KeyshareRemove unenrolls the keyshare server of the specified scheme manager.
func (client *Client) KeyshareRemove(manager irmago.SchemeManagerIdentifier) error {
func (client *Client) KeyshareRemove(manager irma.SchemeManagerIdentifier) error {
if _, contains := client.keyshareServers[manager]; !contains {
return errors.New("Can't uninstall unknown keyshare server")
}
......@@ -681,7 +681,7 @@ func (client *Client) KeyshareRemove(manager irmago.SchemeManagerIdentifier) err
}
func (client *Client) KeyshareRemoveAll() error {
client.keyshareServers = map[irmago.SchemeManagerIdentifier]*keyshareServer{}
client.keyshareServers = map[irma.SchemeManagerIdentifier]*keyshareServer{}
client.UnenrolledSchemeManagers = client.unenrolledSchemeManagers()
return client.storage.StoreKeyshareServers(client.keyshareServers)
}
......
......@@ -9,12 +9,12 @@ import (
// is always the secret key and the first attribute the metadata attribute.
type credential struct {
*gabi.Credential
*irmago.MetadataAttribute
attrs *irmago.AttributeList
*irma.MetadataAttribute
attrs *irma.AttributeList
}
func newCredential(gabicred *gabi.Credential, store *irmago.ConfigurationStore) (*credential, error) {
meta := irmago.MetadataFromInt(gabicred.Attributes[1], store)
func newCredential(gabicred *gabi.Credential, store *irma.ConfigurationStore) (*credential, error) {
meta := irma.MetadataFromInt(gabicred.Attributes[1], store)
cred := &credential{
Credential: gabicred,
MetadataAttribute: meta,
......@@ -27,9 +27,9 @@ func newCredential(gabicred *gabi.Credential, store *irmago.ConfigurationStore)
return cred, nil
}
func (cred *credential) AttributeList() *irmago.AttributeList {
func (cred *credential) AttributeList() *irma.AttributeList {
if cred.attrs == nil {
cred.attrs = irmago.NewAttributeListFromInts(cred.Credential.Attributes[1:], cred.MetadataAttribute.Store)
cred.attrs = irma.NewAttributeListFromInts(cred.Credential.Attributes[1:], cred.MetadataAttribute.Store)
}
return cred.attrs
}
......@@ -31,10 +31,10 @@ func TestMain(m *testing.M) {
type IgnoringClientHandler struct{}
func (i *IgnoringClientHandler) UpdateConfigurationStore(new *irmago.IrmaIdentifierSet) {}
func (i *IgnoringClientHandler) UpdateAttributes() {}
func (i *IgnoringClientHandler) EnrollmentError(manager irmago.SchemeManagerIdentifier, err error) {}
func (i *IgnoringClientHandler) EnrollmentSuccess(manager irmago.SchemeManagerIdentifier) {}
func (i *IgnoringClientHandler) UpdateConfigurationStore(new *irma.IrmaIdentifierSet) {}
func (i *IgnoringClientHandler) UpdateAttributes() {}
func (i *IgnoringClientHandler) EnrollmentError(manager irma.SchemeManagerIdentifier, err error) {}
func (i *IgnoringClientHandler) EnrollmentSuccess(manager irma.SchemeManagerIdentifier) {}
func parseStorage(t *testing.T) *Client {
exists, err := fs.PathExists("testdata/storage/test")
......@@ -64,12 +64,12 @@ func s2big(s string) (r *big.Int) {
}
func verifyManagerIsUnmarshaled(t *testing.T, client *Client) {
cred, err := client.credential(irmago.NewCredentialTypeIdentifier("irma-demo.RU.studentCard"), 0)
cred, err := client.credential(irma.NewCredentialTypeIdentifier("irma-demo.RU.studentCard"), 0)
require.NoError(t, err, "could not fetch credential")
require.NotNil(t, cred, "Credential should exist")
require.NotNil(t, cred.Attributes[0], "Metadata attribute of irma-demo.RU.studentCard should not be nil")
cred, err = client.credential(irmago.NewCredentialTypeIdentifier("test.test.mijnirma"), 0)
cred, err = client.credential(irma.NewCredentialTypeIdentifier("test.test.mijnirma"), 0)
require.NoError(t, err, "could not fetch credential")
require.NotNil(t, cred, "Credential should exist")
require.NotNil(t, cred.Signature.KeyshareP)
......@@ -123,7 +123,7 @@ func verifyPaillierKey(t *testing.T, PrivateKey *paillierPrivateKey) {
func verifyKeyshareIsUnmarshaled(t *testing.T, client *Client) {
require.NotNil(t, client.paillierKeyCache)
require.NotNil(t, client.keyshareServers)
test := irmago.NewSchemeManagerIdentifier("test")
test := irma.NewSchemeManagerIdentifier("test")
require.Contains(t, client.keyshareServers, test)
kss := client.keyshareServers[test]
require.NotEmpty(t, kss.Nonce)
......@@ -133,33 +133,33 @@ func verifyKeyshareIsUnmarshaled(t *testing.T, client *Client) {
}
// TODO move up to irmago?
func verifyStoreIsLoaded(t *testing.T, store *irmago.ConfigurationStore, android bool) {
require.Contains(t, store.SchemeManagers, irmago.NewSchemeManagerIdentifier("irma-demo"))
require.Contains(t, store.SchemeManagers, irmago.NewSchemeManagerIdentifier("test"))
func verifyStoreIsLoaded(t *testing.T, store *irma.ConfigurationStore, android bool) {
require.Contains(t, store.SchemeManagers, irma.NewSchemeManagerIdentifier("irma-demo"))
require.Contains(t, store.SchemeManagers, irma.NewSchemeManagerIdentifier("test"))
if android {
require.Contains(t, store.SchemeManagers, irmago.NewSchemeManagerIdentifier("test2"))
require.Contains(t, store.SchemeManagers, irma.NewSchemeManagerIdentifier("test2"))
}
pk, err := store.PublicKey(irmago.NewIssuerIdentifier("irma-demo.RU"), 0)
pk, err := store.PublicKey(irma.NewIssuerIdentifier("irma-demo.RU"), 0)
require.NoError(t, err)
require.NotNil(t, pk)
require.NotNil(t, pk.N, "irma-demo.RU public key has no modulus")
require.Equal(t,
"Irma Demo",
store.SchemeManagers[irmago.NewSchemeManagerIdentifier("irma-demo")].Name["en"],
store.SchemeManagers[irma.NewSchemeManagerIdentifier("irma-demo")].Name["en"],
"irma-demo scheme manager has unexpected name")
require.Equal(t,
"Radboud University Nijmegen",
store.Issuers[irmago.NewIssuerIdentifier("irma-demo.RU")].Name["en"],
store.Issuers[irma.NewIssuerIdentifier("irma-demo.RU")].Name["en"],
"irma-demo.RU issuer has unexpected name")
require.Equal(t,
"Student Card",
store.CredentialTypes[irmago.NewCredentialTypeIdentifier("irma-demo.RU.studentCard")].ShortName["en"],
store.CredentialTypes[irma.NewCredentialTypeIdentifier("irma-demo.RU.studentCard")].ShortName["en"],
"irma-demo.RU.studentCard has unexpected name")
require.Equal(t,
"studentID",
store.CredentialTypes[irmago.NewCredentialTypeIdentifier("irma-demo.RU.studentCard")].Attributes[2].ID,
store.CredentialTypes[irma.NewCredentialTypeIdentifier("irma-demo.RU.studentCard")].Attributes[2].ID,
"irma-demo.RU.studentCard.studentID has unexpected name")
// Hash algorithm pseudocode:
......@@ -186,7 +186,7 @@ func TestUnmarshaling(t *testing.T) {
// Do session so we can examine its log item later
logs, err := client.Logs()
require.NoError(t, err)
jwt := getIssuanceJwt("testip", irmago.NewAttributeTypeIdentifier("irma-demo.RU.studentCard.studentID"))
jwt := getIssuanceJwt("testip", irma.NewAttributeTypeIdentifier("irma-demo.RU.studentCard.studentID"))
sessionHelper(t, jwt, "issue", client)
newclient, err := New("testdata/storage/test", "testdata/irma_configuration", "testdata/oldstorage", nil)
......@@ -203,7 +203,7 @@ func TestUnmarshaling(t *testing.T) {
require.NotNil(t, entry)
sessionjwt, err := entry.Jwt()
require.NoError(t, err)
require.Equal(t, "testip", sessionjwt.(*irmago.IdentityProviderJwt).ServerName)
require.Equal(t, "testip", sessionjwt.(*irma.IdentityProviderJwt).ServerName)
require.NoError(t, err)
require.NotEmpty(t, entry.Disclosed)
require.NotEmpty(t, entry.Received)
......@@ -216,12 +216,12 @@ func TestUnmarshaling(t *testing.T) {
}
func TestMetadataAttribute(t *testing.T) {
metadata := irmago.NewMetadataAttribute()
metadata := irma.NewMetadataAttribute()
if metadata.Version() != 0x02 {
t.Errorf("Unexpected metadata version: %d", metadata.Version())
}
expiry := metadata.SigningDate().Unix() + int64(metadata.ValidityDuration()*irmago.ExpiryFactor)
expiry := metadata.SigningDate().Unix() + int64(metadata.ValidityDuration()*irma.ExpiryFactor)
if !time.Unix(expiry, 0).Equal(metadata.Expiry()) {
t.Errorf("Invalid signing date")
}
......@@ -232,16 +232,16 @@ func TestMetadataAttribute(t *testing.T) {
}
func TestMetadataCompatibility(t *testing.T) {
store, err := irmago.NewConfigurationStore("testdata/irma_configuration", "")
store, err := irma.NewConfigurationStore("testdata/irma_configuration", "")
require.NoError(t, err)
require.NoError(t, store.ParseFolder())
// An actual metadata attribute of an IRMA credential extracted from the IRMA app
attr := irmago.MetadataFromInt(s2big("49043481832371145193140299771658227036446546573739245068"), store)
attr := irma.MetadataFromInt(s2big("49043481832371145193140299771658227036446546573739245068"), store)
require.NotNil(t, attr.CredentialType(), "attr.CredentialType() should not be nil")
require.Equal(t,
irmago.NewCredentialTypeIdentifier("irma-demo.RU.studentCard"),
irma.NewCredentialTypeIdentifier("irma-demo.RU.studentCard"),
attr.CredentialType().Identifier(),
"Metadata credential type was not irma-demo.RU.studentCard",
)
......@@ -256,9 +256,9 @@ func TestMetadataCompatibility(t *testing.T) {
func TestCandidates(t *testing.T) {
client := parseStorage(t)
attrtype := irmago.NewAttributeTypeIdentifier("irma-demo.RU.studentCard.studentID")
disjunction := &irmago.AttributeDisjunction{
Attributes: []irmago.AttributeTypeIdentifier{attrtype},
attrtype := irma.NewAttributeTypeIdentifier("irma-demo.RU.studentCard.studentID")
disjunction := &irma.AttributeDisjunction{
Attributes: []irma.AttributeTypeIdentifier{attrtype},
}
attrs := client.Candidates(disjunction)
require.NotNil(t, attrs)
......@@ -268,17 +268,17 @@ func TestCandidates(t *testing.T) {
require.NotNil(t, attr)
require.Equal(t, attr.Type, attrtype)
disjunction = &irmago.AttributeDisjunction{
Attributes: []irmago.AttributeTypeIdentifier{attrtype},
Values: map[irmago.AttributeTypeIdentifier]string{attrtype: "456"},
disjunction = &irma.AttributeDisjunction{
Attributes: []irma.AttributeTypeIdentifier{attrtype},
Values: map[irma.AttributeTypeIdentifier]string{attrtype: "456"},
}
attrs = client.Candidates(disjunction)
require.NotNil(t, attrs)
require.Len(t, attrs, 1)
disjunction = &irmago.AttributeDisjunction{
Attributes: []irmago.AttributeTypeIdentifier{attrtype},
Values: map[irmago.AttributeTypeIdentifier]string{attrtype: "foobarbaz"},
disjunction = &irma.AttributeDisjunction{
Attributes: []irma.AttributeTypeIdentifier{attrtype},
Values: map[irma.AttributeTypeIdentifier]string{attrtype: "foobarbaz"},
}
attrs = client.Candidates(disjunction)
require.NotNil(t, attrs)
......@@ -288,18 +288,18 @@ func TestCandidates(t *testing.T) {
}
func TestTimestamp(t *testing.T) {
mytime := irmago.Timestamp(time.Unix(1500000000, 0))
timestruct := struct{ Time *irmago.Timestamp }{Time: &mytime}
mytime := irma.Timestamp(time.Unix(1500000000, 0))
timestruct := struct{ Time *irma.Timestamp }{Time: &mytime}
bytes, err := json.Marshal(timestruct)
require.NoError(t, err)
timestruct = struct{ Time *irmago.Timestamp }{}
timestruct = struct{ Time *irma.Timestamp }{}
require.NoError(t, json.Unmarshal(bytes, &timestruct))
require.Equal(t, time.Time(*timestruct.Time).Unix(), int64(1500000000))
}
func TestServiceProvider(t *testing.T) {
var spjwt irmago.ServiceProviderJwt
var spjwt irma.ServiceProviderJwt
var spjson = `{
"sprequest": {
......@@ -325,7 +325,7 @@ func TestServiceProvider(t *testing.T) {
require.NotEmpty(t, spjwt.Request.Request.Content[0].Attributes)
require.Equal(t, spjwt.Request.Request.Content[0].Attributes[0].Name(), "studentID")
require.NotNil(t, spjwt.Request.Request.Content.Find(irmago.NewAttributeTypeIdentifier("irma-demo.RU.studentCard.studentID")))
require.NotNil(t, spjwt.Request.Request.Content.Find(irma.NewAttributeTypeIdentifier("irma-demo.RU.studentCard.studentID")))
}
func TestPaillier(t *testing.T) {
......@@ -360,8 +360,8 @@ func TestPaillier(t *testing.T) {
func TestCredentialRemoval(t *testing.T) {
client := parseStorage(t)
id := irmago.NewCredentialTypeIdentifier("irma-demo.RU.studentCard")
id2 := irmago.NewCredentialTypeIdentifier("test.test.mijnirma")
id := irma.NewCredentialTypeIdentifier("irma-demo.RU.studentCard")
id2 := irma.NewCredentialTypeIdentifier("test.test.mijnirma")
cred, err := client.credential(id, 0)
require.NoError(t, err)
......@@ -386,7 +386,7 @@ func TestCredentialRemoval(t *testing.T) {