Skip to content

fix(tally): fix shared default ciphertext in tally selection#810

Open
mdevolde wants to merge 1 commit intoElection-Tech-Initiative:mainfrom
mdevolde:fix/tally-default-factory
Open

fix(tally): fix shared default ciphertext in tally selection#810
mdevolde wants to merge 1 commit intoElection-Tech-Initiative:mainfrom
mdevolde:fix/tally-default-factory

Conversation

@mdevolde
Copy link

Issue

Fixes #809

Description

This change updates CiphertextTallySelection.ciphertext to use default_factory instead of a shared ElGamalCiphertext instance as a dataclass field default. That ensures each CiphertextTallySelection gets its own ciphertext value rather than sharing the same default object across instances.

The behavior avoids unintended shared state if the default ciphertext is ever mutated in place, and also resolves the dataclass validation error raised by Python 3.11 for mutable defaults.

I ran the tests locally: poetry run pytest tests/unit, poetry run pytest tests/property, poetry run pytest tests/integration (on python 3.9.21, on windows 11). I built the project with poetry build on the same environment.

Testing

Run the relevant tally-related test suites with:

poetry run pytest tests/unit/electionguard
poetry run pytest tests/property/test_tally.py

These validate that CiphertextTallySelection still behaves correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐞 CiphertextTallySelection uses a shared default ElGamalCiphertext instance

1 participant