RSA polynomial
R = PolynomialRing(GF(2),'x') # GF(2) is the field Z mod 2 and R is the polynomial ring F_2[x]. x = R.gen() %typeset_mode True p = x^5+x^3+1 q = x^3+x+1 e=101 n=p*q S = R.quotient(n, 'a') a = S.gen() p q expand(n)
fiOfN=(2^5-1)*(2^3-1) fiOfN
M=1*a^7+(0*a^6)+(0*a^5)+(0*a^4)+(1*a^3)+(1*a^2)+(0*(a^1))+(1*(a^0)) M
eM=M^e eM
d,u,v=xgcd(fiOfN,e) v
dM=eM^(v+fiOfN) dM M
numM=16346
lM=numM.digits(2) lM
c=lM[0] for i in range(len(lM)): c=c+lM[i]*a^i print(c)
mYES=c mYES
enc=mYES^e enc
enc^(v+fiOfN)
a^fiOfN
C = c.lift()
C
C.coefficients(sparse=False)