ethermint

package
v2.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PrivKeySize defines the size of the PrivKey bytes
	PrivKeySize = 32
	// PubKeySize defines the size of the PubKey bytes
	PubKeySize = 33
	// KeyType is the string constant for the Secp256k1 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

View Source
const (
	// EthSecp256k1Type defines the ECDSA secp256k1 used on Ethereum
	EthSecp256k1Type = hd.PubKeyType(KeyType)
)

Variables

View Source
var (
	ErrInvalidLengthAccount        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowAccount          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupAccount = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	// SupportedAlgorithms defines the list of signing algorithms used on Ethermint:
	//  - eth_secp256k1 (Ethereum)
	//  - secp256k1 (Comet)
	SupportedAlgorithms = keyring.SigningAlgoList{EthSecp256k1, hd.Secp256k1}
	// SupportedAlgorithmsLedger defines the list of signing algorithms used on Ethermint for the Ledger device:
	//  - eth_secp256k1 (Ethereum)
	//  - secp256k1 (Comet)
	SupportedAlgorithmsLedger = keyring.SigningAlgoList{EthSecp256k1, hd.Secp256k1}
)
View Source
var (
	ErrInvalidLengthKeys        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowKeys          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupKeys = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (
	ErrInvalidLengthWeb3        = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowWeb3          = fmt.Errorf("proto: integer overflow")
	ErrUnexpectedEndOfGroupWeb3 = fmt.Errorf("proto: unexpected end of group")
)
View Source
var (

	// EthSecp256k1 uses the Bitcoin secp256k1 ECDSA parameters.
	EthSecp256k1 = ethSecp256k1Algo{}
)

Functions

func EthSecp256k1Option

func EthSecp256k1Option() keyring.Option

EthSecp256k1Option defines a function keys options for the ethereum Secp256k1 curve. It supports eth_secp256k1 and secp256k1 keys for accounts.

func GetEIP712BytesForMsg

func GetEIP712BytesForMsg(signDocBytes []byte) ([]byte, error)

Get the EIP-712 object bytes for the given SignDoc bytes by first decoding the bytes into an EIP-712 object, then hashing the EIP-712 object to create the bytes to be signed. See https://eips.ethereum.org/EIPS/eip-712 for more.

func GetEIP712TypedDataForMsg

func GetEIP712TypedDataForMsg(signDocBytes []byte) (apitypes.TypedData, error)

GetEIP712TypedDataForMsg returns the EIP-712 TypedData representation for either Amino or Protobuf encoded signature doc bytes.

func ParseChainID

func ParseChainID(chainID string) (*big.Int, error)

ParseChainID parses a string chain identifier's epoch to an Ethereum-compatible chain-id in *big.Int format. The function returns an error if the chain-id has an invalid format

func RegisterInterfaces

func RegisterInterfaces(registry codectypes.InterfaceRegistry)

RegisterInterfaces register the Ethermint key concrete types.

func WrapTxToTypedData

func WrapTxToTypedData(
	cdc codectypes.AnyUnpacker,
	chainID uint64,
	msg sdk.Msg,
	data []byte,
	feeDelegation *FeeDelegationOptions,
) (apitypes.TypedData, error)

WrapTxToTypedData is an ultimate method that wraps Amino-encoded Cosmos Tx JSON data into an EIP712-compatible TypedData request.

Types

type EthAccount

type EthAccount struct {
	// base_account is an authtypes.BaseAccount
	*types.BaseAccount `` /* 136-byte string literal not displayed */
	// code_hash is the hash calculated from the code contents
	CodeHash string `protobuf:"bytes,2,opt,name=code_hash,json=codeHash,proto3" json:"code_hash,omitempty" yaml:"code_hash"`
}

EthAccount implements the authtypes.AccountI interface and embeds an authtypes.BaseAccount type. It is compatible with the auth AccountKeeper.

func (*EthAccount) Descriptor

func (*EthAccount) Descriptor() ([]byte, []int)

func (*EthAccount) Marshal

func (m *EthAccount) Marshal() (dAtA []byte, err error)

func (*EthAccount) MarshalTo

func (m *EthAccount) MarshalTo(dAtA []byte) (int, error)

func (*EthAccount) MarshalToSizedBuffer

func (m *EthAccount) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*EthAccount) ProtoMessage

func (*EthAccount) ProtoMessage()

func (*EthAccount) Reset

func (m *EthAccount) Reset()

func (*EthAccount) Size

func (m *EthAccount) Size() (n int)

func (*EthAccount) Unmarshal

func (m *EthAccount) Unmarshal(dAtA []byte) error

func (*EthAccount) XXX_DiscardUnknown

func (m *EthAccount) XXX_DiscardUnknown()

func (*EthAccount) XXX_Marshal

func (m *EthAccount) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*EthAccount) XXX_Merge

