Skip to content

Comments on Python Code #89

@siv2r

Description

@siv2r

Most of these comments relate to improving error handling clarity in the reference implementation.

  • In hostpubkey_gen, currently a ValueError is raised when hostseckey is out of range. It would be clearer to wrap the pubkey_gen_plain call in a try-except block, catching the ValueError and raising a HostSeckeyError instead.
    • The participant_step1 function already follows a similar pattern.
  • In chilldkg.participant_step1, we should explicitly check if len(random) != 32 and raise a clear ValueError. Currently, this condition causes a crash because encpedpop.participant_step1 asserts it implicitly.
  • In chilldkg.participant_step2:
    • We should add checks for [1] "Host secret key does not match any host public key" and [2] hostseckey length (32 bytes), similar to those present in participant_step1.
      • This seems to have been overlooked, as the documentation indicates that step2 raises HostSeckeyError, but it doesn't currently do so.
    • The docstring also fails to mention the FaultyCoordinatorError.
  • The checks in simplepedpop.participant_step1 currently raise ValueError or IndexError. It might be more consistent to replace these with assert statements, similar to encpedpop.participant_step1.
  • certeq_verify raises a ValueError for an invalid certificate length, which callers (participant_finalize, coordinator_finalize, and recover) propagate directly. It would be clearer if these callers caught this ValueError and raised their own specific exceptions instead.
    • Also, the docstring of chilldkg.participant_finalize mentions raising FaultyCoordinatorError, but currently, this error is never actually raised. Implementing the above suggestion would resolve this discrepancy.
  • The docstring of chilldkg.participant_finalize currently misses mentioning the cmsg2 argument.
  • encpedpop.coordinator_step1 currently raises a FaultyParticipantOrCoordinatorError. Should it instead raise FaultyParticipantError?
    • Also, the docstring of chilldkg.coordinator_step1 does not currently mention this error.
  • The __all__ list in chilldkg.py is missing FaultyParticipantError and InvalidSignatureInCertificateError.
  • In encpedpop.participant_step2, the current code snippet:
    pads = decaps_multi(deckey, enckeys[idx], pubnonces, enc_context, idx)
    secshare = enc_secshare - Scalar.sum(*pads)

    can be simplified to:
    secshare = decrypt_sum(deckey, enckeys[idx], pubnonces, enc_context, idx, enc_secshare)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions