Skip to content

Commit d9d4b52

Browse files
committed
Key Ceremony Update (#349)
* 🐛. Exponent modifier should not be zero The exponent modifier should never be allowed to be zero to compute a polynomial coordinate. In the same way a sequence_order should never be zero. * Refactor Auxiliary Key * Refactor Elgamal Key * Refactor ElectionPolynomial * Refactor Key Ceremony and Election Keys - Remove GuardianKeyPair for migration to stateful class - Migration of coefficient commitments and proofs into electionpublickey - Removal of hash coefficient commitment specialty method - Update tests * Update Publish and tests * Update Guardian to Stateless * Functional Key Ceremony Test * Update Decryption * ❓Remove optional on store Optional on store shouldn't exist. This returns a list. * Refactor Guardian - Remove references to manually doing recovery key - Ensure using new naming for election public key - Correctly handle publish - Change tests to rely on what can possibly be an outside verifier not necessarily a guardian. * Refactor Key Ceremony - Ensure key owner id and sequence order passed into all guardian key generation * Implement Key Ceremony Helper Key Ceremony Helper is both an example and a test implementation to perform the key ceremony. The idea is to provide an example and simply long testing sections. * Updates to Functional Key Ceremony * Add identity encrypt to ElectionGuard Test Identity encrypt to the mock library to reduce the recoding of this function * Update decryption tests * Update Election Builder * Update Key Ceremony Mediator * Add Changes into Election Factory * Update Decryption Mediator * Update End to End Election Tests Update the end to end election to demonstrate the entire election process including the new key ceremony changes. * Review Adjustments - Add property descriptions - Add method descriptions * Remove sequence order that is created with zero * Update Ballot Box to use BALLOT_ID * 🐛 Fix decryption mediator for ballots * ✅ Add Decryption Tests - Migrate some tests to decrypt_with_shares - Add test_decryption tests - Add Decryption Mediator tests
1 parent 71e8150 commit d9d4b52

26 files changed

Lines changed: 2770 additions & 1666 deletions

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ unit-tests:
102102

103103
property-tests:
104104
@echo ✅ PROPERTY TESTS
105-
poetry run pytest tests/test_decryption_mediator.py
106105
poetry run pytest tests/property
107106

108107
integration-tests:

src/electionguard/auxiliary.py

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,64 @@
33
from .types import GUARDIAN_ID
44

55
MESSAGE = str
6-
PUBLIC_KEY = str
7-
SECRET_KEY = str
6+
AUXILIARY_PUBLIC_KEY = str
7+
AUXILIARY_SECRET_KEY = str
88
ENCRYPTED_MESSAGE = str
99

1010

11-
class AuxiliaryKeyPair(NamedTuple):
12-
"""A tuple of a secret key and public key."""
11+
class AuxiliaryPublicKey(NamedTuple):
12+
"""A tuple of auxiliary public key and owner information that can be shared between guardians"""
1313

14-
secret_key: SECRET_KEY
15-
"""The secret or private key"""
16-
public_key: PUBLIC_KEY
14+
owner_id: GUARDIAN_ID
15+
"""
16+
The unique identifier of the guardian owning the key
17+
"""
18+
19+
sequence_order: int
20+
"""
21+
The sequence order of the auxiliary public key (usually the guardian's sequence order)
22+
"""
1723

24+
key: AUXILIARY_PUBLIC_KEY
25+
"""
26+
A string representation of the Auxiliary public key that can be shared between guardians.
27+
It is up to the external `AuxiliaryEncrypt` function to know how to parse this value
28+
"""
1829

19-
class AuxiliaryPublicKey(NamedTuple):
20-
"""A tuple of auxiliary public key and owner information"""
30+
31+
class AuxiliaryKeyPair(NamedTuple):
32+
"""A tuple of a secret key and public key."""
2133

2234
owner_id: GUARDIAN_ID
2335
"""
24-
The unique identifier of the guardian
36+
The unique identifier of the guardian owning the key
2537
"""
2638

2739
sequence_order: int
2840
"""
2941
The sequence order of the auxiliary public key (usually the guardian's sequence order)
3042
"""
3143

32-
key: PUBLIC_KEY
44+
secret_key: AUXILIARY_SECRET_KEY
45+
"""The secret or private key"""
46+
47+
public_key: AUXILIARY_PUBLIC_KEY
3348
"""
34-
A string representation of the Auxiliary public key.
49+
A string representation of the Auxiliary public key that can be shared between guardians.
3550
It is up to the external `AuxiliaryEncrypt` function to know how to parse this value
3651
"""
3752

53+
def share(self) -> AuxiliaryPublicKey:
54+
"""Share the auxiliary public key and associated data"""
55+
return AuxiliaryPublicKey(self.owner_id, self.sequence_order, self.public_key)
56+
3857

39-
AuxiliaryEncrypt = Callable[[MESSAGE, PUBLIC_KEY], Optional[ENCRYPTED_MESSAGE]]
58+
AuxiliaryEncrypt = Callable[
59+
[MESSAGE, AUXILIARY_PUBLIC_KEY], Optional[ENCRYPTED_MESSAGE]
60+
]
4061
"""A callable type that represents the auxiliary encryption scheme."""
4162

42-
AuxiliaryDecrypt = Callable[[ENCRYPTED_MESSAGE, SECRET_KEY], Optional[MESSAGE]]
63+
AuxiliaryDecrypt = Callable[
64+
[ENCRYPTED_MESSAGE, AUXILIARY_SECRET_KEY], Optional[MESSAGE]
65+
]
4366
"""A callable type that represents the auxiliary decryption scheme."""

src/electionguard/ballot_box.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from .election import CiphertextElectionContext
1313
from .logs import log_warning
1414
from .manifest import InternalManifest
15+
from .types import BALLOT_ID
1516

1617

1718
@dataclass
@@ -83,7 +84,7 @@ def accept_ballot(
8384

8485
def get_ballots(
8586
store: DataStore, state: Optional[BallotBoxState]
86-
) -> Dict[str, SubmittedBallot]:
87+
) -> Dict[BALLOT_ID, SubmittedBallot]:
8788
return {
8889
ballot_id: ballot
8990
for (ballot_id, ballot) in store.items()

src/electionguard/data_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(self) -> None:
3131
def __iter__(self) -> Iterator:
3232
return iter(self._store.items())
3333

34-
def all(self) -> List[Optional[_U]]:
34+
def all(self) -> List[_U]:
3535
"""
3636
Get all `SubmittedBallot` from the store
3737
"""

0 commit comments

Comments
 (0)