-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
vrf_key.go
40 lines (34 loc) · 1.04 KB
/
vrf_key.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
package presenters
import (
"github.com/smartcontractkit/chainlink/v2/core/logger"
"github.com/smartcontractkit/chainlink/v2/core/services/keystore/keys/vrfkey"
)
type VRFKeyResource struct {
JAID
Compressed string `json:"compressed"`
Uncompressed string `json:"uncompressed"`
Hash string `json:"hash"`
}
// GetName implements the api2go EntityNamer interface
func (VRFKeyResource) GetName() string {
return "encryptedVRFKeys"
}
func NewVRFKeyResource(key vrfkey.KeyV2, lggr logger.Logger) *VRFKeyResource {
uncompressed, err := key.PublicKey.StringUncompressed()
if err != nil {
lggr.Errorw("Unable to get uncompressed pk", "err", err)
}
return &VRFKeyResource{
JAID: NewJAID(key.PublicKey.String()),
Compressed: key.PublicKey.String(),
Uncompressed: uncompressed,
Hash: key.PublicKey.MustHash().String(),
}
}
func NewVRFKeyResources(keys []vrfkey.KeyV2, lggr logger.Logger) []VRFKeyResource {
rs := []VRFKeyResource{}
for _, key := range keys {
rs = append(rs, *NewVRFKeyResource(key, lggr))
}
return rs
}