61 lines
No EOL
1.8 KiB
Python
61 lines
No EOL
1.8 KiB
Python
import hashlib
|
||
from cryptography.hazmat.primitives import hashes
|
||
from cryptography.hazmat.primitives.asymmetric import rsa
|
||
from cryptography.hazmat.primitives.asymmetric import padding
|
||
|
||
from source.Card import Card
|
||
from source.models.Elector import Elector
|
||
#from source.Certificate import Certificate
|
||
from source.Machine import Machine
|
||
|
||
# Création des cartes
|
||
|
||
alice_card = Card("Alice", "6060")
|
||
bob_card = Card("Bob", "0100")
|
||
eve_card = Card("Eve", "0008")
|
||
print(f"carte alice pubkey: {alice_card.public_key}")
|
||
print("Cartes d’élections créent")
|
||
|
||
input()
|
||
|
||
# Création de la liste électorale
|
||
|
||
# Eve peut voter pour Alice
|
||
alice_elector = Elector(name="Alice",
|
||
public_key_elector=alice_card.public_key,
|
||
fingerprint_elector="empreinteA",
|
||
public_key_mandataire=eve_card.public_key,
|
||
fingerprint_mandataire="empreinteE")
|
||
bob_elector = Elector("Bob", bob_card.public_key, "empreinteB")
|
||
eve_elector = Elector("Eve", eve_card.public_key, "empreinteE")
|
||
emerging_list = [alice_elector, bob_elector, eve_elector]
|
||
print(f"alice name: {alice_elector.name}")
|
||
print(f"alice pubkey: {alice_elector.public_key_elector}")
|
||
print(f"alice pubkey mandataire: {alice_elector.public_key_mandataire}")
|
||
print(f"alice empreinte: {alice_elector.hashed_fingerprint_elector}")
|
||
print(f"alice empreinte mandataire: {alice_elector.hashed_fingerprint_mandataire}")
|
||
print(f"liste d’émargement: {emerging_list}")
|
||
print("Liste électorale crée.")
|
||
|
||
input()
|
||
|
||
# Création de la machine
|
||
|
||
machine = Machine(emerging_list)
|
||
print(f"machine pubkey : {machine._public_key.public_bytes()}")
|
||
print("Machine pour voter crée")
|
||
|
||
input()
|
||
|
||
|
||
|
||
# Authentification
|
||
|
||
# Vote
|
||
|
||
# Publication des résultats
|
||
|
||
#Machine.authenticate(Alice_card, 6060, "azerty")
|
||
|
||
|
||
#Machine.vote(Alice_card) |