99#include < addresstype.h>
1010#include < attributes.h>
1111#include < key.h>
12+ #include < musig.h>
1213#include < pubkey.h>
1314#include < script/keyorigin.h>
1415#include < script/script.h>
1516#include < sync.h>
1617
18+ #include < functional>
19+ #include < optional>
20+
1721struct ShortestVectorFirstComparator
1822{
1923 bool operator ()(const std::vector<unsigned char >& a, const std::vector<unsigned char >& b) const
@@ -162,6 +166,9 @@ class SigningProvider
162166 virtual bool GetTaprootSpendData (const XOnlyPubKey& output_key, TaprootSpendData& spenddata) const { return false ; }
163167 virtual bool GetTaprootBuilder (const XOnlyPubKey& output_key, TaprootBuilder& builder) const { return false ; }
164168 virtual std::vector<CPubKey> GetMuSig2ParticipantPubkeys (const CPubKey& pubkey) const { return {}; }
169+ virtual void SetMuSig2SecNonce (const uint256& id, MuSig2SecNonce&& nonce) const {}
170+ virtual std::optional<std::reference_wrapper<MuSig2SecNonce>> GetMuSig2SecNonce (const uint256& session_id) const { return std::nullopt ; }
171+ virtual void DeleteMuSig2Session (const uint256& session_id) const {}
165172
166173 bool GetKeyByXOnly (const XOnlyPubKey& pubkey, CKey& key) const
167174 {
@@ -206,6 +213,9 @@ class HidingSigningProvider : public SigningProvider
206213 bool GetTaprootSpendData (const XOnlyPubKey& output_key, TaprootSpendData& spenddata) const override ;
207214 bool GetTaprootBuilder (const XOnlyPubKey& output_key, TaprootBuilder& builder) const override ;
208215 std::vector<CPubKey> GetMuSig2ParticipantPubkeys (const CPubKey& pubkey) const override ;
216+ void SetMuSig2SecNonce (const uint256& id, MuSig2SecNonce&& nonce) const override ;
217+ std::optional<std::reference_wrapper<MuSig2SecNonce>> GetMuSig2SecNonce (const uint256& session_id) const override ;
218+ void DeleteMuSig2Session (const uint256& session_id) const override ;
209219};
210220
211221struct FlatSigningProvider final : public SigningProvider
@@ -216,6 +226,7 @@ struct FlatSigningProvider final : public SigningProvider
216226 std::map<CKeyID, CKey> keys;
217227 std::map<XOnlyPubKey, TaprootBuilder> tr_trees; /* * Map from output key to Taproot tree (which can then make the TaprootSpendData */
218228 std::map<CPubKey, std::vector<CPubKey>> aggregate_pubkeys; /* * MuSig2 aggregate pubkeys */
229+ std::map<uint256, MuSig2SecNonce>* musig2_secnonces{nullptr };
219230
220231 bool GetCScript (const CScriptID& scriptid, CScript& script) const override ;
221232 bool GetPubKey (const CKeyID& keyid, CPubKey& pubkey) const override ;
@@ -225,6 +236,9 @@ struct FlatSigningProvider final : public SigningProvider
225236 bool GetTaprootSpendData (const XOnlyPubKey& output_key, TaprootSpendData& spenddata) const override ;
226237 bool GetTaprootBuilder (const XOnlyPubKey& output_key, TaprootBuilder& builder) const override ;
227238 std::vector<CPubKey> GetMuSig2ParticipantPubkeys (const CPubKey& pubkey) const override ;
239+ void SetMuSig2SecNonce (const uint256& id, MuSig2SecNonce&& nonce) const override ;
240+ std::optional<std::reference_wrapper<MuSig2SecNonce>> GetMuSig2SecNonce (const uint256& session_id) const override ;
241+ void DeleteMuSig2Session (const uint256& session_id) const override ;
228242
229243 FlatSigningProvider& Merge (FlatSigningProvider&& b) LIFETIMEBOUND;
230244};
0 commit comments