crypto

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2018 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SigHashAll          = 1
	SigHashNone         = 2
	SigHashSingle       = 3
	SigHashForkID       = 0x40
	SigHashAnyoneCanpay = 0x80

	// SigHashMask defines the number of bits of the hash type which is used
	// to identify which outputs are signed.
	SigHashMask = 0x1f
)
View Source
const (
	PrivateKeyBytesLen      = 32
	DumpedPrivateKeyVersion = 128
)

Variables

This section is empty.

Functions

func InitSecp256

func InitSecp256()

func IsCompressedOrUncompressedPubKey

func IsCompressedOrUncompressedPubKey(bytes []byte) bool

func IsCompressedPubKey

func IsCompressedPubKey(bytes []byte) bool

func IsDefineHashtypeSignature

func IsDefineHashtypeSignature(vchSig []byte) bool

func IsLowDERSignature

func IsLowDERSignature(vchSig []byte) (bool, error)

func IsValidSignatureEncoding

func IsValidSignatureEncoding(signs []byte) bool

Types

type PrivateKey

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

func DecodePrivateKey

func DecodePrivateKey(encoded string) (*PrivateKey, error)

func PrivateKeyFromBytes

func PrivateKeyFromBytes(privateKeyBytes []byte) *PrivateKey

func (*PrivateKey) Encode

func (privateKey *PrivateKey) Encode() []byte

func (*PrivateKey) PubKey

func (privateKey *PrivateKey) PubKey() *PublicKey

func (*PrivateKey) Sign

func (privateKey *PrivateKey) Sign(hash []byte) (*Signature, error)

func (*PrivateKey) ToString

func (privateKey *PrivateKey) ToString() string

type PublicKey

type PublicKey struct {
	SecpPubKey *secp256k1.PublicKey
	Compressed bool
}

func ParsePubKey

func ParsePubKey(pubKeyStr []byte) (*PublicKey, error)

func (*PublicKey) IsEqual

func (publicKey *PublicKey) IsEqual(otherPublicKey *PublicKey) bool

func (*PublicKey) SerializeCompressed

func (publicKey *PublicKey) SerializeCompressed() []byte

func (*PublicKey) SerializeUncompressed

func (publicKey *PublicKey) SerializeUncompressed() []byte

func (*PublicKey) ToBytes

func (publicKey *PublicKey) ToBytes() []byte

func (*PublicKey) ToHexString

func (publicKey *PublicKey) ToHexString() string

func (*PublicKey) ToSecp256k

func (publicKey *PublicKey) ToSecp256k() *secp256k1.PublicKey

type Signature

type Signature secp256k1.EcdsaSignature

func ParseDERSignature

func ParseDERSignature(signature []byte) (*Signature, error)

func (*Signature) EcdsaNormalize

func (sig *Signature) EcdsaNormalize() bool

func (*Signature) Serialize

func (sig *Signature) Serialize() []byte

func (*Signature) Verify

func (sig *Signature) Verify(hash []byte, pubKey *PublicKey) bool

Jump to

Keyboard shortcuts

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