-
Notifications
You must be signed in to change notification settings - Fork 4
/
holder.go
70 lines (55 loc) · 1.85 KB
/
holder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package mobilecore
import (
"encoding/json"
hcertholder "github.com/minvws/nl-covid19-coronacheck-hcert/holder"
hcertverifier "github.com/minvws/nl-covid19-coronacheck-hcert/verifier"
idemixholder "github.com/minvws/nl-covid19-coronacheck-idemix/holder"
"github.com/privacybydesign/gabi"
"os"
"path"
)
const (
HOLDER_CONFIG_FILENAME = "config.json"
HOLDER_PUBLIC_KEYS_FILENAME = "public_keys.json"
CREATE_CREDENTIAL_VERSION = 3
DCC_DOMESTIC_ISSUER_COUNTRY_CODE = "NL"
DCC_DOMESTIC_ISSUER_KEY_SAN = "NLD"
)
const (
DISCLOSURE_POLICY_1G = "1"
DISCLOSURE_POLICY_3G = "3"
)
var (
holderConfig *holderConfiguration
domesticHolder *idemixholder.Holder
europeanHolder *hcertholder.Holder
// euopeanPksLookup is only used to determine key SAN for CAS-islands
europeanPksLookup hcertverifier.PksLookup
lastCredBuilders []gabi.ProofBuilder
)
type holderConfiguration struct {
// Until business rules are part of the config, we don't need anything from here
}
func InitializeHolder(configDirectoryPath string) *Result {
configPath := path.Join(configDirectoryPath, HOLDER_CONFIG_FILENAME)
pksPath := path.Join(configDirectoryPath, HOLDER_PUBLIC_KEYS_FILENAME)
// Load config
configJson, err := os.ReadFile(configPath)
if err != nil {
return WrappedErrorResult(err, "Could not read holder config file")
}
err = json.Unmarshal(configJson, &holderConfig)
if err != nil {
return WrappedErrorResult(err, "Could not JSON unmarshal holder config")
}
// Read public keys
publicKeysConfig, err := NewPublicKeysConfig(pksPath)
if err != nil {
return WrappedErrorResult(err, "Could not load public keys config")
}
// Initialize holders
domesticHolder = idemixholder.New(publicKeysConfig.FindAndCacheDomestic, CREATE_CREDENTIAL_VERSION)
europeanHolder = hcertholder.New()
europeanPksLookup = publicKeysConfig.EuropeanPks
return &Result{nil, ""}
}