Skip to content

Commit

Permalink
python: Various nits
Browse files Browse the repository at this point in the history
  • Loading branch information
real-or-random committed Oct 25, 2024
1 parent 1a2dd1b commit 01a1827
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
15 changes: 10 additions & 5 deletions python/chilldkg_ref/encpedpop.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def decrypt_sum(
if idx >= len(pubnonces):
raise IndexError
context_ = idx.to_bytes(4, byteorder="big") + context
secshare = sum_ciphertexts
sum_plaintexts = sum_ciphertexts
for i, pubnonce in enumerate(pubnonces):
if i == idx:
pad = self_pad(deckey, context_)
Expand All @@ -106,8 +106,8 @@ def decrypt_sum(
context=context_,
sending=False,
)
secshare = secshare - pad
return secshare
sum_plaintexts = sum_plaintexts - pad
return sum_plaintexts


###
Expand Down Expand Up @@ -243,5 +243,10 @@ def coordinator_step(
# in encpedpop.CoordinatorMsg, but only return it as a side output, so that
# chilldkg.coordinator_step can pick it up. Implementations of pure
# EncPedPop will need to decide how to transmit enc_secshares[i] to
# participant i; we leave this unspecified.
return CoordinatorMsg(simpl_cmsg, pubnonces), dkg_output, eq_input, enc_secshares
# participant i for participant_step2(); we leave this unspecified.
return (
CoordinatorMsg(simpl_cmsg, pubnonces),
dkg_output,
eq_input,
enc_secshares,
)
12 changes: 5 additions & 7 deletions python/chilldkg_ref/simplpedpop.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,17 +171,15 @@ def coordinator_step(
) -> Tuple[CoordinatorMsg, DKGOutput, bytes]:
# Sum the commitments to the i-th coefficients for i > 0
#
# This procedure is introduced by Pedersen in Section 5.1 of
# 'Non-Interactive and Information-Theoretic Secure Verifiable Secret
# Sharing'.
#
# We cannot sum the commitments to the secrets (i == 0) because they'll be
# necessary to check the pops.
# This procedure corresponds to the one described by Pedersen in Section 5.1
# of "Non-Interactive and Information-Theoretic Secure Verifiable Secret
# Sharing". However, we don't sum the commitments to the secrets (i == 0)
# because they'll be necessary to check the pops.
coms_to_secrets = [pmsg.com.commitment_to_secret() for pmsg in pmsgs]
# But we can sum the commitments to the non-constant terms.
sum_coms_to_nonconst_terms = [
GE.sum(*(pmsg.com.commitment_to_nonconst_terms()[j] for pmsg in pmsgs))
for j in range(0, t - 1)
for j in range(t - 1)
]
pops = [pmsg.pop for pmsg in pmsgs]
cmsg = CoordinatorMsg(coms_to_secrets, sum_coms_to_nonconst_terms, pops)
Expand Down
3 changes: 2 additions & 1 deletion python/chilldkg_ref/vss.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def secshare_for(self, i: int) -> Scalar:
# Return the secret share for the participant with index i.
#
# This computes f(i+1).

if i < 0:
raise ValueError(f"Invalid participant index: {i}")
x = Scalar(i + 1)
# Ensure we don't compute f(0), which is the secret.
assert x != Scalar(0)
Expand Down

0 comments on commit 01a1827

Please sign in to comment.