mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-09 22:57:59 -05:00
research/fft: alternative to finding extension fields containing root of unity
This commit is contained in:
@@ -26,6 +26,20 @@ def find_ext_order(p, n):
|
|||||||
|
|
||||||
N += 1
|
N += 1
|
||||||
|
|
||||||
|
# Alternative to the above fn. Technically we still need to loop since
|
||||||
|
# discrete_log() is a bruteforce algo.
|
||||||
|
def find_ext_order_alt(p, n):
|
||||||
|
# We have that n | p^N - 1 for some n. This is the same as wrtiting:
|
||||||
|
# p^N - 1 = ns for some s
|
||||||
|
# => p^N - 1 ≡ 0 (mod n)
|
||||||
|
# p · p^(N - 1) ≡ 1 (mod n)
|
||||||
|
# But recall that p^(N - 1) ≡ p^-1
|
||||||
|
# So we just take p (mod n), find its inverse then compute N - 1
|
||||||
|
R = Integers(n)
|
||||||
|
p = R(p)
|
||||||
|
N_minus_1 = discrete_log(p^-1, p)
|
||||||
|
return N_minus_1 + 1
|
||||||
|
|
||||||
def find_nth_root_unity(K, n):
|
def find_nth_root_unity(K, n):
|
||||||
# It cannot be a quadratic residue if n is odd
|
# It cannot be a quadratic residue if n is odd
|
||||||
#assert n % 2 == 1
|
#assert n % 2 == 1
|
||||||
@@ -47,8 +61,6 @@ K.<a> = GF(p^N, repr="int")
|
|||||||
|
|
||||||
L.<X> = K[]
|
L.<X> = K[]
|
||||||
|
|
||||||
f = 3*X^4 + 7*X^3 + X^2 + 4
|
|
||||||
g = 2*X^4 + 2*X^2 + 110
|
|
||||||
f = X^2 + 2*X + 4
|
f = X^2 + 2*X + 4
|
||||||
g = 2*X^2 + 110
|
g = 2*X^2 + 110
|
||||||
assert f.degree() < n/2
|
assert f.degree() < n/2
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ print()
|
|||||||
L.<X> = K[]
|
L.<X> = K[]
|
||||||
|
|
||||||
f = 10*X + 110
|
f = 10*X + 110
|
||||||
assert f.degree() < n/2
|
f = X^3 + 10*X + 110
|
||||||
|
#assert f.degree() < n/2
|
||||||
print(f"f = {f}")
|
print(f"f = {f}")
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user