Skip to content

Commit 8ecea91

Browse files
committed
sign: Add GetMuSig2ParticipantPubkeys to SigningProvider
1 parent fac0ee0 commit 8ecea91

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/script/signingprovider.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ bool HidingSigningProvider::GetTaprootBuilder(const XOnlyPubKey& output_key, Tap
5252
{
5353
return m_provider->GetTaprootBuilder(output_key, builder);
5454
}
55+
std::vector<CPubKey> HidingSigningProvider::GetMuSig2ParticipantPubkeys(const CPubKey& pubkey) const
56+
{
57+
if (m_hide_origin) return {};
58+
return m_provider->GetMuSig2ParticipantPubkeys(pubkey);
59+
}
5560

5661
bool FlatSigningProvider::GetCScript(const CScriptID& scriptid, CScript& script) const { return LookupHelper(scripts, scriptid, script); }
5762
bool FlatSigningProvider::GetPubKey(const CKeyID& keyid, CPubKey& pubkey) const { return LookupHelper(pubkeys, keyid, pubkey); }
@@ -82,13 +87,21 @@ bool FlatSigningProvider::GetTaprootBuilder(const XOnlyPubKey& output_key, Tapro
8287
return LookupHelper(tr_trees, output_key, builder);
8388
}
8489

90+
std::vector<CPubKey> FlatSigningProvider::GetMuSig2ParticipantPubkeys(const CPubKey& pubkey) const
91+
{
92+
std::vector<CPubKey> participant_pubkeys;
93+
LookupHelper(aggregate_pubkeys, pubkey, participant_pubkeys);
94+
return participant_pubkeys;
95+
}
96+
8597
FlatSigningProvider& FlatSigningProvider::Merge(FlatSigningProvider&& b)
8698
{
8799
scripts.merge(b.scripts);
88100
pubkeys.merge(b.pubkeys);
89101
keys.merge(b.keys);
90102
origins.merge(b.origins);
91103
tr_trees.merge(b.tr_trees);
104+
aggregate_pubkeys.merge(b.aggregate_pubkeys);
92105
return *this;
93106
}
94107

src/script/signingprovider.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ class SigningProvider
161161
virtual bool GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const { return false; }
162162
virtual bool GetTaprootSpendData(const XOnlyPubKey& output_key, TaprootSpendData& spenddata) const { return false; }
163163
virtual bool GetTaprootBuilder(const XOnlyPubKey& output_key, TaprootBuilder& builder) const { return false; }
164+
virtual std::vector<CPubKey> GetMuSig2ParticipantPubkeys(const CPubKey& pubkey) const { return {}; }
164165

165166
bool GetKeyByXOnly(const XOnlyPubKey& pubkey, CKey& key) const
166167
{
@@ -204,6 +205,7 @@ class HidingSigningProvider : public SigningProvider
204205
bool GetKeyOrigin(const CKeyID& keyid, KeyOriginInfo& info) const override;
205206
bool GetTaprootSpendData(const XOnlyPubKey& output_key, TaprootSpendData& spenddata) const override;
206207
bool GetTaprootBuilder(const XOnlyPubKey& output_key, TaprootBuilder& builder) const override;
208+
std::vector<CPubKey> GetMuSig2ParticipantPubkeys(const CPubKey& pubkey) const override;
207209
};
208210

209211
struct FlatSigningProvider final : public SigningProvider
@@ -213,6 +215,7 @@ struct FlatSigningProvider final : public SigningProvider
213215
std::map<CKeyID, std::pair<CPubKey, KeyOriginInfo>> origins;
214216
std::map<CKeyID, CKey> keys;
215217
std::map<XOnlyPubKey, TaprootBuilder> tr_trees; /** Map from output key to Taproot tree (which can then make the TaprootSpendData */
218+
std::map<CPubKey, std::vector<CPubKey>> aggregate_pubkeys; /** MuSig2 aggregate pubkeys */
216219

217220
bool GetCScript(const CScriptID& scriptid, CScript& script) const override;
218221
bool GetPubKey(const CKeyID& keyid, CPubKey& pubkey) const override;
@@ -221,6 +224,7 @@ struct FlatSigningProvider final : public SigningProvider
221224
bool GetKey(const CKeyID& keyid, CKey& key) const override;
222225
bool GetTaprootSpendData(const XOnlyPubKey& output_key, TaprootSpendData& spenddata) const override;
223226
bool GetTaprootBuilder(const XOnlyPubKey& output_key, TaprootBuilder& builder) const override;
227+
std::vector<CPubKey> GetMuSig2ParticipantPubkeys(const CPubKey& pubkey) const override;
224228

225229
FlatSigningProvider& Merge(FlatSigningProvider&& b) LIFETIMEBOUND;
226230
};

0 commit comments

Comments
 (0)