crypto

package
Version: v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 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 CheckLowS added in v0.0.4

func CheckLowS(vchSig []byte) bool

func InitPrivateKeyVersion added in v0.0.3

func InitPrivateKeyVersion(privateKeyVer byte)

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 IsValidSignatureEncoding

func IsValidSignatureEncoding(signs []byte) bool

Types

type KeyPair added in v0.0.3

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

func NewKeyPair added in v0.0.3

func NewKeyPair(privateKey *PrivateKey) *KeyPair

func (*KeyPair) GetKeyID added in v0.0.3

func (kd *KeyPair) GetKeyID() string

func (*KeyPair) GetPrivateKey added in v0.0.3

func (kd *KeyPair) GetPrivateKey() *PrivateKey

func (*KeyPair) GetPublicKey added in v0.0.3

func (kd *KeyPair) GetPublicKey() *PublicKey

type KeyStore added in v0.0.3

type KeyStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewKeyStore added in v0.0.3

func NewKeyStore() *KeyStore

func (*KeyStore) AddKey added in v0.0.3

func (ks *KeyStore) AddKey(privateKey *PrivateKey)

func (*KeyStore) AddKeyPairs added in v0.0.3

func (ks *KeyStore) AddKeyPairs(keys []*KeyPair)

func (*KeyStore) GetKeyPair added in v0.0.3

func (ks *KeyStore) GetKeyPair(pubKeyHash []byte) *KeyPair

func (*KeyStore) GetKeyPairByPubKey added in v0.0.3

func (ks *KeyStore) GetKeyPairByPubKey(pubKey []byte) *KeyPair

func (*KeyStore) GetKeyPairs added in v0.0.3

func (ks *KeyStore) GetKeyPairs(pubKeyHashList [][]byte) []*KeyPair

type PrivateKey

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

func DecodePrivateKey

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

func NewPrivateKeyFromBytes added in v0.0.2

func NewPrivateKeyFromBytes(data []byte, compressed bool) *PrivateKey

func PrivateKeyFromBytes

func PrivateKeyFromBytes(privateKeyBytes []byte) *PrivateKey

func (*PrivateKey) Encode

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

func (*PrivateKey) GetBytes added in v0.0.2

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

func (*PrivateKey) IsCompressed added in v0.0.2

func (privateKey *PrivateKey) IsCompressed() bool

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) ToHash160 added in v0.0.2

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

func (*PublicKey) ToHexString

func (publicKey *PublicKey) ToHexString() string

func (*PublicKey) ToSecp256k

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

func (*PublicKey) Verify added in v0.0.4

func (publicKey *PublicKey) Verify(hash *util.Hash, vchSig []byte) (bool, error)

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
t or T : Toggle theme light dark auto
y or Y : Canonical URL