Skip to content

Commit

Permalink
MuSig2 signing, rounds 1 and 2
Browse files Browse the repository at this point in the history
  • Loading branch information
bigspider committed May 28, 2024
1 parent 5ed718f commit 79855b9
Show file tree
Hide file tree
Showing 9 changed files with 1,358 additions and 70 deletions.
4 changes: 4 additions & 0 deletions src/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ typedef enum {
GET_MASTER_FINGERPRINT = 0x05,
SIGN_MESSAGE = 0x10,
} command_e;

// Tags used when yielding different objects with the YIELD client command.
#define CCMD_YIELD_MUSIG_PUBNONCE_TAG 0xffffffff
#define CCMD_YIELD_MUSIG_PARTIALSIGNATURE_TAG 0xfffffffe
2 changes: 1 addition & 1 deletion src/handler/lib/policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ execute_processor(policy_parser_state_t *state, policy_parser_processor_t proc,

// convenience function, split from get_derived_pubkey only to improve stack usage
// returns -1 on error, 0 if the returned key info has no wildcard (**), 1 if it has the wildcard
__attribute__((noinline, warn_unused_result)) static int get_extended_pubkey(
__attribute__((noinline, warn_unused_result)) int get_extended_pubkey(
dispatcher_context_t *dispatcher_context,
const wallet_derivation_info_t *wdi,
int key_index,
Expand Down
23 changes: 23 additions & 0 deletions src/handler/lib/policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,29 @@ typedef struct {
bool change; // whether a change address or a receive address is derived
} wallet_derivation_info_t;

/**
* Computes the a derived compressed pubkey for one of the key of the wallet policy,
* for a given change/address_index combination.
*
* This function computes the extended public key (xpub) based on the provided
* BIP32 derivation path. It supports both standard BIP32 derivation and
* the derivation of Musig (multi-signature) keys.
*
* @param[in] dispatcher_context Pointer to the dispatcher content
* @param[in] wdi Pointer to a `wallet_derivation_info_t` struct with the details of the
* necessary details of the wallet policy, and the desired change/address_index pair.
* @param[in] key_index Index of the pubkey in the vector of keys of the wallet policy.
* @param[out] out Pointer to a `serialized_extended_pubkey_t` that will contain the requested
* extended pubkey.
*
* @return -1 on error, 0 if the returned key info has no wildcard (**), 1 if it has the wildcard.
*/
__attribute__((warn_unused_result)) int get_extended_pubkey(
dispatcher_context_t *dispatcher_context,
const wallet_derivation_info_t *wdi,
int key_index,
serialized_extended_pubkey_t *out);

/**
* Computes the hash of a taptree, to be used as tweak for the internal key per BIP-0341;
* The returned hash is the second value in the tuple returned by taproot_tree_helper in
Expand Down
609 changes: 543 additions & 66 deletions src/handler/sign_psbt.c

Large diffs are not rendered by default.

Loading

0 comments on commit 79855b9

Please sign in to comment.