-
Notifications
You must be signed in to change notification settings - Fork 0
/
dsa_public_key.py
77 lines (60 loc) · 1.48 KB
/
dsa_public_key.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
class DSAPublicKey:
def __init__(self, p: int = 0, q: int = 0, g: int = 0, y: int = 0):
self._p = p
self._q = q
self._g = g
self._y = y
@property
def p(self) -> int:
return self._p
@p.setter
def p(self, p: int):
self._p = p
@property
def q(self) -> int:
return self._q
@q.setter
def q(self, q: int):
self._q = q
@property
def g(self) -> int:
return self._g
@g.setter
def g(self, g: int):
self._g = g
@property
def y(self) -> int:
return self._y
@y.setter
def y(self, y: int):
self._y = y
def to_list(self) -> list:
return [self._p, self._q, self._g, self._y]
@property
def is_empty(self) -> bool:
return all(map(lambda num: num == 0, self.to_list()))
@property
def is_full(self) -> bool:
return all(map(lambda num: num != 0, self.to_list()))
@property
def has_non_zero_values(self) -> bool:
return not self.is_empty
@property
def has_zero_values(self) -> bool:
return not self.is_full
@property
def has_q(self) -> bool:
result = self._q > 0
return result
@property
def has_p(self) -> bool:
result = self._p > 0
return result
@property
def has_g(self) -> bool:
result = self._g > 0
return result
@property
def has_y(self) -> bool:
result = self._y > 0
return result