New models Proof and Elector use by emerging_list and proof_list.
This commit is contained in:
parent
8202d75e48
commit
00bb7493c8
3 changed files with 46 additions and 0 deletions
27
source/models/Elector.py
Normal file
27
source/models/Elector.py
Normal file
|
@ -0,0 +1,27 @@
|
|||
from dataclasses import dataclass
|
||||
|
||||
|
||||
@dataclass
|
||||
class Elector:
|
||||
# [
|
||||
# {
|
||||
# "name": "Bob",
|
||||
# "votant": (pub_key_bob, Hash(empreinte_bob)),
|
||||
# "mandataire": None,
|
||||
# },
|
||||
# {
|
||||
# "name": "Alice",
|
||||
# "votant": (pub_key_alice, Hash(empreinte_alice)),
|
||||
# "mandataire": (pub_key_Eve, Hash(empreinte_eve)), # Eve peut voter pour Alice.
|
||||
# }
|
||||
# ]
|
||||
|
||||
name: str
|
||||
public_key_elector: bytes
|
||||
hashed_fingerprint_elector: bytes
|
||||
public_key_mandataire: bytes = b""
|
||||
hashed_fingerprint_mandataire: bytes = b""
|
||||
|
||||
def set_mandataire(self, public_key: bytes, hashed_fingerprint: bytes):
|
||||
self.public_key_mandataire = public_key
|
||||
self.hashed_fingerprint_mandataire = hashed_fingerprint
|
19
source/models/Proof.py
Normal file
19
source/models/Proof.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
|
||||
import struct
|
||||
|
||||
|
||||
@dataclass
|
||||
class Proof:
|
||||
|
||||
date: datetime
|
||||
public_key_votant: bytes
|
||||
public_key_mandataire: bytes
|
||||
proof_signature: bytes
|
||||
|
||||
def to_bytes(self):
|
||||
struct.pack("<d...", self.date.timestamp(), self.public_key_votant, self.public_key_mandataire)
|
||||
|
||||
#bytes(str(ici), 'utf-8')
|
||||
bytes(self.date.timestamp())
|
0
source/models/__init__.py
Normal file
0
source/models/__init__.py
Normal file
Loading…
Reference in a new issue