62 lines
No EOL
1.6 KiB
Python
62 lines
No EOL
1.6 KiB
Python
class Machine:
|
|
"""
|
|
|
|
"""
|
|
|
|
def __init__(self):
|
|
# First DB: list of people authorized to vote on this machine.
|
|
# Public (que name et procuration pas empreinte) ?
|
|
self.emerging_list = [
|
|
{
|
|
"name": "Bob",
|
|
"personne": (pub_key_bob, Enc(empreinte_bob)),
|
|
"procuration": "vide",
|
|
},
|
|
{
|
|
"name": "Alice",
|
|
"personne": (pub_key_alice, Enc(empreinte_alice)),
|
|
"procuration": (pub_key_Eve, Enc(empreinte_eve)), # Eve peut voter pour Alice.
|
|
}
|
|
]
|
|
|
|
# Second DB: list of people who voted.
|
|
# - public
|
|
self.signing_list = [
|
|
("pub_key_Alice", "pub_key_Eve", "date", signature("message")),
|
|
("pub_key_Bob", "pub_key_Bob", "date", signature("message")),
|
|
]
|
|
|
|
# Third DB: votes (shuffle when vote is inserted).
|
|
# - private
|
|
self._vote_list = ["A", "B", "C"]
|
|
|
|
def authenticate(self):
|
|
pass
|
|
|
|
def vote(self, card: Card) -> bool:
|
|
if not authenticate(card):
|
|
print("la carte peut pas voter dans cette machine")
|
|
return False
|
|
|
|
if card_in_siging_list(card):
|
|
print("déjà vôté")
|
|
return False
|
|
|
|
vote = get_vote()
|
|
generate_signature(vote, card)
|
|
add_vote_to_urn(vote)
|
|
print("Vote comptabilisé!")
|
|
return True
|
|
|
|
def print_signing_list(self) -> None:
|
|
...
|
|
|
|
def print_emerging_list(self) -> None:
|
|
...
|
|
|
|
def cloture_du_vote(self) -> tuple[list[vote], signature]:
|
|
...
|
|
|
|
|
|
machine = Machine()
|
|
machine.emerging_list |