k1util

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: GPL-3.0 Imports: 11 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 CosmosPubkeyToEVMAddress

func CosmosPubkeyToEVMAddress(pubkeyCmp []byte) (addr common.Address, err error)

CosmosPubkeyToEVMAddress converts a 33-byte Cosmos pubkey to a 20-byte EVM address. It decompresses the pubkey, applies keccak256, then take the last 20 bytes to get the corresponding EVM address.

func PBPubKeyFromBytes

func PBPubKeyFromBytes(pubkey []byte) (cryptopb.PublicKey, error)

func PubKeyBytesToCosmos

func PubKeyBytesToCosmos(pubkey []byte) (cosmoscrypto.PubKey, error)

func PubKeyFromBytes64

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

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

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

func StdPrivKeyToComet

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

func StdPubKeyToCosmos

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