github.com/koko1123/flow-go-1@v0.29.6/utils/unittest/keys.go (about) 1 package unittest 2 3 import ( 4 "encoding/hex" 5 6 "github.com/onflow/flow-go/crypto" 7 8 "github.com/koko1123/flow-go-1/model/encodable" 9 ) 10 11 func NetworkingKeys(n int) []crypto.PrivateKey { 12 keys := make([]crypto.PrivateKey, 0, n) 13 14 for i := 0; i < n; i++ { 15 key := NetworkingPrivKeyFixture() 16 keys = append(keys, key) 17 } 18 19 return keys 20 } 21 22 func StakingKeys(n int) []crypto.PrivateKey { 23 keys := make([]crypto.PrivateKey, 0, n) 24 25 for i := 0; i < n; i++ { 26 key := StakingPrivKeyFixture() 27 keys = append(keys, key) 28 } 29 30 return keys 31 } 32 33 func RandomBeaconPriv() *encodable.RandomBeaconPrivKey { 34 privKey := StakingPrivKeyFixture() 35 return &encodable.RandomBeaconPrivKey{ 36 PrivateKey: privKey, 37 } 38 } 39 40 func MustDecodePublicKeyHex(algo crypto.SigningAlgorithm, keyHex string) crypto.PublicKey { 41 keyBytes, err := hex.DecodeString(keyHex) 42 if err != nil { 43 panic(err) 44 } 45 key, err := crypto.DecodePublicKey(algo, keyBytes) 46 if err != nil { 47 panic(err) 48 } 49 return key 50 } 51 52 func MustDecodeSignatureHex(sigHex string) crypto.Signature { 53 sigBytes, err := hex.DecodeString(sigHex) 54 if err != nil { 55 panic(err) 56 } 57 return sigBytes 58 }