You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.
So we can do something like FQ(...).primitive_root(5) which will return a primitive 5th root of unity in the field.
There are situations where there may not be a n-th root of unity, an exception should be thrown.
It may also be beneficial to do a deterministic search for the roots of unity, so that the results are consistent across runs.
Example code:
deffind_root(p, n):
x=randint(1, p-1)
returnpow(x, (p-1)//n, p)
deffind_roots(p, n):
# https://crypto.stackexchange.com/questions/63614/finding-the-n-th-root-of-unity-in-a-finite-field# In particular, if N is a power of 2 and ω^(N/2) = −1, then ω is a principal N-th root of unity.gs=set()
whilelen(gs) !=n:
gs.add(find_root(p, n))
returnlist(gs)
defis_primitive_root(g, p, n):
returnpow(g, n//2, p) !=1defprimitive_roots(p, n):
return [_for_infind_roots(p, n) ifis_primitive_root(_, p, n)]
defprimitive_root(p, n):
whileTrue:
g=find_root(p, n)
ifis_primitive_root(g, p, n):
returng
The text was updated successfully, but these errors were encountered:
So we can do something like
FQ(...).primitive_root(5)
which will return a primitive 5th root of unity in the field.There are situations where there may not be a
n-th
root of unity, an exception should be thrown.It may also be beneficial to do a deterministic search for the roots of unity, so that the results are consistent across runs.
Example code:
The text was updated successfully, but these errors were encountered: