secp256k1

package
v0.0.0-...-7657fe4 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 13 Imported by: 1

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

Variables

View Source
var File_framework_crypto_secp256k1_keys_proto protoreflect.FileDescriptor

Functions

func Derive

func Derive(mnemonic, bip39Passphrase, path string) ([]byte, error)

Derive derives and returns the eth_secp256k1 private key for the given mnemonic and HD path.

func MakePubKey

func MakePubKey(key []byte) fwcryptotypes.PubKey

func PubKeyFromBytes

func PubKeyFromBytes(bz []byte) fwcryptotypes.PubKey

Types

type PrivKey

type PrivKey struct {
	Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	// contains filtered or unexported fields
}

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

func Generate

func Generate(bz []byte) *PrivKey

Generate generates an eth_secp256k1 private key from the given bytes.

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 deprecated

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

Deprecated: Use PrivKey.ProtoReflect.Descriptor instead.

func (*PrivKey) Equals

func (privKey *PrivKey) Equals(other fwcryptotypes.LedgerPrivKey) bool

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

func (*PrivKey) GetKey

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

func (*PrivKey) ProtoMessage

func (*PrivKey) ProtoMessage()

func (*PrivKey) ProtoReflect

func (x *PrivKey) ProtoReflect() protoreflect.Message

func (*PrivKey) PubKey

func (privKey *PrivKey) PubKey() fwcryptotypes.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 (x *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) String

func (x *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

type PubKey

type PubKey struct {
	Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	// contains filtered or unexported fields
}

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() fwcryptotypes.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 deprecated

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

Deprecated: Use PubKey.ProtoReflect.Descriptor instead.

func (*PubKey) Equals

func (pubKey *PubKey) Equals(other fwcryptotypes.PubKey) bool

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

func (*PubKey) GetKey

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

func (*PubKey) ProtoMessage

func (*PubKey) ProtoMessage()

func (*PubKey) ProtoReflect

func (x *PubKey) ProtoReflect() protoreflect.Message

func (*PubKey) Reset

func (x *PubKey) Reset()

func (*PubKey) String

func (x *PubKey) String() string

func (*PubKey) Type

func (pubKey *PubKey) Type() string

Type returns eth_secp256k1

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.

Jump to

Keyboard shortcuts

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