musig

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 7 Imported by: 0

README

CGo likes having all C files in the same folder as the go package that will use it. This can be avoided, but it requires building the lib ourselves. In the context of libwallet, that means cross compiling to iOS and Android targets, then selectively linking the proper one. Not exactly easy.

The alternative is then to flatten libsecp256k1 to a single folder. We can now use golangs include directives to use the headers we need. So far so good, right?

Wrong. The lib has a peculiar pattern of writing a lot of it's logic in .h files instead of .c files. CGo naturally only compiles .c files. To get around this, a new .c file is added: umbrella.c, which includes every source header we need. It's counterpart, umbrella.h includes every definition header we need to make things a bit easier to handle on Go's side.

Some things to keep in mind if you want to update libsecp. The script does it best job to make everything work, but it might fail if any details change in the lib. After executing it, review added files to see if they are relevant and remove them if not.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddUserSignatureAndCombine

func AddUserSignatureAndCombine(
	data [32]byte,
	userKey *btcec.PrivateKey,
	muunKey *btcec.PublicKey,
	rawMuunPartialSig [32]byte,
	rawMuunPubNonce [66]byte,
	sessionId [32]byte,
	customTweak []byte,
) ([64]byte, error)

AddUserSignatureAndCombine with partial muun signature.

func CombinePubKeysWithTweak

func CombinePubKeysWithTweak(userKey, muunKey *btcec.PublicKey, customTweak []byte) (*btcec.PublicKey, error)

func ComputeMuunPartialSignature

func ComputeMuunPartialSignature(
	data [32]byte,
	userKey *btcec.PublicKey,
	muunKey *btcec.PrivateKey,
	rawUserPubNonce [66]byte,
	sessionId [32]byte,
	customTweak []byte,
) ([32]byte, error)

func GeneratePubNonce

func GeneratePubNonce(sessionId [32]byte) [66]byte

GeneratePubNonce returns the pub nonce for a given session id

func RandomSessionId

func RandomSessionId() [32]byte

RandomSessionId returns a safe random session id. Session IDs must not be repeated otherwise private keys are compromised.

func VerifySignature

func VerifySignature(data [32]byte, signature [64]byte, pubKey *btcec.PublicKey) bool

VerifySignature checks a Schnorr signature.

Types

This section is empty.

Jump to

Keyboard shortcuts

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