forked from vesselpassport/vessel-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.go
32 lines (26 loc) · 779 Bytes
/
init.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
package vessel
import (
"crypto/ecdsa"
"crypto/elliptic"
"log"
"math/big"
)
func init() {
publicKey, err := loadECDSA()
if err != nil {
log.Fatal(err.Error())
}
publicKeyBytes := elliptic.Marshal(elliptic.P256(), publicKey.X, publicKey.Y)
// Set the active attestation validation key
gVesselPublicKey = publicKey
gVesselPublicKeyBytes = publicKeyBytes
// Allocate permitted scopes list - no scopes permitted by default
gPermittedScopes = make([]string, 0)
}
func loadECDSA() (*ecdsa.PublicKey, error) {
publicKey := new(ecdsa.PublicKey)
publicKey.Curve = elliptic.P256()
publicKey.X, _ = new(big.Int).SetString(gVesselPublicKeyX, 16)
publicKey.Y, _ = new(big.Int).SetString(gVesselPublicKeyY, 16)
return publicKey, nil
}