func (m *EthAccount) XXX_Merge(src proto.Message)

func (*EthAccount) XXX_Size

func (m *EthAccount) XXX_Size() int

func (*EthAccount) XXX_Unmarshal

func (m *EthAccount) XXX_Unmarshal(b []byte) error

type ExtensionOptionsWeb3Tx

type ExtensionOptionsWeb3Tx struct {
	// typed_data_chain_id is used only in EIP712 Domain and should match
	// Ethereum network ID in a Web3 provider (e.g. Metamask).
	TypedDataChainID uint64 `protobuf:"varint,1,opt,name=typed_data_chain_id,json=typedDataChainId,proto3" json:"typedDataChainID,omitempty"`
	// fee_payer is an account address for the fee payer. It will be validated
	// during EIP712 signature checking.
	FeePayer string `protobuf:"bytes,2,opt,name=fee_payer,json=feePayer,proto3" json:"feePayer,omitempty"`
	// fee_payer_sig is a signature data from the fee paying account,
	// allows to perform fee delegation when using EIP712 Domain.
	FeePayerSig []byte `protobuf:"bytes,3,opt,name=fee_payer_sig,json=feePayerSig,proto3" json:"feePayerSig,omitempty"`
}

ExtensionOptionsWeb3Tx is an extension option that specifies the typed chain id, the fee payer as well as its signature data.

func (*ExtensionOptionsWeb3Tx) Descriptor

func (*ExtensionOptionsWeb3Tx) Descriptor() ([]byte, []int)

func (*ExtensionOptionsWeb3Tx) Marshal

func (m *ExtensionOptionsWeb3Tx) Marshal() (dAtA []byte, err error)

func (*ExtensionOptionsWeb3Tx) MarshalTo

func (m *ExtensionOptionsWeb3Tx) MarshalTo(dAtA []byte) (int, error)

func (*ExtensionOptionsWeb3Tx) MarshalToSizedBuffer

func (m *ExtensionOptionsWeb3Tx) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*ExtensionOptionsWeb3Tx) ProtoMessage

func (*ExtensionOptionsWeb3Tx) ProtoMessage()

func (*ExtensionOptionsWeb3Tx) Reset

func (m *ExtensionOptionsWeb3Tx) Reset()

func (*ExtensionOptionsWeb3Tx) Size

func (m *ExtensionOptionsWeb3Tx) Size() (n int)

func (*ExtensionOptionsWeb3Tx) String

func (m *ExtensionOptionsWeb3Tx) String() string

func (*ExtensionOptionsWeb3Tx) Unmarshal

func (m *ExtensionOptionsWeb3Tx) Unmarshal(dAtA []byte) error

func (*ExtensionOptionsWeb3Tx) XXX_DiscardUnknown

func (m *ExtensionOptionsWeb3Tx) XXX_DiscardUnknown()

func (*ExtensionOptionsWeb3Tx) XXX_Marshal

func (m *ExtensionOptionsWeb3Tx) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*ExtensionOptionsWeb3Tx) XXX_Merge

func (m *ExtensionOptionsWeb3Tx) XXX_Merge(src proto.Message)

func (*ExtensionOptionsWeb3Tx) XXX_Size

func (m *ExtensionOptionsWeb3Tx) XXX_Size() int

func (*ExtensionOptionsWeb3Tx) XXX_Unmarshal

func (m *ExtensionOptionsWeb3Tx) XXX_Unmarshal(b []byte) error

type FeeDelegationOptions

type FeeDelegationOptions struct {
	FeePayer sdk.AccAddress
}

type PrivKey

type PrivKey struct {
	// key is the private key in byte form
	Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
}

PrivKey defines a type alias for an ecdsa.PrivateKey that implements Comet'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 byte representation of the ECDSA Private Key.

func (*PrivKey) Descriptor

func (*PrivKey) Descriptor() ([]byte, []int)

func (PrivKey) Equals

func (privKey PrivKey) Equals(other cryptotypes.LedgerPrivKey) bool

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

func (*PrivKey) GetKey

func (m *PrivKey) GetKey() []byte

func (*PrivKey) Marshal

func (m *PrivKey) Marshal() (dAtA []byte, err error)

func (PrivKey) MarshalAmino

func (privKey PrivKey) MarshalAmino() ([]byte, error)

MarshalAmino overrides Amino binary marshaling.

func (PrivKey) MarshalAminoJSON

func (privKey PrivKey) MarshalAminoJSON() ([]byte, error)

MarshalAminoJSON overrides Amino JSON marshaling.

func (*PrivKey) MarshalTo

func (m *PrivKey) MarshalTo(dAtA []byte) (int, error)

func (*PrivKey) MarshalToSizedBuffer

func (m *PrivKey) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*PrivKey) ProtoMessage

func (*PrivKey) ProtoMessage()

func (PrivKey) PubKey

