fun
This commit is contained in:
1 parent
711c6474cc
commit
886ae12241
1 file changed
+11
-5
+11
-5
@@ -1,8 +1,11 @@
|
||||
from collections.abc import Callable
|
||||
|
||||
|
||||
class Person:
|
||||
def __init__(self, p: int, g: int, k: int):
|
||||
self.p, self.g, self.k = p, g, k
|
||||
self.s = None
|
||||
|
||||
|
||||
def public_key(self, recieved: int | None = None) -> int:
|
||||
return pow(recieved or self.g, self.k, self.p)
|
||||
|
||||
@@ -11,11 +14,14 @@ class Person:
|
||||
return self.s
|
||||
|
||||
|
||||
def damn(p, g) -> Callable[[int], Person]:
|
||||
return lambda k: Person(p, g, k)
|
||||
|
||||
|
||||
def main():
|
||||
p = 23
|
||||
g = 5
|
||||
alice = Person(p, g, 4)
|
||||
bob = Person(p, g, 3)
|
||||
demo = damn(p=23, g=5)
|
||||
alice = demo(4)
|
||||
bob = demo(3)
|
||||
assert (
|
||||
alice.recieve_public_key(bob.public_key())
|
||||
== bob.recieve_public_key(alice.public_key())
|
||||
|
||||
Reference in new issue
Block a user