keyring

package
v0.0.0-...-d9725e3 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until UseLogger is called.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info.

Types

type KeyDescriptor

type KeyDescriptor struct {
	// KeyLocator is the internal KeyLocator of the descriptor.
	KeyLocator

	// PubKey is an optional public key that fully describes a target key.
	// If this is nil, the KeyLocator MUST NOT be empty.
	PubKey *btcec.PublicKey
}

type KeyLocator

type KeyLocator struct {
	// Family is the family of key being identified.
	Family uint32

	// Index is the precise index of the key being identified.
	Index uint32
}

type KeyRing

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

KeyRing is an HD keyring backed by pre-derived in-memory account keys from which index keys can be quickly derived on demand.

func NewKeyRing

func NewKeyRing(client *api.Logical, node string, coin int) *KeyRing

NewKeyRing returns a vault-backed key ring.

func (*KeyRing) Coin

func (k *KeyRing) Coin() int

Coin returns the node's HDCoinType as an int. It must be converted to a uint32 and hardened before use in a derivation path.

func (*KeyRing) ECDH

func (k *KeyRing) ECDH(keyDesc KeyDescriptor, pub *btcec.PublicKey) ([32]byte,
	error)

ECDH performs a scalar multiplication (ECDH-like operation) between the target key descriptor and remote public key. The output returned will be the sha256 of the resulting shared point serialized in compressed format. If k is our private key, and P is the public key, we perform the following operation:

sx := k*P s := sha256(sx.SerializeCompressed())

func (*KeyRing) Node

func (k *KeyRing) Node() string

Node returns the node's pubkey as a hex-encoded string.

func (*KeyRing) SignMessage

func (k *KeyRing) SignMessage(keyLoc KeyLocator, msg []byte, doubleHash bool,
	compact bool) ([]byte, error)

SignMessage signs the given message, single or double SHA256 hashing it first, with the private key described in the key locator.

func (*KeyRing) SignMessageSchnorr

func (k *KeyRing) SignMessageSchnorr(keyLoc KeyLocator, msg []byte,
	doubleHash bool, taprootTweak []byte) (*schnorr.Signature, error)

SignMessageSchnorr signs the given message, single or double SHA256 hashing it first, with the private key described in the key locator and the optional Taproot tweak applied to the private key.

func (*KeyRing) SignPsbt

func (k *KeyRing) SignPsbt(packet *psbt.Packet) ([]uint32, error)

SignPsbt signs all inputs in the PSBT that can be signed by our keyring. We have no state information, so we only attempt to derive the appropriate keys for each input and sign if we get a match.

Jump to

Keyboard shortcuts

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