Say, I want a finite field containing $2^n$ elements for some positive $n$. How to get a single random primitive element in Python, different from that provided by the Conway polynomial?
I know that Python's Galois library gives the option to calculate "GF.primitive_elements" or "GF.primitive_element" but I need two things:
- Only one primitive element (not all) for each primitive polynomial (Referring to the method "GF.primitive_elements").
- A single random primitive element different from that provided by the Conway polynomial (Referring to the method "GF.primitive_element")
To test if an element is a primitive element of GF(2^n), determine the prime factors of (2^n)-1, then calculate all the products of all the combinations of those factors except for all of them. Then to test if the element α is a primitive element of GF(2^n), α^p != 1, for all p of any of the products of combinations of factors (except for p = product of all factors, in which case β^p == 1, for any element β of GF(2^n)).
For GF(2^8), 2^8-1 = 255, factors of 255 are 3, 5, 17, the products of combinations are 3 * 5 = 15, 3 * 17 = 51, 5 * 17 = 85. Then to test if the element α is a primitive element of GF(2^8): α^15 != 1, α^51 != 1, α^85 != 1. If none of these powers == 1, then α is a primitive element.
For GF(2^16), 2^16-1 = 65535, factors are 3, 5, 17, 257, products are 3 * 5 * 17 = 255, 3 * 5 * 257 = 3855, 3 * 17 * 257 = 13107, 5 * 17 * 257 = 21845, so 4 tests would be used.