Election-Tech-Initiative / Election-Tech-Initiative/electionguard
✨ Document and check that selection ids are unique across all contests.
- Dominant language
- Python
- Stars
- 872
- Forks
- 131
- PR merge metrics
- No merged PRs in 30d
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Suggestion
Its not obvious whether selection ids must be unique only within contests or across contests.
In decryption_share, we search across all shares, all contests, all selections, and match on the selection_id
```
def get_shares_for_selection(
selection_id: str,
shares: Dict[GuardianId, DecryptionShare],
) -> Dict[GuardianId, Tuple[ElementModP, CiphertextDecryptionSelection]]:
"""
Get all of the cast shares for a specific selection
"""
selections: Dict[GuardianId, Tuple[ElementModP, CiphertextDecryptionSelection]] = {}
for share in shares.values():
for contest in share.contests.values():
for selection in contest.selections.values():
if selection.object_id == selection_id:
selections[share.guardian_id] = (share.public_key, selection)
return selections
```
So this implies that selection_ids must be unique across all contests. If you didnt enforce that, likely there would be a verification failure. I think it would only fail when there are missing guardians, so it might be easy to miss in testing.
We could change that code to check both the contest id and the selection id, or just document and verify that selection ids are unique in the entire election manifest.
### Possible Implementation
_No response_
### Anything else?
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.