bip322

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: ISC Imports: 10 Imported by: 0

Documentation

Overview

Package bip322 holds all the relevant tools to actually build and validate signed message via BIP-322.

For more information, refer: https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki

These files were heavily inspired by:

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildToSignTx

func BuildToSignTx(toSpend *wire.MsgTx) *wire.MsgTx

BuildToSignTx builds a toSign transaction based on the BIP-322 spec. // It requires the toSpend transaction that it spends.

For more details, refer: https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki#full

func BuildToSpendTx

func BuildToSpendTx(msg []byte, address btcutil.Address) (*wire.MsgTx, error)

BuildToSpendTx builds a toSpend transaction based on the BIP-322 spec. It requires the message that is signed and the address that produced the signature.

For more details, refer: https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki#full

func IsSupported

func IsSupported(address btcutil.Address) bool

func SimpleSigToWitness

func SimpleSigToWitness(sig []byte) ([][]byte, error)

SimpleSigToWitness converts a simple signature into a witness stack. As per the BIP-322 spec, a simple signature consists of a witness stack, consensus encoded as a vector of vectors of bytes. For more details, refer: https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki#simple

The encoding of the witness stack is based on the Leather wallet implementation. For details, refer: https://github.com/leather-wallet/extension/blob/dev/src/shared/crypto/bitcoin/bip322/bip322-utils.ts#L58

The signature is encoded as follows: - 1st byte: Elements of the witness stack that are serialized - For each element of the stack

  • The first byte specifies how many bytes it contains
  • The rest are the bytes of the element

func Verify

func Verify(address btcutil.Address, message string, signatureDecoded []byte) (bool, error)

TODO: Check if we can implement more by referencing https://github.com/ACken2/bip322-js/blob/main/src/Verifier.ts#L23 Their implementation supports *btcutil.AddressScriptHash (but no multisig, yet).

Types

This section is empty.

Jump to

Keyboard shortcuts

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