[#CreateMuSig2AggregateSig]
= CreateMuSig2AggregateSig
:mrdocs:

Combine the participants&apos; partial signatures into a final MuSig2 aggregate signature&period;

== Synopsis

Declared in `&lt;musig&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
std::optional&lt;std::vector&lt;uint8&lowbar;t&gt;&gt;
CreateMuSig2AggregateSig(
    std::vector&lt;CPubKey&gt; const& participants,
    xref:CPubKey.adoc[CPubKey] const& aggregate&lowbar;pubkey,
    std::vector&lt;std::pair&lt;uint256, bool&gt;&gt; const& tweaks,
    xref:uint256.adoc[uint256] const& sighash,
    std::map&lt;CPubKey, std::vector&lt;uint8&lowbar;t&gt;&gt; const& pubnonces,
    std::map&lt;CPubKey, uint256&gt; const& partial&lowbar;sigs);
----

== Return Value

The final aggregate signature, or std&colon;&colon;nullopt if combining fails&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *participants*
| The participant public keys, in aggregation order&period;
| *aggregate&lowbar;pubkey*
| The aggregate public key of all participants&period;
| *tweaks*
| The tweaks to apply to the aggregate key, each with a flag selecting x&hyphen;only or ordinary tweaking&period;
| *sighash*
| The signature hash being signed&period;
| *pubnonces*
| The public nonces from all participants, keyed by public key&period;
| *partial&lowbar;sigs*
| The partial signatures from all participants, keyed by public key&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
