Merge bitcoin/bitcoin#29675: wallet: Be able to receive and spend inputs involving MuSig2 aggregate keys
ac599c4a9ctest: Test MuSig2 in the wallet (Ava Chow)68ef954c4cwallet: Keep secnonces in DescriptorScriptPubKeyMan (Ava Chow)4a273edda0sign: Create MuSig2 signatures for known MuSig2 aggregate keys (Ava Chow)258db93889sign: Add CreateMuSig2AggregateSig (Ava Chow)bf69442b3fsign: Add CreateMuSig2PartialSig (Ava Chow)512b17fc56sign: Add CreateMuSig2Nonce (Ava Chow)82ea67c607musig: Add MuSig2AggregatePubkeys variant that validates the aggregate (Ava Chow)d99a081679psbt: MuSig2 data in Fill/FromSignatureData (Ava Chow)4d8b4f5336signingprovider: Add musig2 secnonces (Ava Chow)c06a1dc86fAdd MuSig2SecNonce class for secure allocation of musig nonces (Ava Chow)9baff05e49sign: Include taproot output key's KeyOriginInfo in sigdata (Ava Chow)4b24bfeab9pubkey: Return tweaks from BIP32 derivation (Ava Chow)f14876213amusig: Move synthetic xpub construction to its own function (Ava Chow)fb8720f1e0sign: Refactor Schnorr sighash computation out of CreateSchnorrSig (Ava Chow)a4cfddda64tests: Clarify why musig derivation adds a pubkey and xpub (Ava Chow)39a63bf2e7descriptors: Add a doxygen comment for has_hardened output_parameter (Ava Chow)2320184d0edescriptors: Fix meaning of any_key_parsed (Ava Chow) Pull request description: This PR implements MuSig2 signing so that the wallet can receive and spend from imported `musig(0` descriptors. The libsecp musig module is enabled so that it can be used for all of the MuSig2 cryptography. Secnonces are handled in a separate class which holds the libsecp secnonce object in a `secure_unique_ptr`. Since secnonces must not be used, this class has no serialization and will only live in memory. A restart of the software will require a restart of the MuSig2 signing process. ACKs for top commit: fjahr: tACKac599c4a9crkrux: lgtm tACKac599c4a9ctheStack: Code-review ACKac599c4a9c🗝️ Tree-SHA512: 626b9adc42ed2403e2f4405321eb9ce009a829c07d968e95ab288fe4940b195b0af35ca279a4a7fa51af76e55382bad6f63a23bca14a84140559b3c667e7041e
This commit is contained in:
18 files changed
+977
-48
No files matched your search
@@ -1256,6 +1256,10 @@ std::unique_ptr<FlatSigningProvider> DescriptorScriptPubKeyMan::GetSigningProvid
|
||||
FlatSigningProvider master_provider;
|
||||
master_provider.keys = GetKeys();
|
||||
m_wallet_descriptor.descriptor->ExpandPrivate(index, master_provider, *out_keys);
|
||||
|
||||
// Always include musig_secnonces as this descriptor may have a participant private key
|
||||
// but not a musig() descriptor
|
||||
out_keys->musig2_secnonces = &m_musig2_secnonces;
|
||||
}
|
||||
|
||||
return out_keys;
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <common/signmessage.h>
|
||||
#include <common/types.h>
|
||||
#include <logging.h>
|
||||
#include <musig.h>
|
||||
#include <node/types.h>
|
||||
#include <psbt.h>
|
||||
#include <script/descriptor.h>
|
||||
@@ -293,6 +294,19 @@ private:
|
||||
//! Number of pre-generated keys/scripts (part of the look-ahead process, used to detect payments)
|
||||
int64_t m_keypool_size GUARDED_BY(cs_desc_man){DEFAULT_KEYPOOL_SIZE};
|
||||
|
||||
/** Map of a session id to MuSig2 secnonce
|
||||
*
|
||||
* Stores MuSig2 secnonces while the MuSig2 signing session is still ongoing.
|
||||
* Note that these secnonces must not be reused. In order to avoid being tricked into
|
||||
* reusing a nonce, this map is held only in memory and must not be written to disk.
|
||||
* The side effect is that signing sessions cannot persist across restarts, but this
|
||||
* must be done in order to prevent nonce reuse.
|
||||
*
|
||||
* The session id is an arbitrary value set by the signer in order for the signing logic
|
||||
* to find ongoing signing sessions. It is the SHA256 of aggregate xonly key, + participant pubkey + sighash.
|
||||
*/
|
||||
mutable std::map<uint256, MuSig2SecNonce> m_musig2_secnonces;
|
||||
|
||||
bool AddDescriptorKeyWithDB(WalletBatch& batch, const CKey& key, const CPubKey &pubkey) EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);
|
||||
|
||||
KeyMap GetKeys() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);
|
||||
|
||||
Reference in new issue
Block a user