operator

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 6 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKeyPair

func GenerateKeyPair(
	curveInstance elliptic.Curve,
) (*PrivateKey, *PublicKey, error)

GenerateKeyPair generates an operator key pair using the provided elliptic curve instance. The provided curve instance's name must resolve to one of the supported curves determined by the operator.Curve enum.

func MarshalCompressed added in v1.21.0

func MarshalCompressed(publicKey *PublicKey) []byte

MarshalCompressed marshals the given public key to the 33-byte compressed form. This implementation is based on the elliptic.MarshalCompressed function.

func MarshalUncompressed added in v1.21.0

func MarshalUncompressed(publicKey *PublicKey) []byte

MarshalUncompressed marshals the given public key to the 65-byte uncompressed form. This implementation is based on the elliptic.Marshal function.

Types

type Curve added in v1.21.0

type Curve int

Curve represents an elliptic curve name that denotes the curve used by the operator keys.

const (
	Secp256k1 Curve = iota
)

Enum that lists all the elliptic curves that can be used with the operator keys.

func ParseCurve added in v1.21.0

func ParseCurve(value string) (Curve, error)

ParseCurve takes a curve name as string and parses it to a specific operator.Curve enum instance.

func (Curve) String added in v1.21.0

func (c Curve) String() string

String returns the string representation of a given operator.Curve enum instance.

type PrivateKey

type PrivateKey struct {
	PublicKey
	D *big.Int
}

PrivateKey represents an operator private key corresponding to an operator public key.

type PublicKey

type PublicKey struct {
	Curve Curve
	X, Y  *big.Int
}

PublicKey represents a public key that identifies the node operator. Actually this is an ECDSA public key that is not tied to any particular elliptic curve implementation and holds just the curve name instead. That trait makes the operator key flexible enough to be accepted by chain and network packages that can convert it to the chain and network key respectively. Chain and network keys should use their own implementations of the curve held by the operator key.

func (*PublicKey) String added in v1.21.0

func (pk *PublicKey) String() string

String returns the hexadecimal representation of the public key in the compressed form prefixed with 02 or 03 byte.

Jump to

Keyboard shortcuts

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