keyring

package
v0.0.1-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSharedKeyReturned = errors.New("vault returned no shared key")
	ErrBadSharedKey        = errors.New("vault returned bad shared key")
	ErrNoSignatureReturned = errors.New("vault returned no signature")
	ErrNoPubkeyReturned    = errors.New("vault returned no pubkey")
)

Functions

func UseLogger

func UseLogger(logger *zap.SugaredLogger)

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 logicalWriter, node string, coin uint32) *KeyRing

NewKeyRing returns a vault-backed key ring.

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) 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