k1util

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package k1util provides functions to sign and verify Ethereum RSV style signatures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PubKeyFromBytes64 added in v0.1.2

func PubKeyFromBytes64(pubkey []byte) (*stdecdsa.PublicKey, error)

PubKeyFromBytes64 returns the public key from the 64 byte uncompressed version. It adds the prefix (0x04 for uncompressed keys) to the input bytes.

func PubKeyPBToAddress

func PubKeyPBToAddress(pubkey cryptopb.PublicKey) (common.Address, error)

PubKeyPBToAddress returns the Ethereum address for the given k1 public key.

func PubKeyToAddress

func PubKeyToAddress(pubkey crypto.PubKey) (common.Address, error)

PubKeyToAddress returns the Ethereum address for the given k1 public key.

func PubKeyToBytes64 added in v0.1.2

func PubKeyToBytes64(pubkey *stdecdsa.PublicKey) []byte

PubKeyToBytes64 returns the 64 byte uncompressed version of the public key, by removing the prefix (0x04 for uncompressed keys).

func PubKeyToCosmos

func PubKeyToCosmos(pubkey crypto.PubKey) (cosmoscrypto.PubKey, error)

func Sign

func Sign(key crypto.PrivKey, input [32]byte) ([65]byte, error)

Sign returns a signature from input data.

The produced signature is 65 bytes in the [R || S || V] format where V is 27 or 28.

func StdPrivKeyFromComet added in v0.1.2

func StdPrivKeyFromComet(privkey crypto.PrivKey) (*stdecdsa.PrivateKey, error)

func StdPubKeyToCosmos added in v0.1.2

func StdPubKeyToCosmos(pubkey *stdecdsa.PublicKey) (cosmoscrypto.PubKey, error)

func Verify

func Verify(address common.Address, hash [32]byte, sig [65]byte) (bool, error)

Verify returns whether the 65 byte signature is valid for the provided hash and Ethereum address.

Note the signature MUST be 65 bytes in the Ethereum [R || S || V] format.

Types

This section is empty.

Jump to

Keyboard shortcuts

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