key

package
v1.3.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateStaticNetworkKey

func GenerateStaticNetworkKey() (*NetworkPrivate, *NetworkPublic, error)

GenerateStaticNetworkKey generates a new, random static key based on secp256k1 ethereum curve.

func Marshal

func Marshal(publicKey *NetworkPublic) []byte

Marshal takes a network public key, converts it into an ecdsa public key, and uses go's standard library elliptic marshal method to convert the public key into a slice of bytes in the correct format for the key type. This allows external consumers of this key to verify integrity of the key without having to understand the internals of the net pkg.

func NetworkKeyToECDSAKey

func NetworkKeyToECDSAKey(publicKey *NetworkPublic) *ecdsa.PublicKey

NetworkKeyToECDSAKey takes the public NetworkKey and turns it into ecdsa.PublicKey from Go standard library.

func NetworkPubKeyToEthAddress

func NetworkPubKeyToEthAddress(publicKey *NetworkPublic) string

NetworkPubKeyToEthAddress transforms the network public key into an Ethereum account address, in a string format.

func OperatorKeyToNetworkKey

func OperatorKeyToNetworkKey(
	operatorPrivateKey *operator.PrivateKey,
	operatorPublicKey *operator.PublicKey,
) (*NetworkPrivate, *NetworkPublic)

OperatorKeyToNetworkKey transforms a static ECDSA key into the format supported by the network layer. Because all curve parameters of the secp256k1 curve defined by `go-ethereum` and all curve parameters of secp256k1 curve defined by `btcsuite` used by `lipb2b` under the hood are identical, we can simply rewrite the private key.

`libp2p` does not recognize `go-ethereum` curves and when it comes to creating peer's ID or deserializing the key, operation fails with unrecognized curve error. This is no longer a problem if we transform the key using this function.

Types

type NetworkPrivate

type NetworkPrivate = libp2pcrypto.Secp256k1PrivateKey

NetworkPrivate represents peer's static key associated with an on-chain stake. It is used to authenticate the peer and for message attributability - each message leaving the peer is signed with its private network key.

type NetworkPublic

type NetworkPublic = libp2pcrypto.Secp256k1PublicKey

NetworkPublic represents peer's static key associated with an on-chain stake. It is used to authenticate the peer and for message attributability - each received message is validated against sender's public network key.

func Libp2pKeyToNetworkKey

func Libp2pKeyToNetworkKey(publicKey libp2pcrypto.PubKey) *NetworkPublic

Libp2pKeyToNetworkKey takes an interface type, libp2pcrypto.PubKey, and returns the concrete type specific to this package. If it fails to do so, it returns nil.

Jump to

Keyboard shortcuts

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