from IPython.display import Image
Image("images/F2.png",width=300)
Image("images/dieti.png",width=200)
Image("images/Asymmetric.png",width=600)
from sympy import *
p = 11
q = 17
N = p*q
print('Is p prime number ? = ',isprime(p))
print('Is q prime number ? = ',isprime(p))
pm1qm1 = (p-1)*(q-1)
print('(p-1)(q-1) =',pm1qm1)
Is p prime number ? = True Is q prime number ? = True (p-1)(q-1) = 160
c = 7
print('Has',c,'factors in common with', (p-1)*(q-1),' ? ',pm1qm1 % c == 0)
d = mod_inverse(c, pm1qm1)
print(c,'x',d,'= 1 ( mod',pm1qm1,')')
Has 7 factors in common with 160 ? False 7 x 23 = 1 ( mod 160 )
b = pow(a,c) % N
print(b)
130
aa = pow(b,d) % N
print(a)
3
Rivest, Shamir, Adleman "Cryptographic communications system and method" Patent US4405829A
Manfred Schroeder "Number Theory in Science and Communication" (1984)
N. David Mermin "Quantum Computer Science (An Introduction)" (2007)