nut11

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// supported tags
	SIGFLAG  = "sigflag"
	NSIGS    = "n_sigs"
	PUBKEYS  = "pubkeys"
	LOCKTIME = "locktime"
	REFUND   = "refund"

	// SIGFLAG types
	SIGINPUTS = "SIG_INPUTS"
	SIGALL    = "SIG_ALL"

	// Error code
	NUT11ErrCode cashu.CashuErrCode = 30001
)

Variables

View Source
var (
	InvalidTagErr            = cashu.Error{Detail: "invalid tag", Code: NUT11ErrCode}
	TooManyTagsErr           = cashu.Error{Detail: "too many tags", Code: NUT11ErrCode}
	NSigsMustBePositiveErr   = cashu.Error{Detail: "n_sigs must be a positive integer", Code: NUT11ErrCode}
	EmptyPubkeysErr          = cashu.Error{Detail: "pubkeys tag cannot be empty if n_sigs tag is present", Code: NUT11ErrCode}
	InvalidWitness           = cashu.Error{Detail: "invalid witness", Code: NUT11ErrCode}
	InvalidKindErr           = cashu.Error{Detail: "invalid kind in secret", Code: NUT11ErrCode}
	DuplicateSignaturesErr   = cashu.Error{Detail: "witness has duplicate signatures", Code: NUT11ErrCode}
	NotEnoughSignaturesErr   = cashu.Error{Detail: "not enough valid signatures provided", Code: NUT11ErrCode}
	NoSignaturesErr          = cashu.Error{Detail: "no signatures provided in witness", Code: NUT11ErrCode}
	AllSigAllFlagsErr        = cashu.Error{Detail: "all flags must be SIG_ALL", Code: NUT11ErrCode}
	SigAllKeysMustBeEqualErr = cashu.Error{Detail: "all public keys must be the same for SIG_ALL", Code: NUT11ErrCode}
	SigAllOnlySwap           = cashu.Error{Detail: "SIG_ALL can only be used in /swap operation", Code: NUT11ErrCode}
	NSigsMustBeEqualErr      = cashu.Error{Detail: "all n_sigs must be the same for SIG_ALL", Code: NUT11ErrCode}
)

NUT-11 specific errors

Functions

func AddSignatureToInputs

func AddSignatureToInputs(inputs cashu.Proofs, signingKey *btcec.PrivateKey) (cashu.Proofs, error)

func AddSignatureToOutputs

func AddSignatureToOutputs(
	outputs cashu.BlindedMessages,
	signingKey *btcec.PrivateKey,
) (cashu.BlindedMessages, error)

func CanSign

func CanSign(secret nut10.WellKnownSecret, key *btcec.PrivateKey) bool

func DuplicateSignatures added in v0.3.0

func DuplicateSignatures(signatures []string) bool

func HasValidSignatures added in v0.3.0

func HasValidSignatures(hash []byte, signatures []string, Nsigs int, pubkeys []*btcec.PublicKey) bool

func IsSigAll

func IsSigAll(secret nut10.WellKnownSecret) bool

func ParsePublicKey added in v0.3.0

func ParsePublicKey(key string) (*btcec.PublicKey, error)

func ParseSignature added in v0.3.0

func ParseSignature(signature string) (*schnorr.Signature, error)

func ProofsSigAll added in v0.3.0

func ProofsSigAll(proofs cashu.Proofs) bool

ProofsSigAll returns true if at least one of the proofs in the list has a SIG_ALL flag

func PublicKeys added in v0.3.0

func PublicKeys(secret nut10.WellKnownSecret) ([]*btcec.PublicKey, error)

PublicKeys returns a list of public keys that can sign a P2PK or HTLC proof

func SerializeP2PKTags added in v0.3.0

func SerializeP2PKTags(p2pkTags P2PKTags) [][]string

Types

type P2PKTags added in v0.3.0

type P2PKTags struct {
	Sigflag  string
	NSigs    int
	Pubkeys  []*btcec.PublicKey
	Locktime int64
	Refund   []*btcec.PublicKey
}

func ParseP2PKTags added in v0.3.0

func ParseP2PKTags(tags [][]string) (*P2PKTags, error)

type P2PKWitness

type P2PKWitness struct {
	Signatures []string `json:"signatures"`
}

Jump to

Keyboard shortcuts

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