M1-PCA-Project/tests/exemple1.py
biloute02 cc243e5163 Function to end election.
Convert type of pubkey from bytes to RSAPublicKey.
2024-07-04 19:31:20 +02:00

61 lines
No EOL
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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)