Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove trailing whitespace in a bunch of files #1250

Merged
merged 1 commit into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/EllCrv/EllCrv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@

function Base.getindex(P::EllCrvPt, i::Int)
@req 1 <= i <= 3 "Index must be 1, 2 or 3"

K = base_field(parent(P))

if is_infinite(P)
if i == 1
if i == 1
return zero(K)
elseif i == 2
return one(K)
Expand Down Expand Up @@ -236,14 +236,14 @@
return elliptic_curve(QQFieldElem[QQ(z) for z in x], check = check)
end

# A constructor to create an elliptic curve from a bivariate polynomial.
# One can specify how to interpret the polynomial via the second and the
# A constructor to create an elliptic curve from a bivariate polynomial.
# One can specify how to interpret the polynomial via the second and the
# third argument.
@doc raw"""
elliptic_curve(f::MPolyRingElem, x::MPolyRingElem, y::MPolyRingElem) -> EllCrv

Construct an elliptic curve from a bivariate polynomial `f` in long Weierstrass form.
The second and third argument specify variables of the `parent` of `f` so that
Construct an elliptic curve from a bivariate polynomial `f` in long Weierstrass form.
The second and third argument specify variables of the `parent` of `f` so that
``f = c ⋅ (-y² + x³ - a₁ ⋅ xy + a₂ ⋅ x² - a₃ ⋅ y + a₄ ⋅ x + a₆)``.
"""
function elliptic_curve(f::MPolyRingElem, x::MPolyRingElem, y::MPolyRingElem)
Expand Down Expand Up @@ -624,10 +624,10 @@
```
"""
function (E::EllCrv{T})(coords::Vector{S}; check::Bool = true) where {S, T}
if !(2 <= length(coords) <= 3)
if !(2 <= length(coords) <= 3)
error("Points need to be given in either affine coordinates (x, y) or projective coordinates (x, y, z)")
end

if length(coords) == 3
if coords[1] == 0 && coords[3] == 0
if coords[2] != 0
Expand All @@ -636,7 +636,7 @@
error("The triple [0: 0: 0] does not define a point in projective space.")
end
end
coords = [coords[1]//coords[3], coords[2]//coords[3]]
coords = [coords[1]//coords[3], coords[2]//coords[3]]
end
if S === T
parent(coords[1]) != base_field(E) &&
Expand Down Expand Up @@ -1122,18 +1122,18 @@
psi_m_univ = division_polynomial_univariate(E, m, x)[2]
psi_mplus = division_polynomial(E, m+1, x, y)
psi_mmin2 = division_polynomial(E, m-2, x, y)
if p == 3 && j_invariant(E) != 0
if iseven(m)

if p == 3 && j_invariant(E) != 0
if iseven(m)

Check warning on line 1127 in src/EllCrv/EllCrv.jl

View check run for this annotation

Codecov / codecov/patch

src/EllCrv/EllCrv.jl#L1127

Added line #L1127 was not covered by tests
num = (psi_mplus2*psi_mmin^2 - psi_mmin2*psi_mplus^2) - a1*(x* psi_m_univ^2*B6 -psi_mmin*psi_mplus)*psi_m_univ
denom = 2*B6^2*psi_m_univ^3
else
num = (psi_mplus2*psi_mmin^2 - psi_mmin2*psi_mplus^2) - a1*(x* psi_m_univ^2 -psi_mmin*psi_mplus*B6)*psi_m_univ
denom = 4*y*psi_m_univ^3
denom = 4*y*psi_m_univ^3

Check warning on line 1132 in src/EllCrv/EllCrv.jl

View check run for this annotation

Codecov / codecov/patch

src/EllCrv/EllCrv.jl#L1132

Added line #L1132 was not covered by tests
end
return num//denom
end


num = (psi_mplus2*psi_mmin^2 - psi_mmin2*psi_mplus^2)

Expand Down
32 changes: 16 additions & 16 deletions src/EllCrv/Finite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
################################################################################

export hasse_interval, order, order_via_exhaustive_search, order_via_bsgs, order_via_legendre,
order_via_schoof, trace_of_frobenius, rand, elem_order_bsgs, is_supersingular,
order_via_schoof, trace_of_frobenius, rand, elem_order_bsgs, is_supersingular,
is_ordinary, is_probable_supersingular, supersingular_polynomial

################################################################################
Expand Down Expand Up @@ -924,34 +924,34 @@ Return true when the elliptic curve is supersingular. The result is proven to be
"""
function is_supersingular(E::EllCrv{T}) where T <: FinFieldElem
K = base_field(E)

p = characteristic(K)
j = j_invariant(E)

if j^(p^2) != j
return false
end

if p<= 3
return j == 0
end

L = Native.GF(p, 2)
Lx, X = polynomial_ring(L, "X")
Lxy, Y = polynomial_ring(Lx, "Y")
Phi2 = X^3 + Y^3 - X^2*Y^2 + 1488*(X^2*Y + Y^2*X) - 162000*(X^2 + Y^2) + 40773375*X*Y + 8748000000*(X + Y) - 157464000000000

jL = _embed_into_p2(j, L)

js = roots(Phi2(jL))

if length(js) < 3
return false
end

newjs = [jL, jL, jL]
f = elem_type(Lx)[zero(Lx), zero(Lx), zero(Lx)]

m = nbits(p) - 1
for k in (1 : m)
for i in (1 : 3)
Expand Down Expand Up @@ -1016,15 +1016,15 @@ function is_probable_supersingular(E::EllCrv{T}) where T <: FinFieldElem
j = j_invariant(E)
K = base_field(E)
p = characteristic(K)

local degj::Int

if degree(K) == 1
degj = 1
else
degj = degree(minpoly(j))
end

if degj == 1
return monte_carlo_test(E, p+1)
elseif degj == 2
Expand All @@ -1036,14 +1036,14 @@ end

function monte_carlo_test(E, n)
E_O = infinity(E)

for i in (1:10)
P = rand(E)
if n*P != E_O
return false
end
end

return true
end

Expand All @@ -1060,7 +1060,7 @@ function supersingular_polynomial(p::IntegerUnion)
if p < 3
return J
end

m = divexact((p-1), 2)
KXT, (X, T) = polynomial_ring(K, ["X", "T"])
H = sum([binomial(m, i)^2 *T^i for i in (0:m)])
Expand Down Expand Up @@ -1144,7 +1144,7 @@ Return a list of generators of the group of rational points on $E$.

# Examples

```jldoctest; filter = r"Point.*"
```jldoctest; filter = r"Point.*"
julia> E = elliptic_curve(GF(101, 2), [1, 2]);

julia> gens(E)
Expand Down
38 changes: 19 additions & 19 deletions src/EllCrv/FormalGroupLaw.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ function formal_w(E::EllCrv, prec::Int = 20)
k = base_field(E)
kz, z = laurent_series_ring(k, prec, "z")
kzw, w = polynomial_ring(kz, "w")

a1, a2, a3, a4, a6 = a_invars(E)

f = z^3 + a1*z*w + a2*z^2*w + a3*w^2 + a4*z*w^2 + a6*w^3
result = z^3 + a1*z*w + a2*z^2*w + a3*w^2 + a4*z*w^2 + a6*w^3

for i in (1:prec)
result = truncate(f(result), div(10,3))
end
return result(0)

end

@doc raw"""
Expand Down Expand Up @@ -69,7 +69,7 @@ function formal_differential_form(E::EllCrv, prec::Int = 20)
x = formal_x(E, prec + 1)
y = formal_y(E, prec + 1)
dx = derivative(x)

return truncate(dx//(2*y + a1*x + a3), prec)
end

Expand All @@ -87,29 +87,29 @@ end
k = base_field(E)
a1, a2, a3, a4, a6 = a_invars(E)
ktt, (z1, z2) = power_series_ring(k, prec + 1, ["z1", "z2"])

#We now compute the slope lambda of the addition in the formal group law
#Following Silverman
#A_n-3 = w[n] for n in 3 to infinity
#(z1^n - z2^n)//(z1 - z2) = z1^(n-1) + z1^(n-2)*z2 +.... +z2^(n-2)
#lambda = sum A_n-3*(z1^n - z2^n)//(z1 - z2)
#(z1^n - z2^n)//(z1 - z2) = z1^(n-1) + z1^(n-2)*z2 +.... +z2^(n-2)
#lambda = sum A_n-3*(z1^n - z2^n)//(z1 - z2)

w = formal_w(E, prec + 1)

lambda = sum([coeff(w, n)*sum([z1^m * z2^(n-m-1) for m in (0:n-1)]) for n in (3:prec +1)])

#Needs to simply be evaluating
wz1 = sum([coeff(w, i)*z1^i for i in (0:prec +1)])

nu = wz1 - lambda*z1

z3 = -z1 - z2 - divexact(a1*lambda + a3*lambda^2 + a2*nu + 2*a4*lambda*nu + 3*a6*lambda^2*nu, 1 + a2*lambda + a4*lambda^2 + a6*lambda^3)

inv = formal_inverse(E, prec)

#Needs to simply be evaluating
result = sum([coeff(inv, i)*z3^i for i in (0:prec +1)])

#Sage and Magma truncate to O(z1, z2)^20 instead of O(z1)^20 + O(z2)^20 like we do
return result
end
Expand Down Expand Up @@ -138,11 +138,11 @@ function formal_isogeny(phi::Isogeny, prec::Int = 20)
E = domain(phi)
x = formal_x(E, prec)
y = formal_y(E, prec)

Rz = parent(x)

maps = rational_maps(phi)

fnum = change_base_ring(Rz, numerator(maps[1]))
fdenom = change_base_ring(Rz, denominator(maps[1]))
gnum = change_base_ring(Rz, numerator(maps[2]))
Expand Down
Loading
Loading