-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathelection_builder_step.py
More file actions
38 lines (33 loc) · 1.5 KB
/
election_builder_step.py
File metadata and controls
38 lines (33 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from typing import Optional
from electionguard.elgamal import ElGamalPublicKey
from electionguard.group import ElementModQ
from electionguard.utils import get_optional
from electionguard_tools.helpers.election_builder import ElectionBuilder
from ..cli_models import CliElectionInputsBase, BuildElectionResults
from .cli_step_base import CliStepBase
class ElectionBuilderStep(CliStepBase):
"""Responsible for creating a manifest and context for use in an election."""
def _build_election(
self,
election_inputs: CliElectionInputsBase,
joint_public_key: ElGamalPublicKey,
committment_hash: ElementModQ,
verification_url: Optional[str],
) -> BuildElectionResults:
self.print_header("Building election")
print_message("Initializing public key and commitment hash")
election_builder = ElectionBuilder(
election_inputs.guardian_count,
election_inputs.quorum,
election_inputs.manifest,
)
election_builder.set_public_key(joint_public_key)
election_builder.set_commitment_hash(committment_hash)
if verification_url is not None:
election_builder.add_extended_data_field(
self.VERIFICATION_URL_NAME, verification_url
)
print_message("Creating context and internal manifest")
build_result = election_builder.build()
internal_manifest, context = get_optional(build_result)
return BuildElectionResults(internal_manifest, context)