ethsecp256k1

package
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2023 License: Apache-2.0, Apache-2.0 Imports: 14 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

Variables

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")
)

Functions

This section is empty.

Types

type PrivKey

type PrivKey struct {
	Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
}

PrivKey defines a type alias for an ecdsa.PrivateKey that implements Tendermint'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 []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
}

PubKey defines a type alias for an ecdsa.PublicKey that implements Tendermint'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.

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