from source.Card import Card from source.models.Elector import Elector from source.Machine import Machine # Vote électronique # 3 personnes alice = { "name": "Alice", "password": "6060", "empreinte": "empreinteA", "vote": "Riri", } bob = { "name": "Bob", "password": "0100", "empreinte": "empreinteB", "vote": "Toto", } eve = { "name": "Eve", "password": "008", "empreinte": "empreinteE", "vote": "Jack", } personnes = [alice, bob, eve] # Création des cartes alice["card"] = Card(alice["password"]) bob["card"] = Card(bob["password"]) eve["card"] = Card(eve["password"]) print(f"Liste de cartes : {[personne['card'] for personne in personnes]}") print("Cartes d’élections créées.") print() # Création de la liste électorale # Eve peut voter pour Alice alice_elector = Elector(name=alice["name"], public_key_elector=alice["card"].public_key, fingerprint_elector=alice["empreinte"], public_key_mandataire=eve["card"].public_key, fingerprint_mandataire=eve["empreinte"]) bob_elector = Elector(name=bob["name"], public_key_elector=bob["card"].public_key, fingerprint_elector=bob["empreinte"]) emerging_list = [alice_elector, bob_elector] print(f"Liste d’émargement: {emerging_list}") print("Liste électorale créée.") print() # Création de la machine machine = Machine(emerging_list) print(f"Machine pubkey : {machine.public_key}") print("Machine pour voter créée") print() # Votes des personnes alice["password"] = "fleur" for personne in personnes: # Authentification print() print(f"La personne {personne["name"]} s’authentifie avec le mdp {personne["password"]} et l’empreinte {personne["empreinte"]}.") if not machine.authenticate(personne["card"], personne["password"], personne["empreinte"]): continue # Vote print() print(f"La personne {personne["name"]} va voter pour {personne["vote"]}") if not machine.vote(personne["card"], personne["vote"]): continue # Publication des résultats votes, sig_votes = machine.cloture_du_vote() print() print(votes)