-
Notifications
You must be signed in to change notification settings - Fork 179
/
keys.go
58 lines (46 loc) · 1.08 KB
/
keys.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
package unittest
import (
"encoding/hex"
"github.com/onflow/flow-go/crypto"
"github.com/onflow/flow-go/model/encodable"
)
func NetworkingKeys(n int) []crypto.PrivateKey {
keys := make([]crypto.PrivateKey, 0, n)
for i := 0; i < n; i++ {
key := NetworkingPrivKeyFixture()
keys = append(keys, key)
}
return keys
}
func StakingKeys(n int) []crypto.PrivateKey {
keys := make([]crypto.PrivateKey, 0, n)
for i := 0; i < n; i++ {
key := StakingPrivKeyFixture()
keys = append(keys, key)
}
return keys
}
func RandomBeaconPriv() *encodable.RandomBeaconPrivKey {
privKey := StakingPrivKeyFixture()
return &encodable.RandomBeaconPrivKey{
PrivateKey: privKey,
}
}
func MustDecodePublicKeyHex(algo crypto.SigningAlgorithm, keyHex string) crypto.PublicKey {
keyBytes, err := hex.DecodeString(keyHex)
if err != nil {
panic(err)
}
key, err := crypto.DecodePublicKey(algo, keyBytes)
if err != nil {
panic(err)
}
return key
}
func MustDecodeSignatureHex(sigHex string) crypto.Signature {
sigBytes, err := hex.DecodeString(sigHex)
if err != nil {
panic(err)
}
return sigBytes
}