Releases: syakoo/galois-field
Adding Features of getting a primitive element in GF(q).
Motivation
This library was created to apply Finite Field to cryptography and coding theory, Especially in cryptography, there are many situations where we want to get a primitive element in GF(q). So we implemented a function to get a primitive element for all GF(q).
Usage
It can be retrieved by executing random_primitive_elm()
function of the GFp
or GFpn
class.
gf_11 = GFp(11)
# Getting a random primitive element in GF(11)
gf_11.random_primitive_elm() # 8 (mod 11)
gf_5_4 = GFpn(5, [1, 0, 0, 0, 2])
# Getting a random primitive element in GF(5^4)
gf_5_4.random_primitive_elm() # 1x^3 + 2x^2 + 4x + 3
Be careful when using a finite field with large orders because the computational complexity is very large.
v2.0.0
The structure of the class has been changed.
In previous version, GF was defined and elements of their instances was changed depending on whether or not they included a mod_poly
as an argument.
>>> gf1 = GF(11)
>>> el1 = gf1(13) # This is an element in GF(11).
>>> gf2 = GF(11, [1, 0, 1])
>>> el2 = gf2([1,2]) # This is an element in GF(11^2)
However, the type hints didn't work well because the properties and methods used by the extension fields and the prime fields are different.
For this reason, we divided the GF class into GFp and GFpn classes:
>>> gf1 = GFp(11) # GF(p)
>>> el1 = gf1(13)
>>> gf2 = GFpn(11, [1, 0, 1]) # GF(p^n)
>>> el2 = gf2([1,2])