Documentation ¶
Overview ¶
Package key is a library of functions for handling Bitcoin-style secp256k1 elliptic curve signatures, and a simple in-memory keychain, with support for encryption of non-active private key data.
Index ¶
- Constants
- func NewID(bytes *[]byte) (out core.Address)
- type AffectedKeysVisitor
- type Priv
- func (r *Priv) AsEC() (ecpriv *ecdsa.PrivateKey)
- func (r *Priv) Bytes() (out *[]byte)
- func (r *Priv) Copy(in *[]byte) core.Buffer
- func (r *Priv) Free() core.Buffer
- func (r *Priv) GetID() core.Address
- func (r *Priv) Hex() (out string)
- func (r *Priv) Invalidate() *Priv
- func (r *Priv) IsValid() bool
- func (r *Priv) Make() *Priv
- func (r *Priv) NewIf() *Priv
- func (r *Priv) PubKey() core.Buffer
- func (r *Priv) SetKey(priv *[]byte, pub *[]byte) (out *Priv)
- func (r *Priv) Sign(h *[]byte) (out *Sig)
- func (r *Priv) SignCompact(h *[]byte) (out *Sig)
- func (r *Priv) WithBC(bc *bc.BlockCrypt) *Priv
- func (r *Priv) Zero() core.Buffer
- type Pub
- func (r *Pub) AsCompressed() (out *buf.Byte)
- func (r *Pub) AsEC() (out *ecdsa.PublicKey)
- func (r *Pub) AsHybrid() (out *buf.Byte)
- func (r *Pub) AsUncompressed() (out *buf.Byte)
- func (r *Pub) Bytes() (out *[]byte)
- func (r *Pub) Compress() *Pub
- func (r *Pub) Copy(in *[]byte) core.Buffer
- func (r *Pub) Decompress() *Pub
- func (r *Pub) Free() core.Buffer
- func (r *Pub) GetID() core.Address
- func (r *Pub) IsCompressed() bool
- func (r *Pub) NewIf() *Pub
- func (r *Pub) Zero() core.Buffer
- type ScriptVisitor
- type Sig
- type SigData
- type SignatureCache
- type Store
- func (r *Store) AddPriv(priv *Priv) *Store
- func (r *Store) AddPub(pub *Pub) *Store
- func (r *Store) Decrypt() *Store
- func (r *Store) Encrypt(blockCrypt *bc.BlockCrypt) *Store
- func (r *Store) Find(id core.Address) (out *Priv)
- func (r *Store) OK() bool
- func (r *Store) Remove(id core.Address) *Store
- func (r *Store) SetStatus(s string) core.Status
- func (r *Store) SetStatusIf(err error) core.Status
- func (r *Store) UnsetStatus() core.Status
- type StoreIsMineVisitor
Constants ¶
const ( // SigHashAll is SigHashAll = 1 // SigHashNone is SigHashNone = 2 // SigHashSingle is SigHashSingle = 3 // SigHashAnyoneCanPay is SigHashAnyoneCanPay = 0x80 // VerifyNone is VerifyNone = 0 // VerifyP2SH is VerifyP2SH = 1 // VerifyStrictEnc is VerifyStrictEnc = 1 << 1 // VerifyNocache is VerifyNocache = 1 << 2 // TxNonstandard is a nonstandard transaction (eg just writing bytes) TxNonstandard = iota // TxPubKey is is a public key TxPubKey // TxPubKeyHash is the hash of a public key TxPubKeyHash // TxScriptHash is the hash of a script TxScriptHash // TxMultisig is a multisignature transaction TxMultisig )
Various script flags
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AffectedKeysVisitor ¶
AffectedKeysVisitor -
type Priv ¶
Priv is a private key, stored in a Crypt
func (*Priv) AsEC ¶
func (r *Priv) AsEC() (ecpriv *ecdsa.PrivateKey)
AsEC returns the key in ecdsa.PrivateKey format
func (*Priv) Hex ¶
Hex returns the hex representation of the contennt of the crypt via the get function
func (*Priv) Invalidate ¶
Invalidate zeroes the key and marks it invalid
func (*Priv) Make ¶
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) SetKey ¶
SetKey loads a private key from raw bytes, and zeroes the input bytes of the private key
func (*Priv) SignCompact ¶
SignCompact produces a compact signature for BTC type systems
type Pub ¶
Pub is a secp256k1 EC public key which can be represented as a compressed, uncompressed or hybrid for wire and storage
func (*Pub) AsCompressed ¶
AsCompressed returns the compressed serialised form (33 bytes, prefix 2 or 3 depending on whether y is odd or even)
func (*Pub) AsHybrid ¶
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 ¶
AsUncompressed returns the uncompressed serialised form (65 bytes with x and y with the prefix 4)
func (*Pub) Decompress ¶
Decompress converts the key to compressed format if it is in anothter format
func (*Pub) IsCompressed ¶
IsCompressed returns true if the key is compressed
type ScriptVisitor ¶
type ScriptVisitor struct {
// contains filtered or unexported fields
}
ScriptVisitor -
type Sig ¶
Sig is a bitcoin EC signature
type SignatureCache ¶
SignatureCache -
type Store ¶
type Store struct { BC *bc.BlockCrypt core.State // contains filtered or unexported fields }
Store is a keychain for public and private keys
func (*Store) Encrypt ¶
func (r *Store) Encrypt(blockCrypt *bc.BlockCrypt) *Store
Encrypt sets the store to encrypt private keys
func (*Store) Find ¶
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