Documentation
¶
Index ¶
- Constants
- Variables
- func DeriveKey(mnemonic, bip39Passphrase, hdPath string, algo keys.SigningAlgo) ([]byte, error)
- func DeriveSecp256k1(mnemonic, bip39Passphrase, path string) ([]byte, error)
- func EthSecp256k1Options() []keys.KeybaseOption
- func EthermintKeygenFunc(bz []byte, algo keys.SigningAlgo) (tmcrypto.PrivKey, error)
- func RegisterCodec(cdc *codec.Codec)
- type PrivKeySecp256k1
- type PubKeySecp256k1
Constants ¶
const ( // EthSecp256k1Type string constant for the EthSecp256k1 algorithm EthSecp256k1Type = "eth_secp256k1" // EthSecp256k1 defines the ECDSA secp256k1 used on Ethereum EthSecp256k1 = keys.SigningAlgo(EthSecp256k1Type) )
const ( PrivKeyAminoName = "ethermint/PrivKeySecp256k1" PubKeyAminoName = "ethermint/PubKeySecp256k1" )
Amino encoding names
Variables ¶
var CryptoCodec = codec.New()
CryptoCodec is the default amino codec used by ethermint
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
DeriveSecp256k1 derives and returns the eth_secp256k1 private key for the given mnemonic and HD path.
func EthSecp256k1Options ¶ added in v0.1.0
func EthSecp256k1Options() []keys.KeybaseOption
EthSecp256k1Options defines a keys options for the ethereum Secp256k1 curve.
func EthermintKeygenFunc ¶
EthermintKeygenFunc is the key generation function to generate secp256k1 ToECDSA from ethereum.
func RegisterCodec ¶
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. The function will panic if the private key is invalid.
type PubKeySecp256k1 ¶
type PubKeySecp256k1 []byte
PubKeySecp256k1 defines a type alias for an ecdsa.PublicKey that implements Tendermint's PubKey interface. It represents the 33-byte compressed public key format.
func (PubKeySecp256k1) Address ¶
func (key PubKeySecp256k1) Address() tmcrypto.Address
Address returns the address of the ECDSA public key. The function will panic if the public key is invalid.
func (PubKeySecp256k1) Bytes ¶
func (key PubKeySecp256k1) Bytes() []byte
Bytes returns the raw bytes of the ECDSA public key. The function panics if the key cannot be marshaled to bytes.
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.