Skip to content

Commit

Permalink
encpedpop: Move and rename plaintext/ciphertext args
Browse files Browse the repository at this point in the history
  • Loading branch information
real-or-random committed Oct 18, 2024
1 parent 3e7631b commit c3e4546
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion python/chilldkg_ref/chilldkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,9 +658,9 @@ def recover(
hostseckey,
hostpubkeys[idx],
pubnonces,
enc_secshares[idx],
enc_context,
idx,
enc_secshares[idx],
)

# This is just a sanity check. Our signature is valid, so we have done
Expand Down
12 changes: 7 additions & 5 deletions python/chilldkg_ref/encpedpop.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ def encrypt_multi(
pubnonce: bytes,
deckey: bytes,
enckeys: List[bytes],
messages: List[Scalar],
context: bytes,
idx: int,
plaintexts: List[Scalar],
) -> List[Scalar]:
pads = encaps_multi(secnonce, pubnonce, deckey, enckeys, context, idx)
ciphertexts = [message + pad for message, pad in zip(messages, pads, strict=True)]
ciphertexts = [
plaintext + pad for plaintext, pad in zip(plaintexts, pads, strict=True)
]
return ciphertexts


Expand Down Expand Up @@ -114,9 +116,9 @@ def decrypt_sum(
deckey: bytes,
enckey: bytes,
pubnonces: List[bytes],
sum_ciphertexts: Scalar,
context: bytes,
idx: int,
sum_ciphertexts: Scalar,
) -> Scalar:
if idx >= len(pubnonces):
raise IndexError
Expand Down Expand Up @@ -194,7 +196,7 @@ def participant_step1(
assert len(shares) == n

enc_shares = encrypt_multi(
secnonce, pubnonce, deckey, enckeys, shares, enc_context, idx
secnonce, pubnonce, deckey, enckeys, enc_context, idx, shares
)

pmsg = ParticipantMsg(simpl_pmsg, pubnonce, enc_shares)
Expand All @@ -217,7 +219,7 @@ def participant_step2(

enc_context = serialize_enc_context(simpl_state.t, enckeys)
secshare = decrypt_sum(
deckey, enckeys[idx], pubnonces, enc_secshare, enc_context, idx
deckey, enckeys[idx], pubnonces, enc_context, idx, enc_secshare
)
dkg_output, eq_input = simplpedpop.participant_step2(
simpl_state, simpl_cmsg, secshare
Expand Down

0 comments on commit c3e4546

Please sign in to comment.