Bitcoin Core 31.99.0
P2P Digital Currency
Classes | Functions | Variables
musig.cpp File Reference
#include <musig.h>
#include <key.h>
#include <random.h>
#include <support/allocators/secure.h>
#include <secp256k1_musig.h>
Include dependency graph for musig.cpp:

Go to the source code of this file.

Classes

class  MuSig2SecNonceImpl
 

Functions

static bool GetMuSig2KeyAggCache (const std::vector< CPubKey > &pubkeys, secp256k1_musig_keyagg_cache &keyagg_cache)
 
static std::optional< CPubKeyGetCPubKeyFromMuSig2KeyAggCache (secp256k1_musig_keyagg_cache &keyagg_cache)
 
std::optional< CPubKeyMuSig2AggregatePubkeys (const std::vector< CPubKey > &pubkeys, secp256k1_musig_keyagg_cache &keyagg_cache, const std::optional< CPubKey > &expected_aggregate)
 Compute the full aggregate pubkey from the given participant pubkeys in their current order. More...
 
std::optional< CPubKeyMuSig2AggregatePubkeys (const std::vector< CPubKey > &pubkeys)
 
CExtPubKey CreateMuSig2SyntheticXpub (const CPubKey &pubkey)
 Construct the BIP 328 synthetic xpub for a pubkey. More...
 
uint256 MuSig2SessionID (const CPubKey &script_pubkey, const CPubKey &part_pubkey, const uint256 &sighash, const std::vector< uint8_t > &pubnonce)
 Computes an arbitrary unique session ID to identify ongoing signing sessions. More...
 
std::vector< uint8_t > CreateMuSig2Nonce (MuSig2SecNonce &secnonce, const uint256 &sighash, const CKey &our_seckey, const CPubKey &aggregate_pubkey, const std::vector< CPubKey > &pubkeys)
 
std::optional< uint256CreateMuSig2PartialSig (const uint256 &sighash, const CKey &our_seckey, const CPubKey &aggregate_pubkey, const std::vector< CPubKey > &pubkeys, const std::map< CPubKey, std::vector< uint8_t > > &pubnonces, MuSig2SecNonce &secnonce, const std::vector< std::pair< uint256, bool > > &tweaks)
 
std::optional< std::vector< uint8_t > > CreateMuSig2AggregateSig (const std::vector< CPubKey > &part_pubkeys, const CPubKey &aggregate_pubkey, const std::vector< std::pair< uint256, bool > > &tweaks, const uint256 &sighash, const std::map< CPubKey, std::vector< uint8_t > > &pubnonces, const std::map< CPubKey, uint256 > &partial_sigs)
 

Variables

const ChainCode MUSIG_CHAINCODE {"868087ca02a6f974c4598924c36b57762d32cb45717167e300622c7167e38965"_hex_u8}
 

Function Documentation

◆ CreateMuSig2AggregateSig()

std::optional< std::vector< uint8_t > > CreateMuSig2AggregateSig ( const std::vector< CPubKey > &  part_pubkeys,
const CPubKey aggregate_pubkey,
const std::vector< std::pair< uint256, bool > > &  tweaks,
const uint256 sighash,
const std::map< CPubKey, std::vector< uint8_t > > &  pubnonces,
const std::map< CPubKey, uint256 > &  partial_sigs 
)

Definition at line 254 of file musig.cpp.

Here is the call graph for this function:

◆ CreateMuSig2Nonce()

std::vector< uint8_t > CreateMuSig2Nonce ( MuSig2SecNonce secnonce,
const uint256 sighash,
const CKey our_seckey,
const CPubKey aggregate_pubkey,
const std::vector< CPubKey > &  pubkeys 
)

Definition at line 132 of file musig.cpp.

Here is the call graph for this function:

◆ CreateMuSig2PartialSig()

std::optional< uint256 > CreateMuSig2PartialSig ( const uint256 sighash,
const CKey our_seckey,
const CPubKey aggregate_pubkey,
const std::vector< CPubKey > &  pubkeys,
const std::map< CPubKey, std::vector< uint8_t > > &  pubnonces,
MuSig2SecNonce secnonce,
const std::vector< std::pair< uint256, bool > > &  tweaks 
)

Definition at line 165 of file musig.cpp.

Here is the call graph for this function:

◆ CreateMuSig2SyntheticXpub()

CExtPubKey CreateMuSig2SyntheticXpub ( const CPubKey pubkey)

Construct the BIP 328 synthetic xpub for a pubkey.

Definition at line 74 of file musig.cpp.

Here is the caller graph for this function:

◆ GetCPubKeyFromMuSig2KeyAggCache()

static std::optional< CPubKey > GetCPubKeyFromMuSig2KeyAggCache ( secp256k1_musig_keyagg_cache keyagg_cache)
static

Definition at line 42 of file musig.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMuSig2KeyAggCache()

static bool GetMuSig2KeyAggCache ( const std::vector< CPubKey > &  pubkeys,
secp256k1_musig_keyagg_cache keyagg_cache 
)
static

Definition at line 16 of file musig.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MuSig2AggregatePubkeys() [1/2]

std::optional< CPubKey > MuSig2AggregatePubkeys ( const std::vector< CPubKey > &  pubkeys)

Definition at line 68 of file musig.cpp.

Here is the call graph for this function:

◆ MuSig2AggregatePubkeys() [2/2]

std::optional< CPubKey > MuSig2AggregatePubkeys ( const std::vector< CPubKey > &  pubkeys,
secp256k1_musig_keyagg_cache keyagg_cache,
const std::optional< CPubKey > &  expected_aggregate 
)

Compute the full aggregate pubkey from the given participant pubkeys in their current order.

Outputs the secp256k1_musig_keyagg_cache and validates that the computed aggregate pubkey matches an expected aggregate pubkey. This is necessary for most MuSig2 operations.

Definition at line 57 of file musig.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MuSig2SessionID()

uint256 MuSig2SessionID ( const CPubKey script_pubkey,
const CPubKey part_pubkey,
const uint256 sighash,
const std::vector< uint8_t > &  pubnonce 
)

Computes an arbitrary unique session ID to identify ongoing signing sessions.

It is the SHA256 of the aggregate xonly key, the participant pubkey, the sighash, and the pubnonce

Definition at line 125 of file musig.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ MUSIG_CHAINCODE

const ChainCode MUSIG_CHAINCODE {"868087ca02a6f974c4598924c36b57762d32cb45717167e300622c7167e38965"_hex_u8}

Definition at line 14 of file musig.cpp.