2
2
from typing import List , NamedTuple , NewType , Tuple , Optional , NoReturn
3
3
4
4
from secp256k1proto .bip340 import schnorr_sign , schnorr_verify
5
- from secp256k1proto .secp256k1 import GE , Scalar
5
+ from secp256k1proto .secp256k1 import G , GE , Scalar
6
6
from .util import (
7
7
BIP_TAG ,
8
8
SecretKeyError ,
@@ -112,6 +112,7 @@ class ParticipantBlameState(NamedTuple):
112
112
n : int
113
113
idx : int
114
114
secshare : Scalar
115
+ secshare_tweak : Scalar
115
116
pubshare : GE
116
117
117
118
@@ -204,16 +205,20 @@ def participant_step2(
204
205
i , "Participant sent invalid proof-of-knowledge"
205
206
)
206
207
sum_coms = assemble_sum_coms (coms_to_secrets , sum_coms_to_nonconst_terms )
207
- threshold_pubkey = sum_coms .commitment_to_secret ()
208
- pubshare = sum_coms .pubshare (idx )
208
+ sum_coms_tweaked , secshare_tweak = sum_coms .invalid_taproot_commit ()
209
+ secshare += secshare_tweak
210
+ threshold_pubkey = sum_coms_tweaked .commitment_to_secret ()
211
+ pubshare = sum_coms_tweaked .pubshare (idx )
209
212
210
213
if not VSSCommitment .verify_secshare (secshare , pubshare ):
211
214
raise UnknownFaultyParticipantOrCoordinatorError (
212
- ParticipantBlameState (n , idx , secshare , pubshare ),
215
+ ParticipantBlameState (n , idx , secshare , secshare_tweak , pubshare ),
213
216
"Received invalid secshare, consider blaming to determine faulty party" ,
214
217
)
215
218
216
- pubshares = [sum_coms .pubshare (i ) if i != idx else pubshare for i in range (n )]
219
+ pubshares = [
220
+ sum_coms_tweaked .pubshare (i ) if i != idx else pubshare for i in range (n )
221
+ ]
217
222
dkg_output = DKGOutput (
218
223
secshare .to_bytes (),
219
224
threshold_pubkey .to_bytes_compressed (),
@@ -228,13 +233,13 @@ def participant_blame(
228
233
cblame : CoordinatorBlameMsg ,
229
234
partial_secshares : List [Scalar ],
230
235
) -> NoReturn :
231
- n , idx , secshare , pubshare = blame_state
236
+ n , idx , secshare , secshare_tweak , pubshare = blame_state
232
237
partial_pubshares = cblame .partial_pubshares
233
238
234
- if GE .sum (* partial_pubshares ) != pubshare :
239
+ if GE .sum (* partial_pubshares ) + secshare_tweak * G != pubshare :
235
240
raise FaultyCoordinatorError ("Sum of partial pubshares not equal to pubshare" )
236
241
237
- if Scalar .sum (* partial_secshares ) != secshare :
242
+ if Scalar .sum (* partial_secshares ) + secshare_tweak != secshare :
238
243
raise SecshareSumError ("Sum of partial secshares not equal to secshare" )
239
244
240
245
for i in range (n ):
@@ -286,8 +291,9 @@ def coordinator_step(
286
291
cmsg = CoordinatorMsg (coms_to_secrets , sum_coms_to_nonconst_terms , pops )
287
292
288
293
sum_coms = assemble_sum_coms (coms_to_secrets , sum_coms_to_nonconst_terms )
289
- threshold_pubkey = sum_coms .commitment_to_secret ()
290
- pubshares = [sum_coms .pubshare (i ) for i in range (n )]
294
+ sum_coms_tweaked , secshare_tweak = sum_coms .invalid_taproot_commit ()
295
+ threshold_pubkey = sum_coms_tweaked .commitment_to_secret ()
296
+ pubshares = [sum_coms_tweaked .pubshare (i ) for i in range (n )]
291
297
292
298
dkg_output = DKGOutput (
293
299
None ,
0 commit comments