def galois_action(self, t, N): from sage.modular.modsym.p1list import lift_to_sl2z if self.is_infinity(): return self if not isinstance(t, Integer): t = Integer(t) a = self._Cusp__a b = self._Cusp__b * t.inverse_mod(N) if b.gcd(a) != ZZ(1): _,_,a,b = lift_to_sl2z(a,b,N) a = Integer(a); b = Integer(b) # Now that we've computed the Galois action, we efficiently # construct the corresponding cusp as a Cusp object. return Cusp(a,b,check=False)
def galois_action(self, t, N): from sage.modular.modsym.p1list import lift_to_sl2z if self.is_infinity(): return self if not isinstance(t, Integer): t = Integer(t) a = self._Cusp__a b = self._Cusp__b * t.inverse_mod(N) if b.gcd(a) != ZZ(1): _,_,a,b = lift_to_sl2z(a,b,N) a = Integer(a); b = Integer(b) # Now that we've computed the Galois action, we efficiently # construct the corresponding cusp as a Cusp object. return Cusp(a,b,check=False)
def method(r,k,D,max_trials=10000, g=0): """ Description: Run the Cocks-Pinch method to find an elliptic curve Input: r - prime k - embedding degree, r % k == 1 D - (negative) fundamental discriminant where D is a square mod r max_trials - the number of integers q to test for primality in the CP method g - an element of order k in Z_r^* Output: (q,t) - tuple where q is a prime and t is chosen such that there exists an elliptic curve E over F_q with trace t, and r | q+1-t; if the algorithm fails to find (q,t), it will return (0,0) """ assert test_promise(r,k,D), 'Invalid inputs' if g != 0: assert power_mod(g,k,r) == 1, 'Invalid inputs' else: g = find_element_of_order(k,r) D = Integer(D) t = Integer(g) + 1 root_d = Integer(Mod(D, r).sqrt()) u = Integer(Mod((t-2)*root_d.inverse_mod(r) ,r)) q = 1 j = Integer(0) i = Integer(0) count = 0 while (count < max_trials): q = Integer( (t+i*r)**2 - D*(u + j*r)**2) if q % 4 ==0: q = q//4 if utils.is_suitable_q(q): return (q, t+i*r) q = 1 if random() < 0.5: j+=1 else: i+=1 count+=1 return (0, 0) # no prime found, so end
def method(r, k, D, max_trials=10000, g=0): """ Description: Run the Cocks-Pinch method to find an elliptic curve Input: r - prime k - embedding degree, r % k == 1 D - (negative) fundamental discriminant where D is a square mod r max_trials - the number of integers q to test for primality in the CP method g - an element of order k in Z_r^* Output: (q,t) - tuple where q is a prime and t is chosen such that there exists an elliptic curve E over F_q with trace t, and r | q+1-t; if the algorithm fails to find (q,t), it will return (0,0) """ assert test_promise(r, k, D), 'Invalid inputs' if g != 0: assert power_mod(g, k, r) == 1, 'Invalid inputs' else: g = find_element_of_order(k, r) D = Integer(D) t = Integer(g) + 1 root_d = Integer(Mod(D, r).sqrt()) u = Integer(Mod((t - 2) * root_d.inverse_mod(r), r)) q = 1 j = Integer(0) i = Integer(0) count = 0 while (count < max_trials): q = Integer((t + i * r)**2 - D * (u + j * r)**2) if q % 4 == 0: q = q // 4 if utils.is_suitable_q(q): return (q, t + i * r) q = 1 if random() < 0.5: j += 1 else: i += 1 count += 1 return (0, 0) # no prime found, so end