With public key methods we define a finite field, and where we constrain the range of integers by a prime number (p). This gives us a finite field of integers from 0 to p-1. There are some fundamentals properties of rings which relate to the addition (+) and multiplication operator (-). In the following we perform the operations in respect of a prime number (p):
Rings and finite fields |
Outline
import sys a=40 b=64 c=91 p =31 print("a=",a) print("b=",b) print("c=",c) print("p=",p) print("Ring 0 to ",p-1) print("\nIdentity Law") print("a + 0=", (a+0) %p) print("0 + a=", (a%p+0%p) %p) print("\nAssociate Law") print("a+(b+c)=", (a + (b+c)%p) % p) print("(a+b)+c=", ((a+b)%p+c) %p) print("\nCommunative Law") print("a+b=",(a+b) % p) print("b+a=", (b%p + a%p) %p) print("\nIdentity Law") print("a * 1=", (a+1) %p) print("1 * a=", (a%p+1%p) %p) print("\nAssociate Law") print("a*(b*c)=", (a * (b*c)%p) % p) print("(a*b)*c=", ((a*b)%p*c) %p) print("\nCommunative Law") print("a*b=",(a*b) % p) print("b*a=", (b%p * a%p) %p)
A sample run:
a= 5 b= 22 c= 31 p= 43 Ring 0 to 42 Identity Law a + 0= 5 0 + a= 5 Associate Law a+(b+c)= 15 (a+b)+c= 15 Commutative Law a+b= 27 b+a= 27 Identity Law a * 1= 6 1 * a= 6 Associate Law a*(b*c)= 13 (a*b)*c= 13 Commutative Law a*b= 24 b*a= 24