util

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeFromBytes

func DecodeFromBytes[T any](in []byte) (*T, error)

func EncodeToBytes

func EncodeToBytes(p interface{}) []byte

func HexToPrivateKey

func HexToPrivateKey(hexStr string) *ecdsa.PrivateKey

Types

type Address

type Address [addressLength]byte

Address is the address of the account.

func BytesToAddress

func BytesToAddress(b []byte) *Address

NewAddress creates a new address from the given byte array.

func PublicKeyToAddress

func PublicKeyToAddress(pubkey *ecdsa.PublicKey) *Address

func StringToAddress added in v1.1.0

func StringToAddress(s string) *Address

string to Address

func (Address) Bytes

func (a Address) Bytes() []byte

Bytes returns the byte representation of the address.

func (Address) String

func (a Address) String() string

String returns the string representation of the address.

type CompactPublicKey

type CompactPublicKey struct {
	CurveParams *elliptic.CurveParams `json:"Curve"`
	X           *big.Int              `json:"X"`
	Y           *big.Int              `json:"Y"`
}

func PublicKeyToCompact

func PublicKeyToCompact(pubkey *ecdsa.PublicKey) *CompactPublicKey

func (*CompactPublicKey) PublicKey

func (cpk *CompactPublicKey) PublicKey() *ecdsa.PublicKey

type Hash

type Hash [hashLength]byte

Hash is the hash of the block.

func ByteToHash

func ByteToHash(b []byte) *Hash

ByteToHash converts a byte array to hash.

func HashData

func HashData(b []byte) *Hash

NewHash creates a new sha256 hash from the given byte array.

func (Hash) Bytes

func (h Hash) Bytes() []byte

Bytes returns the byte representation of the hash.

func (Hash) String

func (h Hash) String() string

String returns the string representation of the hash.

type UnlockedAccount

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

func NewUnlockedAccount

func NewUnlockedAccount(privateKey *ecdsa.PrivateKey) *UnlockedAccount

func (*UnlockedAccount) Address

func (ua *UnlockedAccount) Address() *Address

func (*UnlockedAccount) PublicKey

func (ua *UnlockedAccount) PublicKey() *ecdsa.PublicKey

func (*UnlockedAccount) Sign

func (ua *UnlockedAccount) Sign(data []byte) (*big.Int, *big.Int, error)

func (*UnlockedAccount) Verify

func (ua *UnlockedAccount) Verify(data []byte, r *big.Int, s *big.Int) bool

Jump to

Keyboard shortcuts

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