key

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key struct {
	crypto.PrivKey
}

Key wraps a cometBFT private key adding custom a address function.

func Download

func Download(ctx context.Context, network netconf.ID, name string, typ Type, addr string) (Key, error)

Download retrieves a key from the gcp secret manager.

func FromBytes

func FromBytes(typ Type, b []byte) (Key, error)

FromBytes parses the given bytes into th eprovided key type.

func Generate

func Generate(typ Type) Key

Generate generates a cryptographic key of the specified type. It panics since it assumes that the type is valid.

func GenerateInsecureDeterministic

func GenerateInsecureDeterministic(network netconf.ID, typ Type, seed string) Key

GenerateInsecureDeterministic generates an insecure deterministic key of the specified type from the provided seed. NOTE THIS MUST ONLY BE USED FOR TESTING: It panics if network is not ephemeral.

func UploadNew

func UploadNew(ctx context.Context, cfg UploadConfig) (Key, error)

UploadNew generates a new key and uploads it to the gcp secret manager.

func (Key) Addr

func (k Key) Addr() (string, error)

Addr returns the address of the key. K1 keys have ethereum 0x addresses, ED keys have the default SHA256-20 of the raw pubkey bytes.

func (Key) ECDSA

func (k Key) ECDSA() (*ecdsa.PrivateKey, error)

ECDSA returns the ECDSA representation of the k1 key. This returns an error for ed25519 keys.

type Type

type Type string

Type represents the type of cryptographic key.

const (
	Validator    Type = "validator"
	P2PConsensus Type = "p2p_consensus"
	P2PExecution Type = "p2p_execution"
	EOA          Type = "eoa"
)

func (Type) String

func (t Type) String() string

func (Type) Verify

func (t Type) Verify() error

type UploadConfig

type UploadConfig struct {
	Network netconf.ID
	Name    string
	Type    Type
}

UploadConfig is the configuration for uploading a key.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL