secp256k1

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package secp256k1 contains methods and types for working with Ethereum and possibly other cryptocurrency keys that use the secp256k1 elliptic curve.

Index

Constants

View Source
const (
	//nolint:revive
	// https://github.com/bitcoin-core/secp256k1/blob/44c2452fd387f7ca604ab42d73746e7d3a44d8a2/include/secp256k1.h#L208
	Secp256k1TagPubkeyEven = byte(2)
	Secp256k1TagPubkeyOdd  = byte(3) //nolint:revive
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

PublicKey represents a secp256k1 public key

func NewPublicKey

func NewPublicKey(x, y [32]byte) *PublicKey

NewPublicKey returns a new public key from the given (x, y) coordinates

func NewPublicKeyFromBigInt

func NewPublicKeyFromBigInt(x, y *big.Int) *PublicKey

NewPublicKeyFromBigInt returns a new public key from the given (x, y) coordinates

func (*PublicKey) Bytes

func (k *PublicKey) Bytes() []byte

Bytes returns the uncompressed 64-byte public key

func (*PublicKey) Compress

func (k *PublicKey) Compress() [33]byte

Compress returns the 33-byte compressed public key

func (*PublicKey) Keccak256

func (k *PublicKey) Keccak256() [32]byte

Keccak256 returns the heccak256 hash of the x and y coordinates concatenated

func (*PublicKey) MarshalText

func (k *PublicKey) MarshalText() ([]byte, error)

MarshalText converts the public key a string for JSON marshalling

func (*PublicKey) String

func (k *PublicKey) String() string

String returns the key as a 64-byte hex encoded string with a leading 0x

func (*PublicKey) UnmarshalText

func (k *PublicKey) UnmarshalText(keyData []byte) error

UnmarshalText converts a 64 byte hex string, with or without a 0x prefix, into the PublicKey type during JSON unmarshalling.

func (*PublicKey) X

func (k *PublicKey) X() [32]byte

X returns the x-coordinate of the key

func (*PublicKey) Y

func (k *PublicKey) Y() [32]byte

Y returns the y-coordinate of the key

Jump to

Keyboard shortcuts

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