modulus = 496597749679620867773432037469214230242402307330180853437434581099336634619713640485778675608223760166307530047354464605410050411581079376994803852937842168733702867087556948851016246640584660942486895230518034810309227309966899431 assert(modulus.is_prime()) Fp = GF(modulus) generator = Fp(0);for i in range(0, 20): i = Fp(i); neg_i = Fp(-i) if not(i.is_primitive_root() or neg_i.is_primitive_root()): continue elif i.is_primitive_root(): assert(i.is_primitive_root()); print("Generator: %d" % i) generator = i break else: assert(neg_i.is_primitive_root()); print("Generator: %d" % neg_i) generator = neg_i break two_adicity = valuation(modulus - 1, 2);trace = (modulus - 1) / 2**two_adicity;two_adic_root_of_unity = generator^traceprint("2-adic Root of Unity: %d " % two_adic_root_of_unity)
modulus = 496597749679620867773432037469214230242402307330180853437434581099336634619713640485778675608223760166307530047354464605410050411581079376994803852937842168733702867087556948851016246640584660942486895230518034810309227309966899431
assert(modulus.is_prime())
Fp = GF(modulus)
generator = Fp(0);
for i in range(0, 20):
i = Fp(i);
neg_i = Fp(-i)
if not(i.is_primitive_root() or neg_i.is_primitive_root()):
continue
elif i.is_primitive_root():
assert(i.is_primitive_root());
print("Generator: %d" % i)
generator = i
break
else:
assert(neg_i.is_primitive_root());
print("Generator: %d" % neg_i)
generator = neg_i
two_adicity = valuation(modulus - 1, 2);
trace = (modulus - 1) / 2**two_adicity;
two_adic_root_of_unity = generator^trace
print("2-adic Root of Unity: %d " % two_adic_root_of_unity)