key

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2018 License: Unlicense Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewID

func NewID(bytes *[]byte) (out proto.ID)

NewID creates an ID out of the bytes of an object, used for address (public key ID) and script ID

Types

type Priv

type Priv struct {
	*crypt.Crypt
	// contains filtered or unexported fields
}

Priv is a private key, stored in a Crypt

func NewPriv

func NewPriv() (priv *Priv)

NewPriv creates a new Priv

func (*Priv) AsEC

func (r *Priv) AsEC() (ecpriv *ecdsa.PrivateKey)

AsEC returns the key in ecdsa.PrivateKey format

func (*Priv) Bytes

func (r *Priv) Bytes() (out *[]byte)

Bytes returns the buffer via the Get function of the Crypt

func (*Priv) Copy

func (r *Priv) Copy(in *[]byte) proto.Buffer

Copy stores the input buffer using the Put function of the Crypt

func (*Priv) Free

func (r *Priv) Free() proto.Buffer

Free frees the crypt inside the Priv and marks it invalid

func (*Priv) GetID

func (r *Priv) GetID() proto.ID

GetID returns the hash160 ID of the public key

func (*Priv) Invalidate

func (r *Priv) Invalidate() *Priv

Invalidate zeroes the key and marks it invalid

func (*Priv) IsValid

func (r *Priv) IsValid() bool

IsValid returns true if the Priv is currently valid

func (*Priv) Make

func (r *Priv) Make() *Priv

Make generates a new private key from random bytes. By default it uses compressed format for the public key, to get another format append a further decompression or hybrid method invocation.

func (*Priv) PubKey

func (r *Priv) PubKey() proto.Buffer

PubKey returns a copy of the public key

func (*Priv) SetKey

func (r *Priv) SetKey(priv *[]byte, pub *[]byte) *Priv

SetKey loads a private key from raw bytes, and zeroes the input bytes of the private key

func (*Priv) Sign

func (r *Priv) Sign(h *[]byte) (out *Sig)

Sign the hash of a message

func (*Priv) SignCompact

func (r *Priv) SignCompact(h *[]byte) (out *Sig)

SignCompact produces a compact signature for BTC type systems

func (*Priv) WithBC

func (r *Priv) WithBC(bc *blockcrypt.BlockCrypt) *Priv

WithBC copies in the reference to a BlockCrypt to enable encryption

func (*Priv) Zero

func (r *Priv) Zero() proto.Buffer

Zero zeroes the key and marks it invalid

type Pub

type Pub struct {
	*buf.Byte
}

Pub is a secp256k1 EC public key which can be represented as a compressed, uncompressed or hybrid for wire and storage

func NewPub

func NewPub() *Pub

NewPub creates a new public key

func (*Pub) AsCompressed

func (r *Pub) AsCompressed() (out *buf.Byte)

AsCompressed returns the compressed serialised form (33 bytes, prefix 2 or 3 depending on whether y is odd or even)

func (*Pub) AsEC

func (r *Pub) AsEC() (out *ecdsa.PublicKey)

AsEC returns the EC public key

func (*Pub) AsHybrid

func (r *Pub) AsHybrid() (out *buf.Byte)

AsHybrid returns the uncompressed serialised form with the first byte taken from the first bit of the y coordinate, either 0 or 1, with both x and y coordinates (this is not really used)

func (*Pub) AsUncompressed

func (r *Pub) AsUncompressed() (out *buf.Byte)

AsUncompressed returns the uncompressed serialised form (65 bytes with x and y with the prefix 4)

func (*Pub) Bytes

func (r *Pub) Bytes() (out *[]byte)

Bytes returns the private key

func (*Pub) Compress

func (r *Pub) Compress() *Pub

Compress converts the key to compressed format if it is in another format

func (*Pub) Copy

func (r *Pub) Copy(in *[]byte) proto.Buffer

Copy loads the public key

func (*Pub) Decompress

func (r *Pub) Decompress() *Pub

Decompress converts the key to compressed format if it is in anothter format

func (*Pub) Free

func (r *Pub) Free() proto.Buffer

Free deallocates the buffer of the key

func (*Pub) GetID

func (r *Pub) GetID() proto.ID

GetID returns the hash160 ID of the public key

func (*Pub) ID

func (r *Pub) ID() (out *buf.Byte)

ID returns the ripemd160 hash of the public key

func (*Pub) IsCompressed

func (r *Pub) IsCompressed() bool

IsCompressed returns true if the key is compressed

func (*Pub) Zero

func (r *Pub) Zero() proto.Buffer

Zero wipes the key

type Sig

type Sig struct {
	buf.Byte
	// contains filtered or unexported fields
}

Sig is a bitcoin EC signature

func NewSig

func NewSig() (out *Sig)

NewSig creates a new signature

func (*Sig) AsEC

func (r *Sig) AsEC() (out *btcec.Signature)

AsEC returns the signature in ecdsa format

func (*Sig) Recover

func (r *Sig) Recover(h *[]byte, addr *[]byte) (out *Pub)

Recover returns a public key with a buffer containing the public key if found and a status indicating if it was successful

type Store

type Store struct {
	BC *blockcrypt.BlockCrypt

	Status string
	// contains filtered or unexported fields
}

Store is a keychain for public and private keys

func NewStore

func NewStore() *Store

NewStore creates a new Store

func (*Store) AddPriv

func (r *Store) AddPriv(priv *Priv) *Store

AddPriv adds a new private key to the store

func (*Store) AddPub

func (r *Store) AddPub(pub *Pub) *Store

AddPub adds a new public key to the store

func (*Store) Decrypt

func (r *Store) Decrypt() *Store

Decrypt sets the store to not encrypt private keys

func (*Store) Encrypt

func (r *Store) Encrypt(bc *blockcrypt.BlockCrypt) *Store

Encrypt sets the store to encrypt private keys

func (*Store) Find

func (r *Store) Find(id proto.ID) (out *Priv)

Find returns the key with matching ID as requested. The return type is Priv but if there is no private key the field is empty

func (*Store) OK

func (r *Store) OK() bool

OK returns true if there is no error

func (*Store) Remove

func (r *Store) Remove(id proto.ID) *Store

Remove a key from the store by ID (address)

func (*Store) SetStatus

func (r *Store) SetStatus(s string) proto.Status

SetStatus is a

func (*Store) SetStatusIf

func (r *Store) SetStatusIf(err error) proto.Status

SetStatusIf is a

func (*Store) UnsetStatus

func (r *Store) UnsetStatus() proto.Status

UnsetStatus is a

Jump to

Keyboard shortcuts

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