Fully implement the vote #8
3 changed files with 70 additions and 0 deletions
2
source/Card.py
Normal file
2
source/Card.py
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
class Card:
|
||||||
|
...
|
6
source/Certificate.py
Normal file
6
source/Certificate.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
class Certificate:
|
||||||
|
"""
|
||||||
|
A certificate.
|
||||||
|
Wrapper around cryptography.x509.Certificate.
|
||||||
|
"""
|
||||||
|
|
62
source/Machine.py
Normal file
62
source/Machine.py
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
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
|
Loading…
Reference in a new issue