crypto

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2020 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrivKeyAminoName = "ethermint/PrivKeySecp256k1"
	PubKeyAminoName  = "ethermint/PubKeySecp256k1"
)

Amino encoding names

View Source
const (
	// EthSecp256k1 defines the ECDSA secp256k1 used on Ethereum
	EthSecp256k1 = keys.SigningAlgo("eth_secp256k1")
)

Variables

View Source
var CryptoCodec = codec.New()

CryptoCodec is the default amino codec used by ethermint

View Source
var SupportedAlgorithms = []keys.SigningAlgo{EthSecp256k1, keys.Secp256k1}

SupportedAlgorithms defines the list of signing algorithms used on Ethermint:

  • eth_secp256k1 (Ethereum)
  • secp256k1 (Tendermint)

Functions

func DeriveKey added in v0.1.0

func DeriveKey(mnemonic, bip39Passphrase, hdPath string, algo keys.SigningAlgo) ([]byte, error)

func DeriveSecp256k1 added in v0.1.0

func DeriveSecp256k1(mnemonic, bip39Passphrase, _ string) ([]byte, error)

func EthSecp256k1Options added in v0.1.0

func EthSecp256k1Options() []keys.KeybaseOption

EthSecp256k1Options defines a keys options for the ethereum Secp256k1 curve.

func EthermintKeygenFunc

func EthermintKeygenFunc(bz []byte, algo keys.SigningAlgo) (tmcrypto.PrivKey, error)

EthermintKeygenFunc is the key generation function to generate secp256k1 ToECDSA from ethereum.

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

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

Types

type PrivKeySecp256k1

type PrivKeySecp256k1 []byte

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

func GenerateKey

func GenerateKey() (PrivKeySecp256k1, error)

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

func (PrivKeySecp256k1) Bytes

func (privkey PrivKeySecp256k1) Bytes() []byte

Bytes returns the raw ECDSA private key bytes.

func (PrivKeySecp256k1) Equals

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

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

func (PrivKeySecp256k1) PubKey

func (privkey PrivKeySecp256k1) PubKey() tmcrypto.PubKey

PubKey returns the ECDSA private key's public key.

func (PrivKeySecp256k1) Sign

func (privkey PrivKeySecp256k1) 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 (PrivKeySecp256k1) ToECDSA

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

ToECDSA returns the ECDSA private key as a reference to ecdsa.PrivateKey type.

type PubKeySecp256k1

type PubKeySecp256k1 []byte

PubKeySecp256k1 defines a type alias for an ecdsa.PublicKey that implements Tendermint's PubKey interface.

func (PubKeySecp256k1) Address

func (key PubKeySecp256k1) Address() tmcrypto.Address

Address returns the address of the ECDSA public key.

func (PubKeySecp256k1) Bytes

func (key PubKeySecp256k1) Bytes() []byte

Bytes returns the raw bytes of the ECDSA public key.

func (PubKeySecp256k1) Equals

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

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

func (PubKeySecp256k1) VerifyBytes

func (key PubKeySecp256k1) 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