Skip to content

Commit 8ef8bc7

Browse files
simplpedpop: Move group addition to error path
1 parent 51984ce commit 8ef8bc7

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

python/chilldkg_ref/simplpedpop.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -202,20 +202,24 @@ def participant_step2(
202202
)
203203

204204
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+
# Verifying the tweaked secshare against the tweaked pubshare is equivalent
206+
# to verifying the untweaked secshare against the untweaked pubshare, but
207+
# avoids computing the untweaked pubshare in the happy path and thereby
208+
# moves a group addition to the error path.
209+
sum_coms_tweaked, tweak, pubtweak = sum_coms.invalid_taproot_commit()
210+
pubshare_tweaked = sum_coms_tweaked.pubshare(idx)
211+
secshare_tweaked = secshare + tweak
212+
if not VSSCommitment.verify_secshare(secshare_tweaked, pubshare_tweaked):
213+
pubshare = pubshare_tweaked - pubtweak
207214
raise UnknownFaultyParticipantOrCoordinatorError(
208215
ParticipantInvestigationData(n, idx, secshare, pubshare),
209216
"Received invalid secshare, "
210217
"consider investigation procedure to determine faulty party",
211218
)
212219

213-
sum_coms_tweaked, tweak, pubshare_tweak = sum_coms.invalid_taproot_commit()
214-
secshare_tweaked = secshare + tweak
215220
threshold_pubkey = sum_coms_tweaked.commitment_to_secret()
216221
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)
219223
]
220224
dkg_output = DKGOutput(
221225
secshare_tweaked.to_bytes(),

0 commit comments

Comments
 (0)