def reduction(E: EllipticCurve_number_field, p: NumberFieldFractionalIdeal):
    if not E.has_good_reduction(p):
        raise ValueError(f"The curve must have good reduction at the place.")
    Ep = E.local_data(p).minimal_model()
    K = E.base_ring()
    Fp = K.residue_field(p)
    Fp2 = GF(Fp.order(), "abar", modulus=Fp.modulus())
    iso = Fp.hom([Fp2.gen(0)], Fp2)
    Ebar = EllipticCurve([iso(Fp(ai)) for ai in Ep.ainvs()])
    return Ebar
Esempio n. 2
0
    def __init__(self, p, a=0, b=0):
        """
        Assumes p is prime.

        Gives an error if p ≠ 3 mod 4.
        """
        assert p % 4 == 3

        # Internally, we represent our element as a Sage field element.
        #
        # Rewrite your own implementation, of GF(p²) on top of Python integers
        I = SageGF(p)['I'].gen()
        base = SageGF(p**2, 'i', modulus=I**2 + 1)
        i = base.gen()
        self.elt = a + b * i
Esempio n. 3
0
POWM2P1D3 = ZZ((2**m2+1)/3)
K1MASK = 2**m1 - 1
K1HIGHBIT = 2**(m1-1)
K0MASK = 2**m0 - 1
K0HIGHBIT = 2**(m0-1)
NECKLACES = 1/m1*sum(euler_phi(d)*2**(ZZ(m1/d)) for d in m1.divisors())
# 9*2*2*2 > 64
if m2 > 8:
    USE_DWORD = 1
else:
    USE_DWORD = 0

GF2 = GF(2)
x = polygen(GF2)
K2 = GF(2**m2, name='g2', modulus=modulus)
g2 = K2.gen()
z2 = K2.multiplicative_generator()
K1 = GF(2**m1, name='g1', modulus=modulus)
g1 = K1.gen()
z1 = K1.multiplicative_generator()
Z1 = z1.polynomial().change_ring(ZZ)(2)
K0 = GF(2**m0, name='g0', modulus=modulus)
g0 = K0.gen()
z0 = K0.multiplicative_generator()
L = [K0, K1, K2]
moduli = [k.modulus() for k in L]
F = [f.change_ring(ZZ)(2) for f in moduli]
weights = [f.hamming_weight()-2 for f in moduli]
degrees = [(f-x**f.degree()-1).exponents() for f in moduli]
FWEIGHTS = weights
F0D = degrees[0]