func (privKey PrivKey) PubKey() cryptotypes.PubKey

PubKey returns the ECDSA private key's public key. If the privkey is not valid it returns a nil value.

func (*PrivKey) Reset

func (m *PrivKey) Reset()

func (PrivKey) Sign

func (privKey PrivKey) Sign(digestBz []byte) ([]byte, error)

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

func (*PrivKey) Size

func (m *PrivKey) Size() (n int)

func (*PrivKey) String

func (m *PrivKey) String() string

func (PrivKey) ToECDSA

func (privKey PrivKey) ToECDSA() (*ecdsa.PrivateKey, error)

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

func (PrivKey) Type

func (privKey PrivKey) Type() string

Type returns eth_secp256k1

func (*PrivKey) Unmarshal

func (m *PrivKey) Unmarshal(dAtA []byte) error

func (*PrivKey) UnmarshalAmino

func (privKey *PrivKey) UnmarshalAmino(bz []byte) error

UnmarshalAmino overrides Amino binary marshaling.

func (*PrivKey) UnmarshalAminoJSON

func (privKey *PrivKey) UnmarshalAminoJSON(bz []byte) error

UnmarshalAminoJSON overrides Amino JSON marshaling.

func (*PrivKey) XXX_DiscardUnknown

func (m *PrivKey) XXX_DiscardUnknown()

func (*PrivKey) XXX_Marshal

func (m *PrivKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PrivKey) XXX_Merge

func (m *PrivKey) XXX_Merge(src proto.Message)

func (*PrivKey) XXX_Size

func (m *PrivKey) XXX_Size() int

func (*PrivKey) XXX_Unmarshal

func (m *PrivKey) XXX_Unmarshal(b []byte) error

type PubKey

type PubKey struct {
	// key is the public key in byte form
	Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
}

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

func (PubKey) Address

func (pubKey PubKey) Address() tmcrypto.Address

Address returns the address of the ECDSA public key. The function will return an empty address if the public key is invalid.

func (PubKey) Bytes

func (pubKey PubKey) Bytes() []byte

Bytes returns the raw bytes of the ECDSA public key.

func (*PubKey) Descriptor

func (*PubKey) Descriptor() ([]byte, []int)

func (PubKey) Equals

func (pubKey PubKey) Equals(other cryptotypes.PubKey) bool

Equals returns true if the pubkey type is the same and their bytes are deeply equal.

func (*PubKey) GetKey

func (m *PubKey) GetKey() []byte

func (*PubKey) Marshal

func (m *PubKey) Marshal() (dAtA []byte, err error)

func (PubKey) MarshalAmino

func (pubKey PubKey) MarshalAmino() ([]byte, error)

MarshalAmino overrides Amino binary marshaling.

func (PubKey) MarshalAminoJSON

func (pubKey PubKey) MarshalAminoJSON() ([]byte, error)

MarshalAminoJSON overrides Amino JSON marshaling.

func (*PubKey) MarshalTo

func (m *PubKey) MarshalTo(dAtA []byte) (int, error)

func (*PubKey) MarshalToSizedBuffer

func (m *PubKey) MarshalToSizedBuffer(dAtA []byte) (int, error)

func (*PubKey) ProtoMessage

func (*PubKey) ProtoMessage()

func (*PubKey) Reset

func (m *PubKey) Reset()

func (*PubKey) Size

func (m *PubKey) Size() (n int)

func (PubKey) String

func (pubKey PubKey) String() string

String implements the fmt.Stringer interface.

func (PubKey) Type

func (pubKey PubKey) Type() string

Type returns eth_secp256k1

func (*PubKey) Unmarshal

func (m *PubKey) Unmarshal(dAtA []byte) error

func (*PubKey) UnmarshalAmino

func (pubKey *PubKey) UnmarshalAmino(bz []byte) error

UnmarshalAmino overrides Amino binary marshaling.

func (*PubKey) UnmarshalAminoJSON

func (pubKey *PubKey) UnmarshalAminoJSON(bz []byte) error

UnmarshalAminoJSON overrides Amino JSON marshaling.

func (PubKey) VerifySignature

func (pubKey PubKey) VerifySignature(msg, sig []byte) bool

VerifySignature 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 and approve verification if the signature can be verified from either the original message or its EIP-712 representation.

CONTRACT: The signature should be in [R || S] format.

func (*PubKey) XXX_DiscardUnknown

func (m *PubKey) XXX_DiscardUnknown()

func (*PubKey) XXX_Marshal

func (m *PubKey) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*PubKey) XXX_Merge

func (m *PubKey) XXX_Merge(src proto.Message)

func (*PubKey) XXX_Size

func (m *PubKey) XXX_Size() int

func (*PubKey) XXX_Unmarshal

func (m *PubKey) XXX_Unmarshal(b []byte) error

Jump to

Keyboard shortcuts

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