ethsecp256k1

package
v0.0.0-...-f498596 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2023 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// PrivKeySize defines the size of the PrivKey bytes
	PrivKeySize = 32
	// KeyType is the string constant for the EthSecp256k1 algorithm
	KeyType = "eth_secp256k1"
)
View Source
const (
	// PrivKeyName defines the amino encoding name for the EthSecp256k1 private key
	PrivKeyName = "ethermint/PrivKeyEthSecp256k1"
	// PubKeyName defines the amino encoding name for the EthSecp256k1 public key
	PubKeyName = "ethermint/PubKeyEthSecp256k1"
)

Amino encoding names

Variables

View Source
var CryptoCodec = codec.New()

CryptoCodec is the default amino codec used by ethermint

Functions

func GenerateAddress

func GenerateAddress() common.Address

GenerateAddress generates an Ethereum address.

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

RegisterCodec registers all the necessary types with amino for the given codec.

Types

type PrivKey

type PrivKey []byte

PrivKey defines a type alias for an ecdsa.PrivateKey that implements Tendermint's PrivateKey interface.

func GenerateKey

func GenerateKey() (PrivKey, error)

GenerateKey generates a new random private key. It returns an error upon failure.

func (PrivKey) Bytes

func (privkey PrivKey) Bytes() []byte

Bytes returns the raw ECDSA private key bytes.

func (PrivKey) Equals

func (privkey PrivKey) Equals(other tmcrypto.PrivKey) bool

Equals returns true if two ECDSA private keys are equal and false otherwise.

func (PrivKey) PubKey

func (privkey PrivKey) PubKey() tmcrypto.PubKey

PubKey returns the ECDSA private key's public key.

func (PrivKey) Sign

func (privkey PrivKey) Sign(msg []byte) ([]byte, error)

Sign creates a recoverable ECDSA signature on the secp256k1 curve over the Keccak256 hash of the provided message. The produced signature is 65 bytes where the last byte contains the recovery ID.

func (PrivKey) ToECDSA

func (privkey PrivKey) ToECDSA() *ecdsa.PrivateKey

ToECDSA returns the ECDSA private key as a reference to ecdsa.PrivateKey type. The function will panic if the private key is invalid.

type PubKey

type PubKey []byte

PubKey defines a type alias for an ecdsa.PublicKey that implements Tendermint's PubKey interface. It represents the 33-byte compressed public key format.

func (PubKey) Address

func (key PubKey) Address() tmcrypto.Address

Address returns the address of the ECDSA public key. The function will panic if the public key is invalid.

func (PubKey) Bytes

func (key PubKey) Bytes() []byte

Bytes returns the raw bytes of the ECDSA public key. The function panics if the key cannot be marshaled to bytes.

func (PubKey) Equals

func (key PubKey) Equals(other tmcrypto.PubKey) bool

Equals returns true if two ECDSA public keys are equal and false otherwise.

func (PubKey) VerifyBytes

func (key PubKey) VerifyBytes(msg []byte, sig []byte) bool

VerifyBytes verifies that the ECDSA public key created a given signature over the provided message. It will calculate the Keccak256 hash of the message prior to verification.

Jump to

Keyboard shortcuts

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