Skip to content

Instantly share code, notes, and snippets.

@melvinvarkey
Created October 9, 2020 08:04
Show Gist options
  • Save melvinvarkey/436f41fa928b88a60e2aa899cdbe9175 to your computer and use it in GitHub Desktop.
Save melvinvarkey/436f41fa928b88a60e2aa899cdbe9175 to your computer and use it in GitHub Desktop.
Python 3.8.5 (tags/v3.8.5:580fbb0, Jul 20 2020, 15:43:08) [MSC v.1926 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a = 111
>>> b = 888
>>>
>>>
>>>
>>> g = 37
>>> n = 7
>>>
>>>
>>>
>>> import math
>>>
>>> alice = pow(g, a)%n
>>> print(alice)
1
>>>
>>>
>>> alice = pow(g, b)%n
>>>
>>> print(alice)
1
>>> g = 123817298361924619486
>>> n = 318729316248716823679
>>>
>>>
>>> alice = pow(g, a)%n
>>> bob = pow(g, b)%n
>>>
>>>
>>>
>>>
>>>
>>> print(alice)
269941610781721801640
>>>
>>> print(bob)
201463049294111210795
>>>
>>>
>>>
>>>
>>>
>>> alice_shared = pow(pow(g, b), a)%n
>>> bob_shared = pow(pow(g, a), b)%n
>>>
>>>
>>>
>>>
>>> print(alice_shared)
79559785172217586973
>>> print(bob_shared)
79559785172217586973
>>>
>>>
>>>
>>>
>>>
>>>
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment