Skip to content
This repository was archived by the owner on Jun 7, 2024. It is now read-only.

Commit f580546

Browse files
keithrfunglprichar
andauthored
♻️ Migrate Election Builder (Election-Tech-Initiative#674)
* ♻️ Migrate Election Builder * ♻️ Remove TODO to migrate Co-authored-by: Lee Richardson <[email protected]>
1 parent 505c902 commit f580546

File tree

11 files changed

+29
-18
lines changed

11 files changed

+29
-18
lines changed

src/electionguard/__init__.py

-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
from electionguard import decryption_share
1919
from electionguard import discrete_log
2020
from electionguard import election
21-
from electionguard import election_builder
2221
from electionguard import election_object_base
2322
from electionguard import election_polynomial
2423
from electionguard import elgamal
@@ -189,9 +188,6 @@
189188
Configuration,
190189
make_ciphertext_election_context,
191190
)
192-
from electionguard.election_builder import (
193-
ElectionBuilder,
194-
)
195191
from electionguard.election_object_base import (
196192
ElectionObjectBase,
197193
OrderedObjectBase,
@@ -468,7 +464,6 @@
468464
"ElGamalKeyPair",
469465
"ElGamalPublicKey",
470466
"ElGamalSecretKey",
471-
"ElectionBuilder",
472467
"ElectionConstants",
473468
"ElectionGuardLog",
474469
"ElectionJointKey",
@@ -609,7 +604,6 @@
609604
"div_p",
610605
"div_q",
611606
"election",
612-
"election_builder",
613607
"election_object_base",
614608
"election_polynomial",
615609
"elgamal",

src/electionguard_cli/cli_steps/election_builder_step.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
import click
33
from electionguard.elgamal import ElGamalPublicKey
44
from electionguard.group import ElementModQ
5-
from electionguard.election_builder import ElectionBuilder
65
from electionguard.utils import get_optional
6+
from electionguard_tools.helpers.election_builder import ElectionBuilder
77

88
from ..cli_models import CliElectionInputsBase, BuildElectionResults
99
from .cli_step_base import CliStepBase

src/electionguard_tools/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
DEVICE_PREFIX,
3030
ELECTION_RECORD_DIR,
3131
ENCRYPTED_TALLY_FILE_NAME,
32+
ElectionBuilder,
3233
GUARDIANS_DIR,
3334
GUARDIAN_PREFIX,
3435
KeyCeremonyOrchestrator,
@@ -43,6 +44,7 @@
4344
TALLY_FILE_NAME,
4445
TallyCeremonyOrchestrator,
4546
accumulate_plaintext_ballots,
47+
election_builder,
4648
export,
4749
export_private_data,
4850
export_record,
@@ -116,6 +118,7 @@
116118
"DEVICE_PREFIX",
117119
"ELECTION_RECORD_DIR",
118120
"ENCRYPTED_TALLY_FILE_NAME",
121+
"ElectionBuilder",
119122
"ElectionFactory",
120123
"ElectionSampleDataGenerator",
121124
"ElectionsAndBallotsTupleType",
@@ -146,6 +149,7 @@
146149
"contest_descriptions",
147150
"contest_descriptions_room_for_overvoting",
148151
"election",
152+
"election_builder",
149153
"election_descriptions",
150154
"election_factory",
151155
"election_types",

src/electionguard_tools/factories/election_factory.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
from electionguard.ballot import PlaintextBallot
1818
from electionguard.constants import ElectionConstants, get_constants
1919
from electionguard.election import CiphertextElectionContext
20-
from electionguard.election_builder import ElectionBuilder
2120
from electionguard.elgamal import ElGamalPublicKey
2221
from electionguard.encrypt import EncryptionDevice, contest_from, generate_device_uuid
2322
from electionguard.group import TWO_MOD_Q
@@ -48,6 +47,7 @@
4847
from electionguard_tools.helpers.key_ceremony_orchestrator import (
4948
KeyCeremonyOrchestrator,
5049
)
50+
from electionguard_tools.helpers.election_builder import ElectionBuilder
5151

5252

5353
_T = TypeVar("_T")

src/electionguard_tools/helpers/__init__.py

+6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
from electionguard_tools.helpers import election_builder
12
from electionguard_tools.helpers import export
23
from electionguard_tools.helpers import key_ceremony_orchestrator
34
from electionguard_tools.helpers import tally_accumulate
45
from electionguard_tools.helpers import tally_ceremony_orchestrator
56

7+
from electionguard_tools.helpers.election_builder import (
8+
ElectionBuilder,
9+
)
610
from electionguard_tools.helpers.export import (
711
CIPHERTEXT_BALLOT_PREFIX,
812
COEFFICIENTS_FILE_NAME,
@@ -45,6 +49,7 @@
4549
"DEVICE_PREFIX",
4650
"ELECTION_RECORD_DIR",
4751
"ENCRYPTED_TALLY_FILE_NAME",
52+
"ElectionBuilder",
4853
"GUARDIANS_DIR",
4954
"GUARDIAN_PREFIX",
5055
"KeyCeremonyOrchestrator",
@@ -59,6 +64,7 @@
5964
"TALLY_FILE_NAME",
6065
"TallyCeremonyOrchestrator",
6166
"accumulate_plaintext_ballots",
67+
"election_builder",
6268
"export",
6369
"export_private_data",
6470
"export_record",

src/electionguard/election_builder.py renamed to src/electionguard_tools/helpers/election_builder.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,20 @@
55

66
from electionguard.elgamal import ElGamalPublicKey
77

8-
from .election import CiphertextElectionContext, make_ciphertext_election_context
9-
from .group import ElementModQ
10-
from .manifest import Manifest, InternalManifest
11-
from .utils import get_optional
8+
from electionguard.election import (
9+
CiphertextElectionContext,
10+
make_ciphertext_election_context,
11+
)
12+
from electionguard.group import ElementModQ
13+
from electionguard.manifest import Manifest, InternalManifest
14+
from electionguard.utils import get_optional
1215

1316

1417
@dataclass
1518
class ElectionBuilder:
1619
"""
1720
`ElectionBuilder` is a stateful builder object that constructs `CiphertextElectionContext` objects
1821
following the initialization process that ElectionGuard Expects.
19-
SUGGESTION Perhaps move to test package.
2022
"""
2123

2224
number_of_guardians: int

tests/integration/test_end_to_end_election.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# Step 0 - Configure Election
1515
from electionguard.constants import ElectionConstants, get_constants
1616
from electionguard.election import CiphertextElectionContext
17-
from electionguard.election_builder import ElectionBuilder
1817
from electionguard.manifest import Manifest, InternalManifest
1918

2019
# Step 1 - Key Ceremony
@@ -73,6 +72,8 @@
7372
ElectionFactory,
7473
NUMBER_OF_GUARDIANS,
7574
)
75+
from electionguard_tools.helpers.election_builder import ElectionBuilder
76+
7677

7778
devices_directory = path.join(ELECTION_RECORD_DIR, DEVICES_DIR)
7879
guardians_directory = path.join(ELECTION_RECORD_DIR, GUARDIANS_DIR)

tests/property/test_decryption_mediator.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
from electionguard.data_store import DataStore
1515
from electionguard.decryption_mediator import DecryptionMediator
1616
from electionguard.election import CiphertextElectionContext
17-
from electionguard.election_builder import ElectionBuilder
1817
from electionguard.encrypt import (
1918
EncryptionMediator,
2019
encrypt_ballot,
@@ -44,6 +43,8 @@
4443
KeyCeremonyOrchestrator,
4544
)
4645
from electionguard_tools.helpers.tally_accumulate import accumulate_plaintext_ballots
46+
from electionguard_tools.helpers.election_builder import ElectionBuilder
47+
4748

4849
election_factory = ElectionFactory.ElectionFactory()
4950
ballot_factory = BallotFactory.BallotFactory()

tests/property/test_verify.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from electionguard.decryption import compute_decryption_share
1212
from electionguard.decryption_share import DecryptionShare
1313
from electionguard.decrypt_with_shares import decrypt_tally
14-
from electionguard.election_builder import ElectionBuilder
1514
from electionguard.elgamal import ElGamalKeyPair
1615
from electionguard.encrypt import EncryptionMediator, encrypt_ballot
1716
from electionguard.key_ceremony import CeremonyDetails
@@ -36,6 +35,8 @@
3635
from electionguard_tools.helpers.key_ceremony_orchestrator import (
3736
KeyCeremonyOrchestrator,
3837
)
38+
from electionguard_tools.helpers.election_builder import ElectionBuilder
39+
3940

4041
election_factory = ElectionFactory.ElectionFactory()
4142
ballot_factory = BallotFactory.BallotFactory()

tests/unit/test_decrypt_with_shares.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
reconstruct_decryption_share_for_ballot,
2121
)
2222
from electionguard.decryption_share import DecryptionShare
23-
from electionguard.election_builder import ElectionBuilder
2423
from electionguard.encrypt import EncryptionMediator
2524
from electionguard.group import ElementModP
2625
from electionguard.guardian import Guardian
@@ -36,6 +35,8 @@
3635
KeyCeremonyOrchestrator,
3736
)
3837
from electionguard_tools.helpers.tally_accumulate import accumulate_plaintext_ballots
38+
from electionguard_tools.helpers.election_builder import ElectionBuilder
39+
3940

4041
election_factory = ElectionFactory.ElectionFactory()
4142
ballot_factory = BallotFactory.BallotFactory()

tests/unit/test_decryption.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
mult_p,
3232
pow_p,
3333
)
34-
from electionguard.election_builder import ElectionBuilder
3534
from electionguard.encrypt import EncryptionMediator
3635
from electionguard.guardian import Guardian
3736
from electionguard.key_ceremony import (
@@ -49,6 +48,8 @@
4948
KeyCeremonyOrchestrator,
5049
)
5150
from electionguard_tools.helpers.tally_accumulate import accumulate_plaintext_ballots
51+
from electionguard_tools.helpers.election_builder import ElectionBuilder
52+
5253

5354
election_factory = ElectionFactory.ElectionFactory()
5455
ballot_factory = BallotFactory.BallotFactory()

0 commit comments

Comments
 (0)