Bitcoin Core 30.99.0
P2P Digital Currency
musig.h
Go to the documentation of this file.
1// Copyright (c) 2024-present The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or https://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_MUSIG_H
6#define BITCOIN_MUSIG_H
7
8#include <pubkey.h>
9
10#include <optional>
11#include <vector>
12
16
17constexpr size_t MUSIG2_PUBNONCE_SIZE{66};
18
22std::optional<CPubKey> MuSig2AggregatePubkeys(const std::vector<CPubKey>& pubkeys, secp256k1_musig_keyagg_cache& keyagg_cache, const std::optional<CPubKey>& expected_aggregate);
23std::optional<CPubKey> MuSig2AggregatePubkeys(const std::vector<CPubKey>& pubkeys);
24
27
40{
41private:
42 std::unique_ptr<MuSig2SecNonceImpl> m_impl;
43
44public:
47 MuSig2SecNonce& operator=(MuSig2SecNonce&&) noexcept;
49
50 // Delete copy constructors
52 MuSig2SecNonce& operator=(const MuSig2SecNonce&) = delete;
53
55 void Invalidate();
56 bool IsValid();
57};
58
59uint256 MuSig2SessionID(const CPubKey& script_pubkey, const CPubKey& part_pubkey, const uint256& sighash);
60
61std::optional<std::vector<uint8_t>> CreateMuSig2AggregateSig(const std::vector<CPubKey>& participants, 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);
62
63#endif // BITCOIN_MUSIG_H
An encapsulated public key.
Definition: pubkey.h:34
MuSig2SecNonce encapsulates a secret nonce in use in a MuSig2 signing session.
Definition: musig.h:40
void Invalidate()
Definition: musig.cpp:112
bool IsValid()
Definition: musig.cpp:117
secp256k1_musig_secnonce * Get() const
Definition: musig.cpp:107
std::unique_ptr< MuSig2SecNonceImpl > m_impl
Definition: musig.h:42
MuSig2SecNonce(MuSig2SecNonce &&) noexcept
256-bit opaque blob.
Definition: uint256.h:195
CExtPubKey CreateMuSig2SyntheticXpub(const CPubKey &pubkey)
Construct the BIP 328 synthetic xpub for a pubkey.
Definition: musig.cpp:71
constexpr size_t MUSIG2_PUBNONCE_SIZE
Definition: musig.h:17
uint256 MuSig2SessionID(const CPubKey &script_pubkey, const CPubKey &part_pubkey, const uint256 &sighash)
Definition: musig.cpp:122
std::optional< std::vector< uint8_t > > CreateMuSig2AggregateSig(const std::vector< CPubKey > &participants, 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: musig.cpp:129
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.
Definition: musig.cpp:54
This module implements BIP 327 "MuSig2 for BIP340-compatible Multi-Signatures" (https://github....
Opaque data structure that holds a signer's secret nonce.