@@ -202,20 +202,24 @@ def participant_step2(
202
202
)
203
203
204
204
sum_coms = assemble_sum_coms (coms_to_secrets , sum_coms_to_nonconst_terms )
205
- pubshare = sum_coms .pubshare (idx )
206
- if not VSSCommitment .verify_secshare (secshare , pubshare ):
205
+ sum_coms_tweaked , tweak , pubtweak = sum_coms .invalid_taproot_commit ()
206
+ pubshare_tweaked = sum_coms_tweaked .pubshare (idx )
207
+ secshare_tweaked = secshare + tweak
208
+ # Verifying the tweaked secshare against the tweaked pubshare is equivalent
209
+ # to verifying the untweaked secshare against the untweaked pubshare, but
210
+ # avoids computing the untweaked pubshare in the happy path and thereby
211
+ # moves a group addition to the error path.
212
+ if not VSSCommitment .verify_secshare (secshare_tweaked , pubshare_tweaked ):
213
+ pubshare = pubshare_tweaked - pubtweak
207
214
raise UnknownFaultyParticipantOrCoordinatorError (
208
215
ParticipantInvestigationData (n , idx , secshare , pubshare ),
209
216
"Received invalid secshare, "
210
217
"consider investigation procedure to determine faulty party" ,
211
218
)
212
219
213
- sum_coms_tweaked , tweak , pubshare_tweak = sum_coms .invalid_taproot_commit ()
214
- secshare_tweaked = secshare + tweak
215
220
threshold_pubkey = sum_coms_tweaked .commitment_to_secret ()
216
221
pubshares = [
217
- sum_coms_tweaked .pubshare (i ) if i != idx else pubshare + pubshare_tweak
218
- for i in range (n )
222
+ sum_coms_tweaked .pubshare (i ) if i != idx else pubshare_tweaked for i in range (n )
219
223
]
220
224
dkg_output = DKGOutput (
221
225
secshare_tweaked .to_bytes (),
0 commit comments