56 lines
1.2 KiB
Python
56 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
|
|
|
from Cryptotools.Groups.group import Group
|
|
from Cryptotools.Utils.utils import gcd
|
|
import matplotlib.pyplot as plt
|
|
|
|
|
|
n = 18
|
|
def operation(e1, e2, n) -> int:
|
|
return e1 * e2 % n
|
|
|
|
# Generate the group G
|
|
g = list()
|
|
for i in range(1, n):
|
|
#if gcd(i, n) == 1:
|
|
g.append(i)
|
|
|
|
G = Group(n = n, g = g, ope=operation)
|
|
print(f"n = {n}")
|
|
print(f"G = {G.getG()}")
|
|
|
|
if G.closure() is False:
|
|
print("The closure law is not respected. It's not an abelian (commutative) group")
|
|
else:
|
|
print("It is a closure group")
|
|
|
|
if G.associative() is False:
|
|
print("The associative law is not respected. It's not a group")
|
|
else:
|
|
print("It is an associative group")
|
|
|
|
if G.identity() is False:
|
|
print("The group hasn't an identity element")
|
|
else:
|
|
print(f"Identity: {G.getIdentity()}")
|
|
|
|
if G.reverse() is False:
|
|
print(f"The group hasn't a reverse")
|
|
else:
|
|
print(f"Reverses: {G.getReverses()}")
|
|
|
|
#reverses = G.getReverses()
|
|
#plt.rcParams["figure.figsize"] = [7.00, 3.50]
|
|
#plt.rcParams["figure.autolayout"] = True
|
|
#for key, value in reverses.items():
|
|
# x = key
|
|
# y = value
|
|
# plt.plot(x, y, marker="o", markersize=2, markeredgecolor="blue")
|
|
# #plt.Circle((0, n), 0.2, color='r')
|
|
#
|
|
#plt.xlim(0, n)
|
|
#plt.ylim(0, n)
|
|
#plt.grid()
|
|
#plt.show()
|
|
|