crypto

package
v0.0.0-...-6a320d6 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PubKeyBytesLenCompressed = 33
)

Variables

This section is empty.

Functions

func Blake160

func Blake160(data []byte) ([]byte, error)

func Blake256

func Blake256(data []byte) ([]byte, error)

func PaddedBigBytes

func PaddedBigBytes(bigint *big.Int, n int) []byte

PaddedBigBytes encodes a big integer as a big-endian byte slice. The length of the slice is at least n bytes.

func ReadBits

func ReadBits(bigint *big.Int, buf []byte)

ReadBits encodes the absolute value of bigint as big-endian bytes. Callers must ensure that buf has enough space. If buf is too short the result will be incomplete.

func ZeroBytes

func ZeroBytes(bytes []byte)

Types

type Encoding

type Encoding uint
const (
	BECH32 Encoding = iota
	BECH32M
)

func Bech32Decode

func Bech32Decode(bech string) (Encoding, string, []byte, error)

type Secp256k1Key

type Secp256k1Key struct {
	PrivateKey *ecdsa.PrivateKey
}

func HexToKey

func HexToKey(hexkey string) (*Secp256k1Key, error)

func RandomNew

func RandomNew() (*Secp256k1Key, error)

func ToKey

func ToKey(d []byte) (*Secp256k1Key, error)

func (*Secp256k1Key) Bytes

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

func (*Secp256k1Key) PubKey

func (k *Secp256k1Key) PubKey() []byte

func (*Secp256k1Key) Sign

func (k *Secp256k1Key) Sign(data []byte) ([]byte, error)

Sign creates a recoverable ECDSA signature. The produced signature is in the 65-byte [R || S || V] format where V is 0 or 1.

type SignatureData

type SignatureData struct {
	V *big.Int
	R *big.Int
	S *big.Int

	ByteV byte
	ByteR []byte
	ByteS []byte
}

func SignAsRecoverable

func SignAsRecoverable(value []byte, prvKey *btcec.PrivateKey) *SignatureData

func (SignatureData) ToBytes

func (sd SignatureData) ToBytes() []byte

func (*SignatureData) ToHex

func (sd *SignatureData) ToHex() string

Jump to

Keyboard shortcuts

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