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 ¶
- func BuildToSignTx(toSpend *wire.MsgTx) *wire.MsgTx
- func BuildToSpendTx(msg []byte, address btcutil.Address) (*wire.MsgTx, error)
- func IsSupported(address btcutil.Address) bool
- func SimpleSigToWitness(sig []byte) ([][]byte, error)
- func Verify(address btcutil.Address, message string, signatureDecoded []byte) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildToSignTx ¶
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 ¶
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 SimpleSigToWitness ¶
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 ¶
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.