Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

195

196

197

198

199

200

201

202

203

204

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

220

221

222

223

224

225

226

227

228

229

230

231

232

233

234

235

236

237

238

239

240

241

242

243

244

245

246

247

248

249

250

251

252

253

254

255

256

257

258

259

260

261

262

263

264

265

266

267

268

269

270

271

272

273

274

275

276

277

278

279

280

281

282

283

284

285

286

287

288

289

290

291

292

293

294

295

296

297

298

299

300

301

302

303

304

305

306

307

308

309

310

311

312

313

314

315

316

317

318

319

320

321

322

323

324

325

326

327

328

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

357

358

359

360

361

362

363

364

365

366

367

368

369

370

371

372

373

374

375

376

377

378

379

380

381

382

383

384

385

386

387

388

389

390

391

392

393

394

395

396

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416

417

418

419

420

421

422

423

424

425

426

427

428

429

430

431

432

433

434

435

436

437

438

439

440

441

442

443

444

445

446

447

448

449

450

451

452

453

454

455

456

457

458

459

460

461

462

463

464

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485

486

487

488

489

490

491

492

493

494

495

496

497

498

499

500

501

502

503

504

505

506

507

508

509

510

511

512

513

514

515

516

517

518

519

520

521

522

523

524

525

526

527

528

529

530

531

532

533

534

535

536

537

538

539

540

541

542

543

544

545

546

547

548

549

550

551

552

553

554

555

556

557

558

559

560

561

562

563

564

565

566

567

568

569

570

571

572

573

574

575

576

577

578

579

580

581

582

583

584

585

586

587

588

589

590

591

592

593

594

595

596

597

598

599

600

601

602

603

604

605

606

607

608

609

610

611

612

613

614

615

616

617

618

619

620

621

622

623

624

625

626

627

628

629

630

631

632

633

634

635

636

637

638

639

640

641

642

643

644

645

646

647

648

649

650

651

652

653

654

655

656

657

658

659

660

661

662

663

664

665

666

667

668

669

670

671

672

673

674

675

676

677

678

679

680

681

682

683

684

685

686

687

688

689

690

691

692

693

694

695

696

697

698

699

700

701

702

703

704

705

706

707

708

709

710

711

712

713

714

715

716

717

718

719

720

721

722

723

724

725

726

727

728

729

730

731

732

733

734

735

736

737

738

739

740

741

742

743

744

745

746

747

748

749

750

751

752

753

754

755

756

757

758

759

760

761

762

763

764

765

766

767

768

769

770

771

772

773

774

775

776

777

778

779

780

781

782

783

784

785

786

787

788

789

790

791

792

793

794

795

796

797

798

799

800

801

802

803

804

805

806

807

808

809

810

811

812

813

814

815

816

817

818

819

820

821

822

823

824

825

826

827

828

829

830

831

832

833

834

835

836

837

838

839

840

841

842

843

844

845

846

847

848

849

850

851

852

853

854

855

856

857

858

859

860

861

862

863

864

865

866

867

868

869

870

871

872

873

874

875

876

877

878

879

880

881

882

883

884

885

886

887

888

889

890

891

892

893

894

895

896

897

898

899

900

901

902

903

904

905

906

907

908

909

910

911

912

913

914

915

916

917

918

919

920

921

922

923

924

925

926

927

928

929

930

931

932

933

934

935

936

937

938

939

940

941

942

943

944

945

946

947

948

949

950

951

952

953

954

955

956

957

958

959

960

961

962

963

964

965

966

967

968

969

970

971

972

973

974

975

976

977

978

979

980

981

982

983

984

985

986

987

988

989

990

991

992

993

994

995

996

997

998

999

1000

1001

1002

1003

1004

1005

1006

1007

1008

1009

1010

1011

1012

1013

1014

1015

1016

1017

1018

1019

1020

1021

1022

1023

1024

1025

1026

1027

1028

1029

1030

1031

1032

1033

1034

1035

1036

1037

1038

1039

1040

1041

1042

1043

1044

1045

1046

1047

1048

1049

1050

1051

1052

1053

1054

1055

1056

1057

1058

1059

1060

1061

1062

1063

1064

1065

1066

1067

1068

1069

1070

1071

1072

1073

1074

1075

1076

1077

1078

1079

1080

1081

1082

1083

1084

1085

1086

1087

1088

1089

1090

1091

1092

1093

1094

1095

1096

1097

1098

1099

1100

1101

1102

1103

1104

1105

1106

1107

1108

1109

1110

1111

1112

1113

1114

1115

1116

1117

1118

1119

1120

1121

1122

1123

1124

1125

1126

1127

1128

1129

1130

1131

1132

1133

1134

1135

1136

1137

1138

1139

1140

1141

1142

1143

1144

1145

1146

1147

1148

1149

1150

1151

1152

1153

1154

1155

1156

1157

1158

1159

1160

1161

1162

1163

1164

1165

1166

1167

1168

1169

1170

1171

1172

1173

1174

1175

1176

1177

1178

1179

1180

1181

1182

1183

1184

1185

1186

1187

1188

1189

1190

1191

1192

1193

1194

1195

1196

1197

1198

1199

1200

1201

1202

1203

1204

1205

1206

1207

1208

1209

1210

1211

1212

1213

1214

1215

1216

1217

1218

1219

1220

1221

1222

1223

1224

1225

1226

1227

1228

1229

1230

1231

1232

1233

1234

1235

1236

1237

1238

1239

1240

1241

1242

1243

1244

1245

1246

1247

1248

1249

1250

1251

1252

1253

1254

1255

1256

1257

1258

1259

1260

1261

1262

1263

1264

1265

1266

1267

1268

1269

1270

1271

1272

1273

1274

1275

1276

1277

1278

1279

1280

1281

1282

1283

1284

1285

1286

1287

1288

1289

1290

1291

1292

1293

1294

1295

1296

1297

1298

1299

1300

1301

1302

1303

1304

1305

1306

1307

1308

1309

1310

1311

1312

1313

1314

1315

1316

1317

1318

1319

1320

1321

1322

1323

1324

1325

1326

1327

1328

1329

1330

1331

1332

1333

1334

1335

1336

1337

1338

1339

1340

1341

1342

1343

1344

1345

1346

1347

1348

1349

1350

1351

1352

1353

1354

1355

1356

1357

1358

1359

1360

1361

1362

1363

1364

1365

1366

1367

1368

1369

1370

1371

1372

1373

1374

1375

1376

1377

1378

1379

1380

1381

1382

1383

1384

1385

1386

1387

1388

1389

1390

1391

1392

1393

1394

1395

1396

1397

1398

1399

1400

1401

1402

1403

1404

1405

1406

1407

1408

1409

1410

1411

1412

1413

1414

1415

1416

1417

1418

1419

1420

1421

1422

1423

1424

1425

1426

1427

1428

1429

1430

1431

1432

1433

1434

1435

1436

1437

1438

1439

1440

1441

1442

1443

1444

1445

1446

1447

1448

1449

1450

1451

1452

1453

1454

1455

1456

1457

1458

1459

1460

1461

1462

1463

1464

1465

1466

1467

1468

1469

1470

1471

1472

1473

1474

1475

1476

1477

1478

1479

1480

1481

1482

1483

1484

1485

1486

1487

1488

1489

1490

1491

1492

1493

1494

1495

1496

1497

1498

1499

1500

1501

1502

1503

1504

1505

1506

1507

1508

1509

1510

1511

1512

1513

1514

1515

1516

1517

1518

1519

1520

1521

1522

1523

1524

1525

1526

1527

1528

1529

1530

1531

1532

1533

1534

1535

1536

1537

1538

1539

1540

1541

1542

1543

1544

1545

1546

1547

1548

1549

1550

1551

1552

1553

1554

1555

1556

1557

1558

1559

1560

1561

1562

1563

1564

1565

1566

1567

1568

1569

1570

1571

1572

1573

1574

1575

1576

1577

1578

1579

1580

1581

1582

1583

1584

1585

1586

1587

1588

1589

1590

1591

1592

1593

1594

1595

1596

1597

1598

1599

1600

1601

1602

1603

1604

1605

1606

1607

1608

1609

1610

1611

1612

1613

1614

1615

1616

1617

1618

1619

1620

1621

1622

1623

1624

1625

1626

1627

1628

1629

1630

1631

1632

1633

1634

1635

1636

1637

1638

1639

1640

1641

1642

1643

1644

1645

1646

1647

1648

1649

1650

1651

1652

1653

1654

1655

1656

1657

1658

1659

1660

1661

1662

1663

1664

1665

1666

1667

1668

1669

1670

1671

1672

1673

1674

1675

1676

1677

1678

1679

1680

1681

1682

1683

1684

1685

1686

1687

1688

1689

1690

1691

1692

1693

1694

1695

1696

1697

1698

1699

1700

1701

1702

1703

1704

1705

1706

1707

1708

1709

1710

1711

1712

1713

1714

1715

1716

1717

1718

1719

1720

1721

1722

1723

1724

1725

1726

1727

1728

1729

1730

1731

1732

1733

1734

1735

1736

1737

1738

1739

1740

1741

1742

1743

1744

1745

1746

1747

1748

1749

1750

1751

1752

1753

1754

1755

1756

1757

1758

1759

1760

1761

1762

1763

1764

1765

1766

1767

1768

1769

1770

1771

1772

1773

1774

1775

1776

1777

1778

1779

1780

1781

1782

1783

1784

1785

1786

1787

1788

1789

1790

1791

1792

1793

1794

1795

1796

1797

1798

1799

1800

1801

1802

1803

1804

1805

1806

1807

1808

1809

1810

1811

1812

1813

1814

1815

1816

1817

1818

1819

1820

1821

1822

1823

1824

1825

1826

1827

1828

1829

1830

1831

1832

1833

1834

1835

1836

1837

1838

1839

1840

1841

1842

1843

1844

1845

1846

1847

1848

1849

1850

1851

1852

1853

1854

1855

1856

1857

1858

1859

1860

1861

1862

1863

1864

1865

1866

1867

1868

1869

1870

1871

1872

1873

1874

1875

1876

1877

1878

1879

1880

1881

1882

1883

1884

1885

1886

1887

1888

1889

1890

1891

1892

1893

1894

1895

1896

1897

1898

1899

1900

1901

1902

1903

1904

1905

1906

1907

1908

1909

1910

1911

1912

1913

1914

1915

1916

1917

1918

1919

1920

1921

1922

1923

1924

1925

1926

1927

1928

1929

1930

1931

1932

1933

1934

1935

1936

1937

1938

1939

1940

1941

1942

1943

1944

1945

1946

1947

1948

1949

1950

1951

1952

1953

1954

1955

1956

1957

1958

1959

1960

1961

1962

1963

1964

1965

1966

1967

1968

1969

1970

1971

1972

1973

1974

1975

1976

1977

1978

1979

1980

1981

1982

1983

1984

1985

1986

1987

1988

1989

1990

1991

1992

1993

1994

1995

1996

1997

1998

1999

2000

2001

2002

2003

2004

2005

2006

2007

2008

2009

2010

2011

2012

2013

2014

2015

2016

2017

2018

2019

2020

2021

2022

2023

2024

2025

2026

2027

2028

2029

2030

2031

2032

2033

2034

2035

2036

2037

2038

2039

2040

2041

2042

2043

2044

2045

2046

2047

2048

2049

2050

2051

2052

2053

2054

2055

2056

2057

2058

2059

2060

2061

2062

2063

2064

2065

2066

2067

2068

2069

2070

2071

2072

2073

2074

2075

2076

2077

2078

2079

2080

2081

2082

2083

2084

2085

2086

2087

2088

2089

2090

2091

2092

2093

2094

2095

2096

2097

2098

2099

2100

2101

2102

2103

2104

2105

2106

2107

2108

2109

2110

2111

2112

2113

2114

2115

2116

2117

2118

2119

2120

2121

2122

2123

2124

2125

2126

2127

2128

2129

2130

2131

2132

2133

2134

2135

2136

2137

2138

2139

2140

2141

2142

2143

2144

2145

2146

2147

2148

2149

2150

2151

2152

2153

2154

2155

2156

2157

2158

2159

2160

2161

2162

2163

2164

2165

2166

2167

2168

2169

2170

2171

2172

2173

2174

2175

2176

2177

2178

2179

2180

2181

2182

2183

2184

2185

2186

2187

2188

2189

2190

2191

2192

2193

2194

2195

2196

2197

2198

2199

2200

2201

2202

2203

2204

2205

2206

2207

2208

2209

2210

2211

2212

2213

2214

2215

2216

2217

2218

2219

2220

2221

2222

2223

2224

2225

2226

2227

2228

2229

2230

2231

2232

2233

2234

2235

2236

2237

2238

2239

2240

2241

2242

2243

2244

2245

2246

2247

2248

2249

2250

2251

2252

2253

2254

2255

2256

2257

2258

2259

2260

2261

2262

2263

2264

2265

2266

2267

2268

2269

2270

2271

2272

2273

2274

2275

2276

2277

2278

2279

2280

2281

2282

2283

2284

2285

2286

2287

2288

2289

2290

2291

2292

2293

2294

2295

2296

2297

2298

2299

2300

2301

2302

2303

2304

2305

2306

2307

2308

2309

2310

2311

2312

2313

2314

2315

2316

2317

2318

2319

2320

2321

2322

2323

2324

2325

2326

2327

2328

2329

2330

2331

2332

2333

2334

2335

2336

2337

2338

2339

2340

2341

2342

2343

2344

2345

2346

2347

2348

2349

2350

2351

2352

2353

2354

2355

2356

2357

2358

2359

2360

2361

2362

2363

2364

2365

2366

2367

2368

2369

2370

2371

2372

2373

2374

2375

2376

2377

2378

2379

2380

2381

2382

2383

2384

2385

2386

2387

2388

2389

2390

2391

2392

2393

2394

2395

2396

2397

2398

2399

2400

2401

2402

2403

2404

2405

2406

2407

2408

2409

2410

2411

2412

2413

2414

2415

2416

2417

2418

2419

2420

2421

2422

2423

2424

2425

2426

2427

2428

2429

2430

2431

2432

2433

2434

2435

2436

2437

2438

2439

2440

2441

2442

2443

2444

2445

2446

2447

2448

2449

2450

2451

2452

2453

2454

2455

2456

2457

2458

2459

2460

2461

2462

2463

2464

2465

2466

2467

2468

2469

2470

2471

2472

2473

2474

2475

2476

2477

2478

2479

2480

2481

2482

2483

2484

2485

2486

2487

2488

2489

2490

2491

2492

2493

2494

2495

2496

2497

2498

2499

2500

2501

2502

2503

2504

2505

2506

2507

2508

2509

2510

2511

2512

2513

2514

2515

2516

2517

2518

2519

2520

2521

2522

2523

2524

2525

2526

2527

2528

2529

2530

2531

2532

2533

2534

2535

2536

2537

2538

2539

2540

2541

2542

2543

2544

2545

2546

2547

2548

2549

2550

2551

2552

2553

2554

2555

2556

2557

2558

2559

2560

2561

2562

2563

2564

2565

2566

2567

2568

2569

2570

2571

2572

2573

2574

2575

2576

2577

2578

2579

2580

2581

2582

2583

2584

2585

2586

2587

2588

2589

2590

2591

2592

2593

2594

2595

2596

2597

2598

2599

2600

2601

2602

2603

2604

2605

2606

2607

2608

2609

2610

2611

2612

2613

2614

2615

2616

2617

2618

2619

2620

2621

2622

2623

2624

2625

2626

2627

2628

2629

2630

2631

2632

2633

2634

2635

2636

2637

2638

2639

2640

2641

2642

2643

2644

2645

2646

2647

2648

2649

2650

2651

2652

2653

2654

2655

2656

2657

2658

2659

2660

2661

2662

2663

2664

2665

2666

2667

2668

2669

2670

2671

2672

2673

2674

2675

2676

2677

2678

2679

2680

2681

2682

2683

2684

2685

2686

2687

2688

2689

2690

2691

2692

2693

2694

2695

2696

2697

2698

2699

2700

2701

2702

2703

2704

2705

2706

2707

2708

2709

2710

2711

2712

2713

2714

2715

2716

2717

2718

2719

2720

2721

2722

2723

2724

2725

2726

2727

2728

2729

2730

2731

2732

2733

2734

2735

2736

2737

2738

2739

2740

2741

2742

2743

2744

2745

2746

2747

2748

2749

2750

2751

2752

2753

2754

2755

2756

2757

2758

2759

2760

2761

2762

2763

2764

2765

2766

2767

2768

2769

2770

2771

2772

2773

2774

2775

2776

2777

2778

2779

2780

2781

2782

2783

2784

2785

2786

2787

2788

2789

2790

2791

2792

2793

2794

2795

2796

2797

2798

2799

2800

2801

2802

2803

2804

2805

2806

2807

2808

2809

2810

2811

2812

2813

2814

2815

2816

2817

2818

2819

2820

2821

2822

2823

2824

2825

2826

2827

2828

2829

2830

2831

2832

2833

2834

2835

2836

2837

2838

2839

2840

2841

2842

2843

2844

2845

2846

2847

2848

2849

2850

2851

2852

2853

2854

2855

2856

2857

2858

2859

2860

2861

2862

2863

2864

2865

2866

2867

2868

2869

2870

2871

2872

2873

2874

2875

2876

2877

2878

2879

2880

2881

2882

2883

2884

2885

2886

2887

2888

2889

2890

2891

2892

2893

2894

2895

2896

2897

2898

2899

2900

2901

2902

2903

2904

2905

2906

2907

2908

2909

2910

2911

2912

2913

2914

2915

2916

2917

2918

2919

2920

2921

2922

2923

2924

2925

2926

2927

2928

2929

2930

2931

2932

2933

2934

2935

2936

2937

2938

2939

2940

2941

2942

2943

2944

2945

2946

2947

2948

2949

2950

2951

2952

2953

2954

2955

2956

2957

2958

2959

2960

2961

2962

2963

2964

2965

2966

2967

2968

2969

2970

2971

2972

2973

2974

2975

2976

2977

2978

2979

2980

2981

2982

2983

2984

2985

2986

2987

2988

2989

2990

2991

2992

2993

2994

2995

2996

2997

2998

2999

3000

3001

3002

3003

3004

3005

3006

3007

3008

3009

3010

3011

3012

3013

3014

3015

3016

3017

3018

3019

3020

3021

3022

3023

3024

3025

3026

3027

3028

3029

3030

3031

3032

3033

3034

3035

3036

3037

3038

3039

3040

3041

3042

3043

3044

3045

3046

3047

3048

3049

3050

3051

3052

3053

3054

3055

3056

3057

3058

3059

3060

3061

3062

3063

3064

3065

3066

3067

3068

3069

3070

3071

3072

3073

3074

3075

3076

3077

3078

3079

3080

3081

3082

3083

3084

3085

3086

3087

3088

3089

3090

3091

3092

3093

3094

3095

3096

3097

3098

3099

3100

3101

3102

3103

3104

3105

3106

3107

3108

3109

3110

3111

3112

3113

3114

3115

3116

3117

3118

3119

3120

3121

3122

3123

3124

3125

3126

3127

3128

3129

3130

3131

3132

3133

3134

3135

3136

3137

3138

3139

3140

3141

3142

3143

3144

3145

3146

3147

3148

3149

3150

3151

3152

3153

3154

3155

3156

3157

3158

3159

3160

3161

3162

3163

3164

3165

3166

3167

3168

3169

3170

3171

3172

3173

3174

3175

3176

3177

3178

3179

3180

3181

3182

3183

3184

3185

3186

3187

3188

3189

3190

3191

3192

3193

3194

3195

3196

3197

3198

3199

3200

3201

3202

3203

3204

3205

3206

3207

3208

3209

3210

3211

3212

3213

3214

3215

3216

3217

3218

3219

3220

3221

3222

3223

3224

3225

3226

3227

3228

3229

3230

3231

3232

3233

3234

3235

3236

3237

3238

3239

3240

3241

3242

3243

3244

3245

3246

3247

3248

3249

3250

3251

3252

3253

3254

3255

3256

3257

3258

3259

3260

3261

3262

3263

3264

3265

3266

3267

3268

3269

3270

3271

3272

3273

3274

3275

3276

3277

3278

3279

3280

3281

3282

3283

3284

3285

3286

3287

3288

3289

3290

3291

3292

3293

3294

3295

3296

3297

3298

3299

3300

3301

3302

3303

3304

3305

3306

3307

3308

3309

3310

3311

3312

3313

3314

3315

3316

3317

3318

3319

3320

3321

3322

3323

3324

3325

3326

3327

3328

3329

3330

3331

3332

3333

3334

3335

3336

3337

3338

3339

3340

3341

3342

3343

3344

3345

3346

3347

3348

3349

3350

3351

3352

3353

3354

3355

3356

3357

3358

3359

3360

3361

3362

3363

3364

3365

3366

3367

3368

3369

3370

3371

3372

3373

3374

3375

3376

3377

3378

3379

3380

3381

3382

3383

3384

3385

3386

3387

3388

3389

3390

3391

3392

3393

3394

3395

3396

3397

3398

3399

3400

3401

3402

3403

3404

3405

3406

3407

3408

3409

3410

3411

3412

3413

3414

3415

3416

3417

3418

3419

3420

3421

3422

3423

3424

3425

3426

3427

3428

3429

3430

3431

3432

3433

3434

3435

3436

3437

3438

3439

3440

3441

3442

3443

3444

3445

3446

3447

3448

3449

3450

3451

3452

3453

3454

3455

3456

3457

3458

3459

3460

3461

3462

3463

3464

3465

3466

3467

3468

3469

3470

3471

3472

3473

3474

3475

3476

3477

3478

3479

3480

3481

3482

3483

3484

3485

3486

3487

3488

3489

3490

3491

3492

3493

3494

3495

3496

3497

3498

3499

3500

3501

3502

3503

3504

3505

3506

3507

3508

3509

3510

3511

3512

3513

3514

3515

3516

3517

3518

3519

3520

3521

3522

3523

3524

3525

3526

3527

3528

3529

3530

3531

3532

3533

3534

3535

3536

3537

3538

3539

3540

3541

3542

3543

3544

3545

3546

3547

3548

3549

3550

3551

3552

3553

3554

3555

3556

3557

3558

3559

3560

3561

3562

3563

3564

3565

3566

3567

3568

3569

3570

3571

3572

3573

3574

3575

3576

3577

3578

3579

3580

3581

3582

3583

3584

3585

3586

3587

3588

3589

3590

3591

3592

3593

3594

3595

3596

3597

3598

3599

3600

3601

3602

3603

3604

3605

3606

3607

3608

3609

3610

3611

3612

3613

3614

3615

3616

3617

3618

3619

3620

3621

3622

3623

3624

3625

3626

3627

3628

3629

3630

3631

3632

3633

3634

3635

3636

3637

3638

3639

3640

3641

3642

3643

3644

3645

3646

3647

3648

3649

3650

3651

3652

3653

3654

3655

3656

3657

3658

3659

3660

3661

3662

3663

3664

3665

3666

3667

3668

3669

3670

3671

3672

3673

3674

3675

3676

3677

3678

3679

3680

3681

3682

3683

3684

3685

3686

3687

3688

3689

3690

3691

3692

3693

3694

3695

3696

3697

3698

3699

3700

3701

3702

3703

3704

3705

3706

3707

3708

3709

3710

3711

3712

3713

3714

3715

3716

3717

3718

3719

3720

3721

3722

3723

3724

3725

3726

3727

3728

3729

3730

3731

3732

3733

3734

3735

3736

3737

3738

3739

3740

3741

3742

3743

3744

3745

3746

3747

3748

3749

3750

3751

3752

3753

3754

3755

3756

3757

3758

3759

3760

3761

3762

3763

3764

3765

3766

3767

3768

3769

3770

3771

3772

3773

3774

3775

3776

3777

3778

3779

3780

3781

3782

3783

3784

3785

3786

3787

3788

3789

3790

3791

3792

3793

3794

3795

3796

3797

3798

3799

3800

3801

3802

3803

3804

3805

3806

3807

3808

3809

3810

3811

3812

3813

3814

3815

3816

3817

3818

3819

3820

3821

3822

3823

3824

3825

3826

3827

3828

3829

3830

3831

3832

3833

3834

3835

3836

3837

3838

3839

3840

3841

3842

3843

3844

3845

3846

3847

3848

3849

3850

3851

3852

3853

3854

3855

3856

3857

3858

3859

3860

3861

3862

3863

3864

3865

3866

3867

3868

3869

3870

3871

3872

3873

3874

3875

3876

3877

3878

3879

3880

3881

3882

3883

3884

3885

3886

3887

3888

3889

3890

3891

3892

3893

3894

3895

3896

3897

3898

3899

3900

3901

3902

3903

3904

3905

3906

3907

3908

3909

3910

3911

3912

3913

3914

3915

3916

3917

3918

3919

3920

3921

3922

3923

3924

3925

3926

3927

3928

3929

3930

3931

3932

3933

3934

3935

3936

3937

3938

3939

3940

3941

3942

3943

3944

3945

3946

3947

3948

3949

3950

3951

3952

3953

3954

3955

3956

3957

3958

3959

3960

3961

3962

3963

3964

3965

3966

3967

3968

3969

3970

3971

3972

3973

3974

3975

3976

3977

3978

3979

3980

3981

3982

3983

3984

3985

3986

3987

3988

3989

3990

3991

3992

3993

3994

3995

3996

3997

3998

3999

4000

4001

4002

4003

4004

4005

4006

4007

4008

4009

4010

4011

4012

4013

4014

4015

4016

4017

4018

4019

4020

4021

4022

4023

4024

4025

4026

4027

4028

4029

4030

4031

4032

4033

4034

4035

4036

4037

4038

4039

4040

4041

4042

4043

4044

4045

4046

4047

4048

4049

4050

4051

4052

4053

4054

4055

4056

4057

4058

4059

4060

4061

4062

4063

4064

4065

4066

4067

4068

4069

4070

4071

4072

4073

4074

4075

4076

4077

4078

4079

4080

4081

4082

4083

4084

4085

4086

4087

4088

4089

4090

4091

4092

4093

4094

4095

4096

4097

4098

4099

4100

4101

4102

4103

4104

4105

4106

4107

4108

4109

4110

4111

4112

4113

4114

4115

4116

4117

4118

4119

4120

4121

4122

4123

4124

4125

4126

4127

4128

4129

4130

4131

4132

4133

4134

4135

4136

4137

4138

4139

4140

4141

4142

4143

4144

4145

4146

4147

4148

4149

4150

4151

4152

# -*- coding: utf-8 -*- 

r""" 

Isogenies 

 

An isogeny `\varphi: E_1\to E_2` between two elliptic curves `E_1` and 

`E_2` is a morphism of curves that sends the origin of `E_1` to the 

origin of `E_2`. Such a morphism is automatically a morphism of group 

schemes and the kernel is a finite subgroup scheme of `E_1`. Such a 

subscheme can either be given by a list of generators, which have to 

be torsion points, or by a polynomial in the coordinate `x` of the 

Weierstrass equation of `E_1`. 

 

The usual way to create and work with isogenies is illustrated with 

the following example:: 

 

sage: k = GF(11) 

sage: E = EllipticCurve(k,[1,1]) 

sage: Q = E(6,5) 

sage: phi = E.isogeny(Q) 

sage: phi 

Isogeny of degree 7 from Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 11 to Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 11 

sage: P = E(4,5) 

sage: phi(P) 

(10 : 0 : 1) 

sage: phi.codomain() 

Elliptic Curve defined by y^2 = x^3 + 7*x + 8 over Finite Field of size 11 

sage: phi.rational_maps() 

((x^7 + 4*x^6 - 3*x^5 - 2*x^4 - 3*x^3 + 3*x^2 + x - 2)/(x^6 + 4*x^5 - 4*x^4 - 5*x^3 + 5*x^2), (x^9*y - 5*x^8*y - x^7*y + x^5*y - x^4*y - 5*x^3*y - 5*x^2*y - 2*x*y - 5*y)/(x^9 - 5*x^8 + 4*x^6 - 3*x^4 + 2*x^3)) 

 

The functions directly accessible from an elliptic curve ``E`` over a 

field are ``isogeny`` and ``isogeny_codomain``. 

 

The most useful functions that apply to isogenies are 

 

- ``codomain`` 

- ``degree`` 

- ``domain`` 

- ``dual`` 

- ``rational_maps`` 

- ``kernel_polynomial`` 

 

.. WARNING:: 

 

Only cyclic, separable isogenies are implemented (except for [2]). Some 

algorithms may need the isogeny to be normalized. 

 

AUTHORS: 

 

- Daniel Shumow <shumow@gmail.com>: 2009-04-19: initial version 

 

- Chris Wuthrich : 7/09: changes: add check of input, not the full list is needed. 

10/09: eliminating some bugs. 

 

- John Cremona 2014-08-08: tidying of code and docstrings, systematic 

use of univariate vs. bivariate polynomials and rational functions. 

 

""" 

 

#***************************************************************************** 

# Copyright (C) 2009 Daniel Shumow <shumow@gmail.com> 

# 

# Distributed under the terms of the GNU General Public License (GPL) 

# http://www.gnu.org/licenses/ 

#***************************************************************************** 

from __future__ import print_function 

from six import itervalues 

from six.moves import range 

 

from copy import copy 

 

from sage.categories import homset 

 

from sage.categories.morphism import Morphism 

 

from sage.rings.all import PolynomialRing, Integer, ZZ, LaurentSeriesRing 

from sage.rings.polynomial.polynomial_element import is_Polynomial 

from sage.schemes.elliptic_curves.all import EllipticCurve 

from sage.schemes.elliptic_curves.ell_generic import is_EllipticCurve 

 

from sage.rings.number_field.number_field_base import is_NumberField 

 

from sage.rings.rational_field import is_RationalField, QQ 

 

from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism, isomorphisms 

 

from sage.sets.set import Set 

from sage.structure.richcmp import richcmp_not_equal, richcmp 

from sage.misc.cachefunc import cached_function 

 

# 

# Private function for parsing input to determine the type of 

# algorithm 

# 

def isogeny_determine_algorithm(E, kernel): 

r""" 

Helper function that allows the various isogeny functions to infer 

the algorithm type from the parameters passed in. 

 

INPUT: 

 

- ``E`` (elliptic curve) -- an elliptic curve 

 

- ``kernel`` -- either a list of points on ``E``, or a univariate 

polynomial or list of coefficients of a univariate polynomial. 

 

OUTPUT: 

 

(string) either 'velu' or 'kohel' 

 

If ``kernel`` is a list of points on the EllipticCurve `E`, then 

we will try to use Velu's algorithm. 

 

If ``kernel`` is a list of coefficients or a univariate 

polynomial, we will try to use the Kohel's algorithms. 

 

EXAMPLES: 

 

This helper function will be implicitly called by the following examples:: 

 

sage: R.<x> = GF(5)[] 

sage: E = EllipticCurve(GF(5), [0,0,0,1,0]) 

 

We can construct the same isogeny from a kernel polynomial:: 

 

sage: phi = EllipticCurveIsogeny(E, x+3) 

 

or from a list of coefficients of a kernel polynomial:: 

 

sage: phi == EllipticCurveIsogeny(E, [3,1]) 

True 

 

or from a rational point which generates the kernel:: 

 

sage: phi == EllipticCurveIsogeny(E, E((2,0)) ) 

True 

 

In the first two cases, Kohel's algorithm will be used, while in 

the third case it is Velu:: 

 

sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import isogeny_determine_algorithm 

sage: isogeny_determine_algorithm(E, x+3) 

'kohel' 

sage: isogeny_determine_algorithm(E, [3, 1]) 

'kohel' 

sage: isogeny_determine_algorithm(E, E((2,0))) 

'velu' 

""" 

kernel_is_list = isinstance(kernel, list) 

 

if not kernel_is_list and kernel in E : 

kernel = [kernel] 

kernel_is_list = True 

 

if (is_Polynomial(kernel) or ( kernel_is_list) and (kernel[0] in E.base_ring()) ): 

algorithm = "kohel" 

elif (kernel_is_list) and (kernel[0] in E): 

# note that if kernel[0] is on an extension of E this 

# condition will be false 

algorithm = "velu" 

else: 

raise ValueError("Invalid Parameters to EllipticCurveIsogeny constructor.") 

return algorithm 

 

def isogeny_codomain_from_kernel(E, kernel, degree=None): 

r""" 

Compute the isogeny codomain given a kernel. 

 

INPUT: 

 

- ``E`` - The domain elliptic curve. 

 

- ``kernel`` - Either a list of points in the kernel of the isogeny, or a 

kernel polynomial (specified as a either a univariate 

polynomial or a coefficient list.) 

 

- ``degree`` - an integer, (default:``None``) optionally specified degree 

of the kernel. 

 

OUTPUT: 

 

(elliptic curve) the codomain of the separable normalized isogeny 

from this kernel 

 

EXAMPLES:: 

 

sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import isogeny_codomain_from_kernel 

sage: E = EllipticCurve(GF(7), [1,0,1,0,1]) 

sage: R.<x> = GF(7)[] 

sage: isogeny_codomain_from_kernel(E, [4,1], degree=3) 

Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + 6 over Finite Field of size 7 

sage: EllipticCurveIsogeny(E, [4,1]).codomain() == isogeny_codomain_from_kernel(E, [4,1], degree=3) 

True 

sage: isogeny_codomain_from_kernel(E, x^3 + x^2 + 4*x + 3) 

Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + 6 over Finite Field of size 7 

sage: isogeny_codomain_from_kernel(E, x^3 + 2*x^2 + 4*x + 3) 

Elliptic Curve defined by y^2 + x*y + y = x^3 + 5*x + 2 over Finite Field of size 7 

 

sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) 

sage: kernel_list = [E((15,10)), E((10,3)),E((6,5))] 

sage: isogeny_codomain_from_kernel(E, kernel_list) 

Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 3*x + 15 over Finite Field of size 19 

 

""" 

 

algorithm = isogeny_determine_algorithm(E, kernel) 

 

if ("velu"==algorithm): 

# if we are using Velu's formula, just instantiate the isogeny 

# and return the codomain 

return EllipticCurveIsogeny(E, kernel).codomain() 

elif ("kohel"==algorithm): 

return compute_codomain_kohel(E, kernel, degree) 

 

def compute_codomain_formula(E, v, w): 

r""" 

Compute the codomain curve given parameters `v` and `w` (as in 

Velu / Kohel / etc formulas). 

 

INPUT: 

 

- ``E`` -- an elliptic curve 

 

- ``v``, ``w`` -- elements of the base field of ``E`` 

 

OUTPUT: 

 

The elliptic curve with invariants 

`[a_1,a_2,a_3,a_4-5v,a_6-(a_1^2+4a_2)v-7w]` where 

`E=[a_1,a_2,a_3,a_4,a_6]`. 

 

EXAMPLES: 

 

This formula is used by every Isogeny instantiation:: 

 

sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) 

sage: phi = EllipticCurveIsogeny(E, E((1,2)) ) 

sage: phi.codomain() 

Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 9*x + 13 over Finite Field of size 19 

sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_codomain_formula 

sage: v = phi._EllipticCurveIsogeny__v 

sage: w = phi._EllipticCurveIsogeny__w 

sage: compute_codomain_formula(E, v, w) == phi.codomain() 

True 

""" 

a1,a2,a3,a4,a6 = E.ainvs() 

 

A4 = a4 - 5*v 

A6 = a6 - (a1**2 + 4*a2)*v - 7*w 

 

return EllipticCurve([a1, a2, a3, A4, A6]) 

 

def compute_vw_kohel_even_deg1(x0, y0, a1, a2, a4): 

r""" 

Compute Velu's (v,w) using Kohel's formulas for isogenies of 

degree exactly divisible by 2. 

 

INPUT: 

 

- ``x0``, ``y0`` -- coordinates of a 2-torsion point on an elliptic curve E 

 

- ``a1``, ``a2``, ``a4`` -- invariants of E 

 

OUTPUT: 

 

(tuple) Velu's isogeny parameters (v,w). 

 

EXAMPLES: 

 

This function will be implicitly called by the following example:: 

 

sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) 

sage: phi = EllipticCurveIsogeny(E, [9,1]); phi 

Isogeny of degree 2 from Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Finite Field of size 19 to Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 9*x + 8 over Finite Field of size 19 

sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_vw_kohel_even_deg1 

sage: a1,a2,a3,a4,a6 = E.ainvs() 

sage: x0 = -9 

sage: y0 = -(a1*x0 + a3)/2 

sage: compute_vw_kohel_even_deg1(x0, y0, a1, a2, a4) 

(18, 9) 

""" 

v = (3*x0**2 + 2*a2*x0 + a4 - a1*y0) 

w = x0*v 

 

return (v,w) 

 

def compute_vw_kohel_even_deg3(b2,b4,s1,s2,s3): 

r""" 

Compute Velu's (v,w) using Kohel's formulas for isogenies of 

degree divisible by 4. 

 

INPUT: 

 

- ``b2``, ``b4`` -- invariants of an elliptic curve E 

 

- ``s1``, ``s2``, ``s3`` -- signed coefficients of the 2-division 

polynomial of E 

 

OUTPUT: 

 

(tuple) Velu's isogeny parameters (v,w). 

 

EXAMPLES: 

 

This function will be implicitly called by the following example:: 

 

sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) 

sage: R.<x> = GF(19)[] 

sage: phi = EllipticCurveIsogeny(E, x^3 + 7*x^2 + 15*x + 12); phi 

Isogeny of degree 4 from Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Finite Field of size 19 to Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 3*x + 15 over Finite Field of size 19 

sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_vw_kohel_even_deg3 

sage: (b2,b4) = (E.b2(), E.b4()) 

sage: (s1, s2, s3) = (-7, 15, -12) 

sage: compute_vw_kohel_even_deg3(b2, b4, s1, s2, s3) 

(4, 7) 

""" 

temp1 = (s1**2 - 2*s2) 

v = 3*temp1 + b2*s1/2 + 3*b4/2 

w = 3*(s1**3 - 3*s1*s2 + 3*s3) + b2*temp1/2 + b4*s1/2 

 

return (v,w) 

 

 

def compute_vw_kohel_odd(b2,b4,b6,s1,s2,s3,n): 

r""" 

Compute Velu's (v,w) using Kohel's formulas for isogenies of odd 

degree. 

 

INPUT: 

 

- ``b2``, ``b4``, ``b6`` -- invariants of an elliptic curve E 

 

- ``s1``, ``s2``, ``s3`` -- signed coefficients of lowest powers 

of x in the kernel polynomial. 

 

- ``n`` (int) -- the degree 

 

OUTPUT: 

 

(tuple) Velu's isogeny parameters (v,w). 

 

EXAMPLES: 

 

This function will be implicitly called by the following example:: 

 

sage: E = EllipticCurve(GF(19), [18,17,16,15,14]) 

sage: R.<x> = GF(19)[] 

sage: phi = EllipticCurveIsogeny(E, x^3 + 14*x^2 + 3*x + 11); phi 

Isogeny of degree 7 from Elliptic Curve defined by y^2 + 18*x*y + 16*y = x^3 + 17*x^2 + 15*x + 14 over Finite Field of size 19 to Elliptic Curve defined by y^2 + 18*x*y + 16*y = x^3 + 17*x^2 + 18*x + 18 over Finite Field of size 19 

sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_vw_kohel_odd 

sage: (b2,b4,b6) = (E.b2(), E.b4(), E.b6()) 

sage: (s1,s2,s3) = (-14,3,-11) 

sage: compute_vw_kohel_odd(b2,b4,b6,s1,s2,s3,3) 

(7, 1) 

 

""" 

v = 6*(s1**2 - 2*s2) + b2*s1 + n*b4 

w = 10*(s1**3 - 3*s1*s2 + 3*s3) + 2*b2*(s1**2 - 2*s2) + 3*b4*s1 + n*b6 

 

return (v,w) 

 

 

def compute_codomain_kohel(E, kernel, degree): 

r""" 

Compute the codomain from the kernel polynomial using Kohel's 

formulas. 

 

INPUT: 

 

- ``E`` -- an elliptic curve 

 

- ``kernel`` (polynomial or list) -- the kernel polynomial, or a 

list of its coefficients 

 

- ``degree`` (int) -- degree of the isogeny 

 

OUTPUT: 

 

(elliptic curve) -- the codomain elliptic curve ``E``/``kernel`` 

 

EXAMPLES:: 

 

sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_codomain_kohel 

sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) 

sage: phi = EllipticCurveIsogeny(E, [9,1]) 

sage: phi.codomain() == isogeny_codomain_from_kernel(E, [9,1]) 

True 

sage: compute_codomain_kohel(E, [9,1], 2) 

Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 9*x + 8 over Finite Field of size 19 

sage: R.<x> = GF(19)[] 

sage: E = EllipticCurve(GF(19), [18,17,16,15,14]) 

sage: phi = EllipticCurveIsogeny(E, x^3 + 14*x^2 + 3*x + 11) 

sage: phi.codomain() == isogeny_codomain_from_kernel(E, x^3 + 14*x^2 + 3*x + 11) 

True 

sage: compute_codomain_kohel(E, x^3 + 14*x^2 + 3*x + 11, 7) 

Elliptic Curve defined by y^2 + 18*x*y + 16*y = x^3 + 17*x^2 + 18*x + 18 over Finite Field of size 19 

sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) 

sage: phi = EllipticCurveIsogeny(E, x^3 + 7*x^2 + 15*x + 12) 

sage: isogeny_codomain_from_kernel(E, x^3 + 7*x^2 + 15*x + 12) == phi.codomain() 

True 

sage: compute_codomain_kohel(E, x^3 + 7*x^2 + 15*x + 12,4) 

Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 3*x + 15 over Finite Field of size 19 

 

.. NOTE:: 

 

This function uses the formulas of Section 2.4 of [K96]_. 

 

REFERENCES: 

 

.. [K96] Kohel, "Endomorphism Rings of Elliptic Curves over Finite 

Fields", UC Berkeley PhD thesis 1996. 

 

""" 

# First set up the polynomial ring 

 

base_field = E.base_ring() 

poly_ring = PolynomialRing(base_field,'x') 

 

if (is_Polynomial(kernel)): 

psi = poly_ring(kernel) 

kernel_list = psi.list() 

elif isinstance(kernel, list) and (kernel[0] in base_field): 

kernel_list = kernel 

psi = poly_ring(kernel_list) 

else: 

raise ValueError("Invalid input to compute_codomain_kohel") 

 

# next determine the even / odd part of the isogeny 

psi_2tor = two_torsion_part(E, psi) 

 

if (0 != psi_2tor.degree()): # even degree case 

 

psi_quo = psi//psi_2tor 

 

if (0 != psi_quo.degree()): 

raise ArithmeticError("For basic Kohel's algorithm, if the kernel degree is even then the kernel must be contained in the two torsion.") 

 

n = psi_2tor.degree() 

 

if (1 == n): # degree divisible exactly by 2 

 

a1,a2,a3,a4,a6 = E.ainvs() 

 

x0 = -psi_2tor.constant_coefficient() 

 

# determine y0 

if (2 == base_field.characteristic()): 

y0 = (x0**3 + a2*x0**2 + a4*x0 + a6).sqrt() 

else: 

y0 = -(a1*x0 + a3)/2 

 

# now (x0,y0) is the 2-torsion point in the kernel 

 

(v,w) = compute_vw_kohel_even_deg1(x0,y0,a1,a2,a4) 

 

elif (3 == n): # psi_2tor is the full 2-division polynomial 

 

b2 = E.b2() 

b4 = E.b4() 

 

s = psi_2tor.list() 

s1 = -s[n-1] 

s2 = s[n-2] 

s3 = -s[n-3] 

 

(v,w) = compute_vw_kohel_even_deg3(b2,b4,s1,s2,s3) 

 

else: # odd degree case 

 

n = psi.degree() 

 

b2 = E.b2() 

b4 = E.b4() 

b6 = E.b6() 

 

s1 = 0; s2 = 0; s3 = 0 

 

if (1 <= n): 

s1 = -kernel_list[n-1] 

 

if (2 <= n): 

s2 = kernel_list[n-2] 

 

if (3 <= n): 

s3 = -kernel_list[n-3] 

 

# initializing these allows us to calculate E2. 

(v,w) = compute_vw_kohel_odd(b2,b4,b6,s1,s2,s3,n) 

 

return compute_codomain_formula(E, v, w) 

 

 

def two_torsion_part(E, psi): 

r""" 

Returns the greatest common divisor of ``psi`` and the 2 torsion 

polynomial of `E`. 

 

INPUT: 

 

- ``E`` -- an elliptic curve 

 

- ``psi`` -- a univariate polynomial over the base field of ``E`` 

 

OUTPUT: 

 

(polynomial) the gcd of psi and the 2-torsion polynomial of ``E``. 

 

EXAMPLES: 

 

Every function that computes the kernel polynomial via Kohel's 

formulas will call this function:: 

 

sage: E = EllipticCurve(GF(19), [1,2,3,4,5]) 

sage: R.<x> = GF(19)[] 

sage: phi = EllipticCurveIsogeny(E, x + 13) 

sage: isogeny_codomain_from_kernel(E, x + 13) == phi.codomain() 

True 

sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import two_torsion_part 

sage: two_torsion_part(E, x+13) 

x + 13 

 

""" 

x = psi.parent().gen() # NB psi is univariate but could be constant 

psi_2 = E.two_division_polynomial(x) 

return psi.gcd(psi_2) 

 

class EllipticCurveIsogeny(Morphism): 

r""" 

Class Implementing Isogenies of Elliptic Curves 

 

This class implements cyclic, separable, normalized isogenies of 

elliptic curves. 

 

Several different algorithms for computing isogenies are 

available. These include: 

 

- Velu's Formulas: Velu's original formulas for computing 

isogenies. This algorithm is selected by giving as the 

``kernel`` parameter a list of points which generate a finite 

subgroup. 

 

- Kohel's Formulas: Kohel's original formulas for computing 

isogenies. This algorithm is selected by giving as the 

``kernel`` parameter a monic polynomial (or a coefficient list 

(little endian)) which will define the kernel of the isogeny. 

 

INPUT: 

 

- ``E`` -- an elliptic curve, the domain of the isogeny to 

initialize. 

 

- ``kernel`` -- a kernel, either a point in ``E``, a list of 

points in ``E``, a monic kernel polynomial, or ``None``. If 

initializing from a domain/codomain, this must be set to None. 

 

- ``codomain`` -- an elliptic curve (default:``None``). If 

``kernel`` is ``None``, then this must be the codomain of a 

cyclic, separable, normalized isogeny, furthermore, ``degree`` 

must be the degree of the isogeny from ``E`` to ``codomain``. If 

``kernel`` is not ``None``, then this must be isomorphic to the 

codomain of the cyclic normalized separable isogeny defined by 

``kernel``, in this case, the isogeny is post composed with an 

isomorphism so that this parameter is the codomain. 

 

- ``degree`` -- an integer (default:``None``). If ``kernel`` is 

``None``, then this is the degree of the isogeny from ``E`` to 

``codomain``. If ``kernel`` is not ``None``, then this is used 

to determine whether or not to skip a gcd of the kernel 

polynomial with the two torsion polynomial of ``E``. 

 

- ``model`` -- a string (default:``None``). Only supported 

variable is ``minimal``, in which case if ``E`` is a curve over 

the rationals or over a number field, then the codomain is a 

global minimum model where this exists. 

 

- ``check`` (default: ``True``) checks if the input is valid to 

define an isogeny 

 

EXAMPLES: 

 

A simple example of creating an isogeny of a field of small 

characteristic:: 

 

sage: E = EllipticCurve(GF(7), [0,0,0,1,0]) 

sage: phi = EllipticCurveIsogeny(E, E((0,0)) ); phi 

Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 3*x over Finite Field of size 7 

sage: phi.degree() == 2 

True 

sage: phi.kernel_polynomial() 

x 

sage: phi.rational_maps() 

((x^2 + 1)/x, (x^2*y - y)/x^2) 

sage: phi == loads(dumps(phi)) # known bug 

True 

 

A more complicated example of a characteristic 2 field:: 

 

sage: E = EllipticCurve(GF(2^4,'alpha'), [0,0,1,0,1]) 

sage: P = E((1,1)) 

sage: phi_v = EllipticCurveIsogeny(E, P); phi_v 

Isogeny of degree 3 from Elliptic Curve defined by y^2 + y = x^3 + 1 over Finite Field in alpha of size 2^4 to Elliptic Curve defined by y^2 + y = x^3 over Finite Field in alpha of size 2^4 

sage: phi_ker_poly = phi_v.kernel_polynomial() 

sage: phi_ker_poly 

x + 1 

sage: ker_poly_list = phi_ker_poly.list() 

sage: phi_k = EllipticCurveIsogeny(E, ker_poly_list) 

sage: phi_k == phi_v 

True 

sage: phi_k.rational_maps() 

((x^3 + x + 1)/(x^2 + 1), (x^3*y + x^2*y + x*y + x + y)/(x^3 + x^2 + x + 1)) 

sage: phi_v.rational_maps() 

((x^3 + x + 1)/(x^2 + 1), (x^3*y + x^2*y + x*y + x + y)/(x^3 + x^2 + x + 1)) 

sage: phi_k.degree() == phi_v.degree() == 3 

True 

sage: phi_k.is_separable() 

True 

sage: phi_v(E(0)) 

(0 : 1 : 0) 

sage: alpha = E.base_field().gen() 

sage: Q = E((0, alpha*(alpha + 1))) 

sage: phi_v(Q) 

(1 : alpha^2 + alpha : 1) 

sage: phi_v(P) == phi_k(P) 

True 

sage: phi_k(P) == phi_v.codomain()(0) 

True 

 

We can create an isogeny that has kernel equal to the full 2 

torsion:: 

 

sage: E = EllipticCurve(GF(3), [0,0,0,1,1]) 

sage: ker_list = E.division_polynomial(2).list() 

sage: phi = EllipticCurveIsogeny(E, ker_list); phi 

Isogeny of degree 4 from Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 3 to Elliptic Curve defined by y^2 = x^3 + x + 1 over Finite Field of size 3 

sage: phi(E(0)) 

(0 : 1 : 0) 

sage: phi(E((0,1))) 

(1 : 0 : 1) 

sage: phi(E((0,2))) 

(1 : 0 : 1) 

sage: phi(E((1,0))) 

(0 : 1 : 0) 

sage: phi.degree() 

4 

 

We can also create trivial isogenies with the trivial kernel:: 

 

sage: E = EllipticCurve(GF(17), [11, 11, 4, 12, 10]) 

sage: phi_v = EllipticCurveIsogeny(E, E(0)) 

sage: phi_v.degree() 

1 

sage: phi_v.rational_maps() 

(x, y) 

sage: E == phi_v.codomain() 

True 

sage: P = E.random_point() 

sage: phi_v(P) == P 

True 

 

sage: E = EllipticCurve(GF(31), [23, 1, 22, 7, 18]) 

sage: phi_k = EllipticCurveIsogeny(E, [1]); phi_k 

Isogeny of degree 1 from Elliptic Curve defined by y^2 + 23*x*y + 22*y = x^3 + x^2 + 7*x + 18 over Finite Field of size 31 to Elliptic Curve defined by y^2 + 23*x*y + 22*y = x^3 + x^2 + 7*x + 18 over Finite Field of size 31 

sage: phi_k.degree() 

1 

sage: phi_k.rational_maps() 

(x, y) 

sage: phi_k.codomain() == E 

True 

sage: phi_k.kernel_polynomial() 

1 

sage: P = E.random_point(); P == phi_k(P) 

True 

 

Velu and Kohel also work in characteristic 0:: 

 

sage: E = EllipticCurve(QQ, [0,0,0,3,4]) 

sage: P_list = E.torsion_points() 

sage: phi = EllipticCurveIsogeny(E, P_list); phi 

Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 3*x + 4 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 27*x + 46 over Rational Field 

sage: P = E((0,2)) 

sage: phi(P) 

(6 : -10 : 1) 

sage: phi_ker_poly = phi.kernel_polynomial() 

sage: phi_ker_poly 

x + 1 

sage: ker_poly_list = phi_ker_poly.list() 

sage: phi_k = EllipticCurveIsogeny(E, ker_poly_list); phi_k 

Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 3*x + 4 over Rational Field to Elliptic Curve defined by y^2 = x^3 - 27*x + 46 over Rational Field 

sage: phi_k(P) == phi(P) 

True 

sage: phi_k == phi 

True 

sage: phi_k.degree() 

2 

sage: phi_k.is_separable() 

True 

 

A more complicated example over the rationals (of odd degree):: 

 

sage: E = EllipticCurve('11a1') 

sage: P_list = E.torsion_points() 

sage: phi_v = EllipticCurveIsogeny(E, P_list); phi_v 

Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - x^2 - 7820*x - 263580 over Rational Field 

sage: P = E((16,-61)) 

sage: phi_v(P) 

(0 : 1 : 0) 

sage: ker_poly = phi_v.kernel_polynomial(); ker_poly 

x^2 - 21*x + 80 

sage: ker_poly_list = ker_poly.list() 

sage: phi_k = EllipticCurveIsogeny(E, ker_poly_list); phi_k 

Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - x^2 - 7820*x - 263580 over Rational Field 

sage: phi_k == phi_v 

True 

sage: phi_v(P) == phi_k(P) 

True 

sage: phi_k.is_separable() 

True 

 

We can also do this same example over the number field defined by 

the irreducible two torsion polynomial of `E`:: 

 

sage: E = EllipticCurve('11a1') 

sage: P_list = E.torsion_points() 

sage: K.<alpha> = NumberField(x^3 - 2* x^2 - 40*x - 158) 

sage: EK = E.change_ring(K) 

sage: P_list = [EK(P) for P in P_list] 

sage: phi_v = EllipticCurveIsogeny(EK, P_list); phi_v 

Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in alpha with defining polynomial x^3 - 2*x^2 - 40*x - 158 to Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-7820)*x + (-263580) over Number Field in alpha with defining polynomial x^3 - 2*x^2 - 40*x - 158 

sage: P = EK((alpha/2,-1/2)) 

sage: phi_v(P) 

(122/121*alpha^2 + 1633/242*alpha - 3920/121 : -1/2 : 1) 

sage: ker_poly = phi_v.kernel_polynomial() 

sage: ker_poly 

x^2 - 21*x + 80 

sage: ker_poly_list = ker_poly.list() 

sage: phi_k = EllipticCurveIsogeny(EK, ker_poly_list) 

sage: phi_k 

Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-10)*x + (-20) over Number Field in alpha with defining polynomial x^3 - 2*x^2 - 40*x - 158 to Elliptic Curve defined by y^2 + y = x^3 + (-1)*x^2 + (-7820)*x + (-263580) over Number Field in alpha with defining polynomial x^3 - 2*x^2 - 40*x - 158 

sage: phi_v == phi_k 

True 

sage: phi_k(P) == phi_v(P) 

True 

sage: phi_k == phi_v 

True 

sage: phi_k.degree() 

5 

sage: phi_v.is_separable() 

True 

 

The following example shows how to specify an isogeny from domain 

and codomain:: 

 

sage: E = EllipticCurve('11a1') 

sage: R.<x> = QQ[] 

sage: f = x^2 - 21*x + 80 

sage: phi = E.isogeny(f) 

sage: E2 = phi.codomain() 

sage: phi_s = EllipticCurveIsogeny(E, None, E2, 5) 

sage: phi_s 

Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - x^2 - 7820*x - 263580 over Rational Field 

sage: phi_s == phi 

True 

sage: phi_s.rational_maps() == phi.rational_maps() 

True 

 

However only cyclic normalized isogenies can be constructed this 

way. So it won't find the isogeny [3]:: 

 

sage: E.isogeny(None, codomain=E,degree=9) 

Traceback (most recent call last): 

... 

ValueError: The two curves are not linked by a cyclic normalized isogeny of degree 9 

 

Also the presumed isogeny between the domain and codomain must be 

normalized:: 

 

sage: E2.isogeny(None,codomain=E,degree=5) 

Traceback (most recent call last): 

... 

ValueError: The two curves are not linked by a cyclic normalized isogeny of degree 5 

sage: phihat = phi.dual(); phihat 

Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 - x^2 - 7820*x - 263580 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field 

sage: phihat.is_normalized() 

False 

 

Here an example of a construction of a endomorphisms with cyclic 

kernel on a CM-curve:: 

 

sage: K.<i> = NumberField(x^2+1) 

sage: E = EllipticCurve(K, [1,0]) 

sage: RK.<X> = K[] 

sage: f = X^2 - 2/5*i + 1/5 

sage: phi= E.isogeny(f) 

sage: isom = phi.codomain().isomorphism_to(E) 

sage: phi.set_post_isomorphism(isom) 

sage: phi.codomain() == phi.domain() 

True 

sage: phi.rational_maps() 

(((4/25*i + 3/25)*x^5 + (4/5*i - 2/5)*x^3 - x)/(x^4 + (-4/5*i + 2/5)*x^2 + (-4/25*i - 3/25)), ((11/125*i + 2/125)*x^6*y + (-23/125*i + 64/125)*x^4*y + (141/125*i + 162/125)*x^2*y + (3/25*i - 4/25)*y)/(x^6 + (-6/5*i + 3/5)*x^4 + (-12/25*i - 9/25)*x^2 + (2/125*i - 11/125))) 

 

Domain and codomain tests (see :trac:`12880`):: 

 

sage: E = EllipticCurve(QQ, [0,0,0,1,0]) 

sage: phi = EllipticCurveIsogeny(E, E(0,0)) 

sage: phi.domain() == E 

True 

sage: phi.codomain() 

Elliptic Curve defined by y^2 = x^3 - 4*x over Rational Field 

 

sage: E = EllipticCurve(GF(31), [1,0,0,1,2]) 

sage: phi = EllipticCurveIsogeny(E, [17, 1]) 

sage: phi.domain() 

Elliptic Curve defined by y^2 + x*y = x^3 + x + 2 over Finite Field of size 31 

sage: phi.codomain() 

Elliptic Curve defined by y^2 + x*y = x^3 + 24*x + 6 over Finite Field of size 31 

 

Composition tests (see :trac:`16245`):: 

 

sage: E = EllipticCurve(j=GF(7)(0)) 

sage: phi = E.isogeny([E(0), E((0,1)), E((0,-1))]); phi 

Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 7 

sage: phi2 = phi * phi; phi2 

Composite map: 

From: Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 7 

To: Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 7 

Defn: Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 7 

then 

Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 7 

 

Examples over relative number fields used not to work (see :trac:`16779`):: 

 

sage: pol26 = hilbert_class_polynomial(-4*26) 

sage: pol = NumberField(pol26,'a').optimized_representation()[0].polynomial() 

sage: K.<a> = NumberField(pol) 

sage: j = pol26.roots(K)[0][0] 

sage: E = EllipticCurve(j=j) 

sage: L.<b> = K.extension(x^2+26) 

sage: EL = E.change_ring(L) 

sage: iso2 = EL.isogenies_prime_degree(2); len(iso2) 

1 

sage: iso3 = EL.isogenies_prime_degree(3); len(iso3) 

2 

 

Examples over function fields used not to work (see :trac:`11327`):: 

 

sage: F.<t> = FunctionField(QQ) 

sage: E = EllipticCurve([0,0,0,-t^2,0]) 

sage: isogs = E.isogenies_prime_degree(2) 

sage: isogs[0] 

Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + (-t^2)*x over Rational function field in t over Rational Field to Elliptic Curve defined by y^2 = x^3 + 4*t^2*x over Rational function field in t over Rational Field 

sage: isogs[0].rational_maps() 

((x^2 - t^2)/x, (x^2*y + t^2*y)/x^2) 

sage: duals = [phi.dual() for phi in isogs] 

sage: duals[0] 

Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 4*t^2*x over Rational function field in t over Rational Field to Elliptic Curve defined by y^2 = x^3 + (-t^2)*x over Rational function field in t over Rational Field 

sage: duals[0].rational_maps() 

((1/4*x^2 + t^2)/x, (1/8*x^2*y + (-1/2*t^2)*y)/x^2) 

sage: duals[0] 

Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 4*t^2*x over Rational function field in t over Rational Field to Elliptic Curve defined by y^2 = x^3 + (-t^2)*x over Rational function field in t over Rational Field 

""" 

 

#################### 

# member variables 

#################### 

 

__check = None 

# 

# variables common to all algorithms 

# 

__E1 = None # domain curve 

__E2 = None # codomain curve 

 

__degree = None 

 

__separable = True # This class only implements separable isogenies (for now.) 

 

__algorithm = None 

 

__this_hash = None 

 

__check = None 

# 

# pre isomorphism 

# 

__intermediate_domain = None 

__pre_isomorphism = None 

__prei_x_coord_ratl_map = None 

__prei_y_coord_ratl_map = None 

 

# 

# post isomorphism 

# 

 

__intermediate_codomain = None 

__post_isomorphism = None 

__posti_x_coord_ratl_map = None 

__posti_y_coord_ratl_map = None 

 

# 

# algebraic structs 

# 

__base_field = None 

__poly_ring = None # univariate in x over __base_field 

__mpoly_ring = None # bivariate in x, y over __base_field 

 

# 

# Rational Maps 

# 

__rational_maps_initialized = False 

__X_coord_rational_map = None 

__Y_coord_rational_map = None 

 

# 

# The dual 

# 

__dual = None 

 

# 

# Kernel Data 

# 

 

__kernel_list = None # list of elements in the kernel 

 

__kernel_polynomial_list = None # polynomial stored as a little endian list of coefficients 

 

__kernel_polynomial = None # polynomial with roots at x values for x-coordinate of points in the kernel 

 

__inner_kernel_polynomial = None # the inner kernel polynomial (ignoring preisomorphism) 

 

__n = None 

 

 

# 

# member variables common to Velu's formula 

# 

 

# we keep track of the 2 torsion and non2torsion separately 

__kernel_2tor = None 

__kernel_non2tor = None 

 

# variables used in Velu's formula (as well as Kohel's variant) 

__v = None 

__w = None 

 

 

# 

# member variables specific to Kohel's algorithm. 

# 

 

__psi = None # psi polynomial 

__phi = None # phi polynomial 

__omega = None # omega polynomial 

 

 

# 

# Python Special Functions 

# 

 

def __init__(self, E, kernel, codomain=None, degree=None, model=None, check=True): 

r""" 

Constructor for EllipticCurveIsogeny class. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(GF(2), [0,0,1,0,1]) 

sage: phi = EllipticCurveIsogeny(E, [1,1]); phi 

Isogeny of degree 3 from Elliptic Curve defined by y^2 + y = x^3 + 1 over Finite Field of size 2 to Elliptic Curve defined by y^2 + y = x^3 over Finite Field of size 2 

 

sage: E = EllipticCurve(GF(31), [0,0,0,1,0]) 

sage: P = E((2,17)) 

sage: phi = EllipticCurveIsogeny(E, P); phi 

Isogeny of degree 8 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 31 to Elliptic Curve defined by y^2 = x^3 + 10*x + 28 over Finite Field of size 31 

 

sage: E = EllipticCurve('17a1') 

sage: phi = EllipticCurveIsogeny(E, [41/3, -55, -1, -1, 1]); phi 

Isogeny of degree 9 from Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - x - 14 over Rational Field to Elliptic Curve defined by y^2 + x*y + y = x^3 - x^2 - 56*x - 10124 over Rational Field 

 

sage: E = EllipticCurve('37a1') 

sage: triv = EllipticCurveIsogeny(E, E(0)); triv 

Isogeny of degree 1 from Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - x over Rational Field 

sage: triv.rational_maps() 

(x, y) 

 

sage: E = EllipticCurve('49a3') 

sage: R.<X> = QQ[] 

sage: EllipticCurveIsogeny(E,X^3-13*X^2-58*X+503,check=False) 

Isogeny of degree 7 from Elliptic Curve defined by y^2 + x*y = x^3 - x^2 - 107*x + 552 over Rational Field to Elliptic Curve defined by y^2 + x*y = x^3 - x^2 - 5252*x - 178837 over Rational Field 

 

""" 

if not is_EllipticCurve(E): 

raise ValueError("E parameter must be an EllipticCurve.") 

 

if not isinstance(kernel, list) and kernel in E : 

# a single point was given, we put it in a list 

# the first condition assures that [1,1] is treated as x+1 

kernel = [kernel] 

 

# if the kernel is None and the codomain isn't 

# calculate the kernel polynomial 

pre_isom = None 

post_isom = None 

 

self.__check = check 

 

if (kernel is None) and (codomain is not None): 

 

if (degree is None): 

raise ValueError("If specifying isogeny by domain and codomain, degree parameter must be set.") 

 

# save the domain/codomain: really used now (trac #7096) 

old_domain = E 

old_codomain = codomain 

 

(pre_isom, post_isom, E, codomain, kernel) = compute_sequence_of_maps(E, codomain, degree) 

 

self.__init_algebraic_structs(E) 

 

algorithm = isogeny_determine_algorithm(E, kernel) 

 

self.__algorithm = algorithm 

 

if ("velu"==algorithm): 

self.__init_from_kernel_list(kernel) 

elif ("kohel"==algorithm): 

self.__init_from_kernel_polynomial(kernel) 

 

self.__compute_E2() 

 

self.__setup_post_isomorphism(codomain, model) 

 

if (pre_isom is not None): 

self.set_pre_isomorphism(pre_isom) 

 

if (post_isom is not None): 

self.__set_post_isomorphism(old_codomain, post_isom) #(trac #7096) 

 

# Inheritance house keeping 

 

self.__perform_inheritance_housekeeping() 

 

def _call_(self, P): 

r""" 

Function that implements the call-ability of elliptic curve 

isogenies. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(GF(17), [1, 9, 5, 4, 3]) 

sage: phi = EllipticCurveIsogeny(E, [6,13,1]) 

sage: phi(E((1,0))) 

(15 : 13 : 1) 

 

sage: E = EllipticCurve(GF(23), [0,0,0,1,0]) 

sage: phi = EllipticCurveIsogeny(E, E((0,0))) 

sage: phi(E((1,5))) 

(2 : 0 : 1) 

 

sage: E = EllipticCurve(QQ, [0,0,0,3,0]) 

sage: P = E((1,2)) 

sage: phi = EllipticCurveIsogeny(E, [0,1]) 

sage: phi(P) 

(4 : -4 : 1) 

sage: phi(-P) 

(4 : 4 : 1) 

 

sage: E = EllipticCurve(GF(17), [0,-1,0,-3,-1]) 

sage: Q = E((16,0)) 

sage: tau = E.isogeny([Q],E) 

sage: tau(Q) 

(0 : 1 : 0) 

 

TESTS: 

 

Tests for :trac:`10888`:: 

 

sage: K.<th> = NumberField(x^2+3) 

sage: E = EllipticCurve(K,[7,0]) 

sage: phi = E.isogeny(E(0,0)) 

sage: P = E(-3,4*th) 

sage: phi(P) 

(-16/3 : 8/9*th : 1) 

sage: Q = phi(P) 

sage: phihat = phi.dual() 

sage: phihat(Q) 

(-1/48 : 127/576*th : 1) 

 

Call a composed isogeny (added for :trac:`16238`):: 

 

sage: E = EllipticCurve(j=GF(7)(0)) 

sage: phi = E.isogeny([E(0), E((0,1)), E((0,-1))]) 

sage: phi(E.points()[0]) 

(0 : 1 : 0) 

sage: phi2 = phi * phi 

sage: phi2(E.points()[0]) 

(0 : 1 : 0) 

 

Coercion works fine with :meth:`_call_` (added for :trac:`16238`):: 

 

sage: K.<th> = NumberField(x^2+3) 

sage: E = EllipticCurve(K,[7,0]) 

sage: E2=EllipticCurve(K,[5,0]) 

sage: phi=E.isogeny(E(0)) 

sage: phi(E2(0)) 

(0 : 1 : 0) 

sage: E2(20,90) 

(20 : 90 : 1) 

sage: phi(E2(20,90)) 

Traceback (most recent call last): 

... 

TypeError: (20 : 90 : 1) fails to convert into the map's domain Elliptic Curve defined by y^2 = x^3 + 7*x over Number Field in th with defining polynomial x^2 + 3, but a `pushforward` method is not properly implemented 

 

""" 

if(P.is_zero()): 

return self.__E2(0) 

 

(xP, yP) = P.xy() 

# if there is a pre isomorphism, apply it 

if (self.__pre_isomorphism is not None): 

temp_xP = self.__prei_x_coord_ratl_map(xP) 

temp_yP = self.__prei_y_coord_ratl_map(xP, yP) 

(xP, yP) = (temp_xP, temp_yP) 

 

if ("velu" == self.__algorithm): 

outP = self.__compute_via_velu_numeric(xP, yP) 

elif ("kohel" == self.__algorithm): 

outP = self.__compute_via_kohel_numeric(xP,yP) 

 

# the intermediate functions return the point at infinity 

# if the input point is in the kernel 

if (outP == self.__intermediate_codomain(0)): 

return self.__E2(0) 

 

# if there is a post isomorphism, apply it 

if (self.__post_isomorphism is not None): 

tempX = self.__posti_x_coord_ratl_map(outP[0]) 

tempY = self.__posti_y_coord_ratl_map(outP[0], outP[1]) 

outP = (tempX, tempY) 

 

return self.__E2(outP) 

 

def __getitem__(self, i): 

r""" 

Return one of the rational map components. 

 

.. NOTE:: 

 

Both components are returned as elements of the function 

field `F(x,y)` in two variables over the base field `F`, 

though the first only involves `x`. To obtain the 

`x`-coordinate function as a rational function in `F(x)`, 

use :meth:`x_rational_map`. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(QQ, [0,2,0,1,-1]) 

sage: phi = EllipticCurveIsogeny(E, [1]) 

sage: phi[0] 

x 

sage: phi[1] 

y 

 

sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) 

sage: phi = EllipticCurveIsogeny(E, E((0,0))) 

sage: phi[0] 

(x^2 + 3)/x 

sage: phi[1] 

(x^2*y - 3*y)/x^2 

""" 

return self.rational_maps()[i] 

 

def __iter__(self): 

r""" 

Return an iterator through the rational map components. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(QQ, [0,2,0,1,-1]) 

sage: phi = EllipticCurveIsogeny(E, [1]) 

sage: for c in phi: print(c) 

x 

y 

 

sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) 

sage: phi = EllipticCurveIsogeny(E, E((0,0))) 

sage: for c in phi: print(c) 

(x^2 + 3)/x 

(x^2*y - 3*y)/x^2 

""" 

return iter(self.rational_maps()) 

 

def __hash__(self): 

r""" 

Function that implements the hash ability of Isogeny objects. 

 

This hashes the underlying kernel polynomial so that equal 

isogeny objects have the same hash value. Also, this hashes 

the base field, and domain and codomain curves as well, so 

that isogenies with the same kernel polynomial (over different 

base fields / curves) hash to different values. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(QQ, [0,0,0,1,0]) 

sage: phi_v = EllipticCurveIsogeny(E, E((0,0))) 

sage: phi_k = EllipticCurveIsogeny(E, [0,1]) 

sage: phi_k.__hash__() == phi_v.__hash__() 

True 

sage: E_F17 = EllipticCurve(GF(17), [0,0,0,1,1]) 

sage: phi_p = EllipticCurveIsogeny(E_F17, E_F17([0,1])) 

sage: phi_p.__hash__() == phi_v.__hash__() 

False 

 

sage: E = EllipticCurve('49a3') 

sage: R.<X> = QQ[] 

sage: EllipticCurveIsogeny(E,X^3-13*X^2-58*X+503,check=False) 

Isogeny of degree 7 from Elliptic Curve defined by y^2 + x*y = x^3 - x^2 - 107*x + 552 over Rational Field to Elliptic Curve defined by y^2 + x*y = x^3 - x^2 - 5252*x - 178837 over Rational Field 

 

""" 

 

if self.__this_hash is not None: 

return self.__this_hash 

 

ker_poly_list = self.__kernel_polynomial_list 

 

if ker_poly_list is None: 

ker_poly_list = self.__init_kernel_polynomial() 

 

this_hash = 0 

 

for a in ker_poly_list: 

this_hash ^= hash(a) 

 

this_hash ^= hash(self.__E1) 

this_hash ^= hash(self.__E2) 

this_hash ^= hash(self.__base_field) 

 

self.__this_hash = this_hash 

 

return self.__this_hash 

 

def _richcmp_(self, other, op): 

r""" 

Function that implements comparisons between isogeny objects. 

 

This function works by comparing the underlying kernel 

objects. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(QQ, [0,0,0,1,0]) 

sage: phi_v = EllipticCurveIsogeny(E, E((0,0))) 

sage: phi_k = EllipticCurveIsogeny(E, [0,1]) 

sage: phi_k == phi_v 

True 

sage: E_F17 = EllipticCurve(GF(17), [0,0,0,1,0]) 

sage: phi_p = EllipticCurveIsogeny(E_F17, [0,1]) 

sage: phi_p == phi_v 

False 

sage: E = EllipticCurve('11a1') 

sage: phi = E.isogeny(E(5,5)) 

sage: phi == phi 

True 

sage: phi == -phi 

False 

sage: psi = E.isogeny(phi.kernel_polynomial()) 

sage: phi == psi 

True 

sage: phi.dual() == psi.dual() 

True 

""" 

if (self.__kernel_polynomial is None): 

self.__init_kernel_polynomial() 

 

# We cannot just compare kernel polynomials, as was done until 

# Trac #11327, as then phi and -phi compare equal, and 

# similarly with phi and any composition of phi with an 

# automorphism of its codomain, or any post-isomorphism. 

# Comparing domains, codomains and rational maps seems much 

# safer. 

lx = self.domain() 

rx = other.domain() 

if lx != rx: 

return richcmp_not_equal(lx, rx, op) 

lx = self.codomain() 

rx = other.codomain() 

if lx != rx: 

return richcmp_not_equal(lx, rx, op) 

return richcmp(self.rational_maps(), other.rational_maps(), op) 

 

def __neg__(self): 

r""" 

Function to implement unary negation (-) operator on 

isogenies. Returns a copy of this isogeny that has been 

negated. 

 

EXAMPLES: 

 

The following examples inherently exercise this function:: 

 

sage: E = EllipticCurve(j=GF(17)(0)) 

sage: phi = EllipticCurveIsogeny(E, E((-1,0)) ) 

sage: negphi = -phi 

sage: phi(E((0,1))) + negphi(E((0,1))) == 0 

True 

 

sage: E = EllipticCurve(j=GF(19)(1728)) 

sage: R.<x> = GF(19)[] 

sage: phi = EllipticCurveIsogeny(E, x) 

sage: negphi = -phi 

sage: phi(E((3,7))) + negphi(E((3,12))) == phi(2*E((3,7))) 

True 

sage: negphi(E((18,6))) 

(17 : 0 : 1) 

 

sage: R.<x> = QQ[] 

sage: E = EllipticCurve('17a1') 

sage: R.<x> = QQ[] 

sage: f = x - 11/4 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: negphi = -phi 

sage: phi.rational_maps()[0] == negphi.rational_maps()[0] 

True 

sage: P = E((7,13)) 

sage: phi(P) + negphi(P) == 0 

True 

 

""" 

# save off the kernel lists 

kernel_list = self.__kernel_list 

self.__kernel_list = None 

 

output = copy(self) 

 

# reset the kernel lists 

output.__kernel_list = copy(kernel_list) 

self.__kernel_list = kernel_list 

 

output.switch_sign() 

return output 

 

# 

# Sage Special Functions 

# 

 

def _repr_(self): 

r""" 

Special sage specific function that implement the 

functionality to display the isogeny self as a string. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(GF(31), [1,0,1,1,0]) 

sage: phi = EllipticCurveIsogeny(E, E((0,0)) ) 

sage: phi._repr_() 

'Isogeny of degree 17 from Elliptic Curve defined by y^2 + x*y + y = x^3 + x over Finite Field of size 31 to Elliptic Curve defined by y^2 + x*y + y = x^3 + 14*x + 9 over Finite Field of size 31' 

 

sage: E = EllipticCurve(QQ, [1,0,0,1,9]) 

sage: phi = EllipticCurveIsogeny(E, [2,1]) 

sage: phi._repr_() 

'Isogeny of degree 2 from Elliptic Curve defined by y^2 + x*y = x^3 + x + 9 over Rational Field to Elliptic Curve defined by y^2 + x*y = x^3 - 59*x + 165 over Rational Field' 

 

""" 

return 'Isogeny of degree %r from %r to %r' % ( 

self.__degree, self.__E1, self.__E2) 

 

def _latex_(self): 

r""" 

Special sage specific function that implements functionality 

to display an isogeny object as a latex string. 

 

This function returns a latex string representing the isogeny 

self as the `x` and `y` coordinate rational functions. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(QQ, [0,0,0,1,-1]) 

sage: phi = EllipticCurveIsogeny(E, E(0)) 

sage: phi._latex_() 

'\\left( x , y \\right)' 

 

sage: E = EllipticCurve(GF(17), [0,0,0,1,-1]) 

sage: R.<X> = GF(17)[] 

sage: phi = EllipticCurveIsogeny(E, X+11) 

sage: phi._latex_() 

'\\left( \\frac{x^{2} + 11 x + 7}{x + 11} , \\frac{x^{2} y + 5 x y + 12 y}{x^{2} + 5 x + 2} \\right)' 

 

 

""" 

ratl_maps = self.rational_maps() 

return '\\left( %s , %s \\right)' % (ratl_maps[0]._latex_(), ratl_maps[1]._latex_()) 

 

 

########################### 

# Private Common Functions 

########################### 

 

# delete the hash value 

def __clear_cached_values(self): 

r""" 

A private function to clear the hash if the codomain has been 

modified by a pre or post isomorphism. 

 

EXAMPLES:: 

 

sage: F = GF(7) 

sage: E = EllipticCurve(j=F(0)) 

sage: phi = EllipticCurveIsogeny(E, [E((0,-1)), E((0,1))]) 

sage: old_hash = hash(phi) 

sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism 

sage: phi.set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(), (-1,2,-3,4))) 

sage: hash(phi) == old_hash 

False 

 

sage: R.<x> = QQ[] 

sage: E = EllipticCurve(QQ, [0,0,0,1,0]) 

sage: phi = EllipticCurveIsogeny(E, x) 

sage: old_ratl_maps = phi.rational_maps() 

sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism 

sage: phi.set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(), (-1,0,0,0))) 

sage: old_ratl_maps == phi.rational_maps() 

False 

sage: old_ratl_maps[1] == -phi.rational_maps()[1] 

True 

 

sage: F = GF(127); R.<x> = F[] 

sage: E = EllipticCurve(j=F(1728)) 

sage: f = x^5 + 43*x^4 + 97*x^3 + 81*x^2 + 42*x + 82 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: old_hash = hash(phi) 

sage: old_ratl_maps = phi.rational_maps() 

sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism 

sage: phi.set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(), (-13,13,-13,13))) 

sage: old_hash == hash(phi) 

False 

sage: old_ratl_maps == phi.rational_maps() 

False 

sage: phi._EllipticCurveIsogeny__clear_cached_values() 

 

""" 

self.__this_hash = None 

self.__rational_maps_initialized = False 

self.__X_coord_rational_map = None 

self.__Y_coord_rational_map = None 

self.__dual = None 

 

# performs the inheritance house keeping 

def __perform_inheritance_housekeeping(self): 

r""" 

Internal helper function, sets values on the super classes of 

this class. 

 

EXAMPLES: 

 

The following examples will implicitly exercise this 

function:: 

 

sage: E = EllipticCurve(GF(43), [2,3,5,7,11]) 

sage: R.<x> = GF(43)[]; f = x + 42 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: phi._EllipticCurveIsogeny__perform_inheritance_housekeeping() 

sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism 

sage: E2 = phi.codomain() 

sage: post_isom = WeierstrassIsomorphism(E2, (41, 37, 31, 29)) 

sage: phi.set_post_isomorphism(post_isom) 

sage: E1pr = WeierstrassIsomorphism(E, (-1, 2, -3, 4)).codomain().codomain() 

sage: pre_isom = E1pr.isomorphism_to(E) 

sage: phi.set_pre_isomorphism(pre_isom) 

 

""" 

# one of the superclasses uses these fields 

self._domain = self.__E1 

self._codomain = self.__E2 

 

# sets up the parent 

parent = homset.Hom(self.__E1, self.__E2) 

Morphism.__init__(self, parent) 

 

def __init_algebraic_structs(self, E): 

r""" 

An internal function for EllipticCurveIsogeny objects that 

sets up the member variables necessary for algebra. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(j=GF(17)(0)) 

sage: phi = EllipticCurveIsogeny(E, E((-1,0))) 

 

The constructor calls this function itself, so the fields it 

sets are already defined:: 

 

sage: phi._EllipticCurveIsogeny__E1 

Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 17 

sage: phi._EllipticCurveIsogeny__base_field 

Finite Field of size 17 

sage: phi._EllipticCurveIsogeny__poly_ring 

Univariate Polynomial Ring in x over Finite Field of size 17 

sage: phi._EllipticCurveIsogeny__mpoly_ring 

Multivariate Polynomial Ring in x, y over Finite Field of size 17 

sage: phi._EllipticCurveIsogeny__intermediate_domain 

Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 17 

 

Now, calling the initialization function does nothing more:: 

 

sage: phi._EllipticCurveIsogeny__init_algebraic_structs(E) 

sage: phi._EllipticCurveIsogeny__E1 

Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 17 

sage: phi._EllipticCurveIsogeny__base_field 

Finite Field of size 17 

sage: phi._EllipticCurveIsogeny__poly_ring 

Univariate Polynomial Ring in x over Finite Field of size 17 

sage: phi._EllipticCurveIsogeny__mpoly_ring 

Multivariate Polynomial Ring in x, y over Finite Field of size 17 

sage: phi._EllipticCurveIsogeny__intermediate_domain 

Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 17 

 

sage: E = EllipticCurve(QQ, [0,0,0,1,0]) 

sage: phi = EllipticCurveIsogeny(E, E((0,0))) 

sage: phi._EllipticCurveIsogeny__init_algebraic_structs(E) 

sage: phi._EllipticCurveIsogeny__E1 

Elliptic Curve defined by y^2 = x^3 + x over Rational Field 

sage: phi._EllipticCurveIsogeny__base_field 

Rational Field 

sage: phi._EllipticCurveIsogeny__poly_ring 

Univariate Polynomial Ring in x over Rational Field 

sage: phi._EllipticCurveIsogeny__mpoly_ring 

Multivariate Polynomial Ring in x, y over Rational Field 

sage: phi._EllipticCurveIsogeny__intermediate_domain 

Elliptic Curve defined by y^2 = x^3 + x over Rational Field 

 

sage: F = GF(19); R.<x> = F[] 

sage: E = EllipticCurve(j=GF(19)(0)) 

sage: phi = EllipticCurveIsogeny(E, x) 

sage: phi._EllipticCurveIsogeny__init_algebraic_structs(E) 

sage: phi._EllipticCurveIsogeny__E1 

Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 19 

sage: phi._EllipticCurveIsogeny__base_field 

Finite Field of size 19 

sage: phi._EllipticCurveIsogeny__poly_ring 

Univariate Polynomial Ring in x over Finite Field of size 19 

sage: phi._EllipticCurveIsogeny__mpoly_ring 

Multivariate Polynomial Ring in x, y over Finite Field of size 19 

sage: phi._EllipticCurveIsogeny__intermediate_domain 

Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 19 

""" 

self.__E1 = E 

self.__base_field = E.base_ring() 

self.__poly_ring = PolynomialRing(self.__base_field, ['x']) 

self.__mpoly_ring = PolynomialRing(self.__base_field, ['x','y']) 

from sage.rings.all import FractionField 

self.__xfield = FractionField(self.__poly_ring) 

self.__xyfield = FractionField(self.__mpoly_ring) 

self.__intermediate_domain = E 

 

def __compute_E2(self): 

r""" 

Private function that computes and sets the isogeny codomain. 

 

EXAMPLES: 

 

These examples inherently exercise this function:: 

 

sage: E = EllipticCurve(j=GF(7)(1728)) 

sage: phi = EllipticCurveIsogeny(E, E((0,0))) 

sage: phi.codomain() 

Elliptic Curve defined by y^2 = x^3 + 3*x over Finite Field of size 7 

sage: phi._EllipticCurveIsogeny__compute_E2() 

 

sage: R.<x> = GF(7)[] 

sage: phi = EllipticCurveIsogeny(E, x) 

sage: phi.codomain() 

Elliptic Curve defined by y^2 = x^3 + 3*x over Finite Field of size 7 

sage: phi._EllipticCurveIsogeny__compute_E2() 

 

""" 

 

if ("velu" == self.__algorithm): 

E2 = self.__compute_E2_via_velu() 

elif ("kohel" == self.__algorithm): 

E2 = self.__compute_E2_via_kohel() 

 

self.__E2 = E2 

self.__intermediate_codomain = E2 

 

# initializes the rational maps fields 

def __initialize_rational_maps(self, precomputed_maps=None): 

r""" 

Private function that computes and initializes the rational 

maps. 

 

INPUT: 

 

- ``precomputed_maps`` (default None) -- tuple (X,Y) of 

rational functions in x,y 

 

EXAMPLES: 

 

The following examples inherently exercise this function:: 

 

sage: E = EllipticCurve(j=GF(7)(1728)) 

sage: phi = EllipticCurveIsogeny(E, E((0,0))) 

sage: phi._EllipticCurveIsogeny__initialize_rational_maps() 

sage: phi.rational_maps() 

((x^2 + 1)/x, (x^2*y - y)/x^2) 

 

sage: R.<x> = GF(7)[] 

sage: phi = EllipticCurveIsogeny(E, x) 

sage: phi = EllipticCurveIsogeny(E, x) 

sage: phi.rational_maps() 

((x^2 + 1)/x, (x^2*y - y)/x^2) 

sage: phi._EllipticCurveIsogeny__initialize_rational_maps() 

 

sage: E = EllipticCurve([1,2,3,4,5]) 

sage: Eshort = E.short_weierstrass_model() 

sage: phi = E.isogeny(E(0), Eshort) 

sage: phiX, phiY = phi.rational_maps() 

sage: phiX(1,2), phiY(1,2) 

(63, 864) 

""" 

if self.__rational_maps_initialized: 

return 

 

if precomputed_maps is None: 

if ("velu"==self.__algorithm): 

(X_map, Y_map) = self.__initialize_rational_maps_via_velu() 

 

if ("kohel"==self.__algorithm): 

(X_map, Y_map) = self.__initialize_rational_maps_via_kohel() 

else: 

X_map, Y_map = precomputed_maps 

# cannot coerce directly in xfield for some reason 

X_map = self.__poly_ring(X_map.numerator())/self.__poly_ring(X_map.denominator()) 

 

if self.__prei_x_coord_ratl_map is not None: 

prei_X_map = self.__prei_x_coord_ratl_map 

prei_Y_map = self.__prei_y_coord_ratl_map 

X_map = X_map(prei_X_map) 

Y_map = Y_map([prei_X_map, prei_Y_map]) 

 

if self.__posti_x_coord_ratl_map is not None: 

# Do not reverse the order here! 

Y_map = self.__posti_y_coord_ratl_map([X_map, Y_map]) 

X_map = self.__posti_x_coord_ratl_map(X_map) 

 

self.__X_coord_rational_map = self.__xfield(X_map) 

self.__Y_coord_rational_map = self.__xyfield(Y_map) 

self.__rational_maps_initialized = True 

 

 

def __init_kernel_polynomial(self): 

r""" 

Private function that initializes the kernel polynomial (if 

the algorithm does not take it as a parameter). 

 

EXAMPLES: 

 

The following examples inherently exercise this function:: 

 

sage: E = EllipticCurve(j=GF(7)(1728)) 

sage: phi = EllipticCurveIsogeny(E, E((0,0))) 

sage: phi.kernel_polynomial() 

x 

sage: phi._EllipticCurveIsogeny__init_kernel_polynomial() 

[0, 1] 

 

""" 

 

if (self.__kernel_polynomial_list is not None): 

return self.__kernel_polynomial_list 

 

if ("velu" == self.__algorithm): 

ker_poly_list = self.__init_kernel_polynomial_velu() 

else: 

raise InputError("The kernel polynomial should already be defined!") 

 

return ker_poly_list 

 

 

def __set_pre_isomorphism(self, domain, isomorphism): 

r""" 

Private function to set the pre isomorphism and domain (and 

keep track of the domain of the isogeny). 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(GF(43), [2,3,5,7,11]) 

sage: R.<x> = GF(43)[]; f = x + 42 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: phi._EllipticCurveIsogeny__perform_inheritance_housekeeping() 

sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism 

sage: E1pr = WeierstrassIsomorphism(E, (-1, 2, -3, 4)).codomain().codomain() 

sage: pre_isom = E1pr.isomorphism_to(E) 

sage: phi.set_pre_isomorphism(pre_isom) 

sage: phi._EllipticCurveIsogeny__set_pre_isomorphism(E, WeierstrassIsomorphism(E, (-1, 3, -3, 4))) 

sage: E == phi.domain() 

True 

 

""" 

 

self.__E1 = domain 

 

# set the isomorphism 

self.__pre_isomorphism = isomorphism 

 

# calculate the isomorphism as a rational map. 

 

u, r, s, t = [self.__base_field(c) for c in isomorphism.tuple()] 

uinv = 1/u 

uinv2 = uinv**2 

uinv3 = uinv*uinv2 

 

x = self.__poly_ring.gen() 

y = self.__xyfield.gen(1) # not mpoly_ring.gen(1) else we end 

# up in K(x)[y] and trouble ensues 

 

self.__prei_x_coord_ratl_map = (x - r) * uinv2 

self.__prei_y_coord_ratl_map = (y - s*(x-r) - t) * uinv3 

 

if (self.__kernel_polynomial is not None): 

ker_poly = self.__kernel_polynomial 

ker_poly = ker_poly(self.__prei_x_coord_ratl_map) 

self.__kernel_polynomial = ker_poly.monic() 

 

self.__perform_inheritance_housekeeping() 

 

 

def __set_post_isomorphism(self, codomain, isomorphism): 

r""" 

Private function to set the post isomorphism and codomain (and 

keep track of the codomain of the isogeny). 

 

EXAMPLES: 

 

The following examples inherently exercise this function:: 

 

sage: E = EllipticCurve(j=GF(7)(1728)) 

sage: phi = EllipticCurveIsogeny(E, E((0,0))) 

sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism 

sage: E2 = phi.codomain() 

sage: isom = WeierstrassIsomorphism(E2, (-1,2,-3,4)) 

sage: phi.set_post_isomorphism(isom) 

sage: phi._EllipticCurveIsogeny__set_post_isomorphism(E2, WeierstrassIsomorphism(phi.codomain(), (1,-2,3,-4))) 

sage: E2 == phi.codomain() 

True 

 

""" 

 

# set the codomains 

self.__E2 = codomain 

 

# set the isomorphism 

self.__post_isomorphism = isomorphism 

 

# calculate the isomorphism as a rational map. 

 

u, r, s, t = [self.__base_field(c) for c in isomorphism.tuple()] 

uinv = 1/u 

uinv2 = uinv**2 

uinv3 = uinv*uinv2 

 

x = self.__poly_ring.gen() 

y = self.__xyfield.gen(1) 

 

self.__posti_x_coord_ratl_map = (x - r) * uinv2 

self.__posti_y_coord_ratl_map = (y - s*(x-r) - t) * uinv3 

 

self.__perform_inheritance_housekeeping() 

 

def __setup_post_isomorphism(self, codomain, model): 

r""" 

Private function to set up the post isomorphism given the 

codomain. 

 

EXAMPLES: 

 

The following examples inherently exercise this function:: 

 

sage: E = EllipticCurve(j=GF(7)(1728)) 

sage: E2 = EllipticCurve(GF(7), [0,0,0,5,0]) 

sage: phi = EllipticCurveIsogeny(E, E((0,0)), E2); phi 

Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 5*x over Finite Field of size 7 

sage: E3 = EllipticCurve(GF(7), [0,0,0,6,0]) 

sage: phi._EllipticCurveIsogeny__setup_post_isomorphism(E3, None) 

sage: phi 

Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 6*x over Finite Field of size 7 

 

sage: R.<x> = QQ[] 

sage: E = EllipticCurve(j=1728) 

sage: f = x^3 - x 

sage: phi = EllipticCurveIsogeny(E, f, model='minimal'); phi 

Isogeny of degree 4 from Elliptic Curve defined by y^2 = x^3 - x over Rational Field to Elliptic Curve defined by y^2 = x^3 - x over Rational Field 

 

sage: phi = EllipticCurveIsogeny(E, f, model=None) 

sage: phi._EllipticCurveIsogeny__setup_post_isomorphism(None, 'minimal') 

sage: phi 

Isogeny of degree 4 from Elliptic Curve defined by y^2 = x^3 - x over Rational Field to Elliptic Curve defined by y^2 = x^3 - x over Rational Field 

 

""" 

# TODO: add checks to make sure that codomain and model 

# parameters are consistent with the algorithm used. 

 

post_isom = None 

newE2 = None 

 

oldE2 = self.__E2 

 

if (model is not None): 

 

if (codomain is not None): 

raise ValueError("Cannot specify a codomain and model flag simultaneously.") 

 

if ('minimal' == model): 

 

if (not is_NumberField(oldE2.base_field())): 

raise ValueError("specifying minimal for model flag only valid with curves over number fields.") 

 

newE2 = oldE2.global_minimal_model(semi_global=True) 

post_isom = oldE2.isomorphism_to(newE2) 

 

else: 

raise ValueError("Unknown value of model flag.") 

 

elif (codomain is not None): 

if (not is_EllipticCurve(codomain)): 

raise ValueError("Codomain parameter must be an elliptic curve.") 

 

if (not oldE2.is_isomorphic(codomain)): 

raise ValueError("Codomain parameter must be isomorphic to computed codomain isogeny") 

 

newE2 = codomain 

post_isom = oldE2.isomorphism_to(newE2) 

 

if (post_isom is not None): 

self.__set_post_isomorphism(newE2, post_isom) 

 

return 

 

########################### 

# Velu's Formula Functions 

########################### 

 

# 

# Setup function for Velu's formula 

# 

 

def __init_from_kernel_list(self, kernel_gens): 

r""" 

Private function that initializes the isogeny from a list of 

points which generate the kernel (For Velu's formulas.) 

 

EXAMPLES: 

 

The following example inherently exercises this function:: 

 

sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) 

sage: phi = EllipticCurveIsogeny(E, E((0,0))); phi 

Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 6*x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 4*x over Finite Field of size 7 

sage: phi._EllipticCurveIsogeny__init_from_kernel_list([E(0), E((0,0))]) 

 

The following example demonstrates the necessity of avoiding any calls 

to P.order(), since such calls involve factoring the group order which 

could take a long time. :: 

 

sage: p = 12 * next_prime(2^180) * next_prime(2^194) - 1 

sage: F = FiniteField(p, proof=False) 

sage: E = EllipticCurve([F(1), F(0)]) 

sage: P = E(0).division_points(3)[1] 

sage: EllipticCurveIsogeny(E, P) 

Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 461742260113997803268895001173557974278278194575766957660028841364655249961609425998827452443620996655395008156411 to Elliptic Curve defined by y^2 = x^3 + 80816485163488178037199320944019099858815874115367810482828676054000067654558381377552245721755005198633191074893*x + 301497584865165444049833326660609767433467459033532853758006118022998267706948164646650354324860226263546558337993 over Finite Field of size 461742260113997803268895001173557974278278194575766957660028841364655249961609425998827452443620996655395008156411 

 

""" 

if self.__check : 

for P in kernel_gens: 

if not P.has_finite_order(): 

raise ValueError("The points in the kernel must be of finite order.") 

 

# Compute a list of points in the subgroup generated by the 

# points in kernel_gens. This is very naive: when finite 

# subgroups are implemented better, this could be simplified, 

# but it won't speed things up too much. 

 

kernel_set = Set([self.__E1(0)]) 

from sage.misc.all import flatten 

 

def all_multiples(itr, terminal): 

mult_list = [terminal] 

R = terminal + itr 

while R != terminal: 

mult_list.append(R) 

R = R + itr 

return mult_list 

for P in kernel_gens: 

kernel_set += Set(flatten([all_multiples(P,Q) 

for Q in kernel_set])) 

self.__kernel_list = kernel_set.list() 

self.__kernel_2tor = {} 

self.__kernel_non2tor = {} 

self.__degree = Integer(len(kernel_set)) 

self.__sort_kernel_list() 

 

# 

# Precompute the values in Velu's Formula. 

# 

def __sort_kernel_list(self): 

r""" 

Private function that sorts the list of points in the kernel 

(For Velu's formulas). Sorts out the 2 torsion points, and 

puts them in a dictionary. 

 

EXAMPLES: 

 

The following example inherently exercises this function:: 

 

sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) 

sage: P = E((4,2)) 

sage: phi = EllipticCurveIsogeny(E, P); phi 

Isogeny of degree 4 from Elliptic Curve defined by y^2 = x^3 + 6*x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 7 

sage: phi._EllipticCurveIsogeny__kernel_2tor = {} 

sage: phi._EllipticCurveIsogeny__kernel_non2tor = {} 

sage: phi._EllipticCurveIsogeny__sort_kernel_list() 

 

""" 

 

a1,a2,a3,a4,a6 = self.__E1.ainvs() 

 

v = 0 

w = 0 

 

for Q in self.__kernel_list: 

 

if Q.is_zero(): 

continue 

 

(xQ,yQ) = Q.xy() 

 

gxQ = 3*xQ**2 + 2*a2*xQ + a4 - a1*yQ 

gyQ = -2*yQ - a1*xQ - a3 

 

uQ = gyQ**2 

 

# sort torsion points: 

if (2*yQ == -a1*xQ - a3): # Q is 2-torsion 

vQ = gxQ 

self.__kernel_2tor[xQ] = (xQ,yQ,gxQ,gyQ,vQ,uQ) 

v = v + vQ 

w = w + (uQ + xQ*vQ) 

elif xQ not in self.__kernel_non2tor: # Q is not a 2-torsion 

vQ = 2*gxQ - a1*gyQ 

self.__kernel_non2tor[xQ] = (xQ,yQ,gxQ,gyQ,vQ,uQ) 

v = v + vQ 

w = w + (uQ + xQ*vQ) 

 

self.__v = v 

self.__w = w 

 

# 

# Velu's formula computing the codomain curve 

# 

def __compute_E2_via_velu(self): 

r""" 

Private function that computes the codomain via Velu's 

formulas. 

 

EXAMPLES: 

 

The following example inherently exercises this function:: 

 

sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) 

sage: P = E((4,2)) 

sage: phi = EllipticCurveIsogeny(E, P) 

sage: phi.codomain() 

Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 7 

sage: phi._EllipticCurveIsogeny__compute_E2_via_velu() 

Elliptic Curve defined by y^2 = x^3 + 2*x over Finite Field of size 7 

 

""" 

v = self.__v 

w = self.__w 

 

return compute_codomain_formula(self.__E1, v,w) 

 

 

def __velu_sum_helper(self, Qvalues, a1, a3, x, y): 

r""" 

Private function for Velu's formulas, helper function to help 

perform the summation. 

 

EXAMPLES: 

 

The following example inherently exercises this function:: 

 

sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) 

sage: P = E((4,2)) 

sage: phi = EllipticCurveIsogeny(E, P) 

sage: Q = E((0,0)); phi(Q) 

(0 : 0 : 1) 

sage: phi.rational_maps() 

((x^4 - 2*x^3 + x^2 - 3*x)/(x^3 - 2*x^2 + 3*x - 2), (x^5*y - 2*x^3*y - x^2*y - 2*x*y + 2*y)/(x^5 + 3*x^3 + 3*x^2 + x - 1)) 

 

sage: F = GF(7) 

sage: E = EllipticCurve(F, [0,0,0,1,0]) 

sage: phi = EllipticCurveIsogeny(E, E((0,0)) ) 

sage: Qvals = phi._EllipticCurveIsogeny__kernel_2tor[0] 

sage: phi._EllipticCurveIsogeny__velu_sum_helper(Qvals, 0, 0, F(5), F(5)) 

(3, 3) 

sage: R.<x,y> = GF(7)[] 

sage: phi._EllipticCurveIsogeny__velu_sum_helper(Qvals, 0, 0, x, y) 

(1/x, y/x^2) 

 

""" 

xQ = Qvalues[0] 

yQ = Qvalues[1] 

gxQ = Qvalues[2] 

gyQ = Qvalues[3] 

vQ = Qvalues[4] 

uQ = Qvalues[5] 

 

t1 = x - xQ 

inv_t1 = t1**-1 

inv_t1_2 = inv_t1**2 

inv_t1_3 = inv_t1_2*inv_t1 

 

tX = vQ*inv_t1 + uQ*(inv_t1_2) 

 

tY0 = uQ*(2*y + a1*x + a3) 

tY1 = vQ*(a1*t1 + y - yQ) 

tY2 = a1*uQ - gxQ*gyQ 

 

# Without this explicit coercion, tY ends up in K(x)[y] 

# instead of K(x,y), and trouble ensues! 

from sage.rings.all import FractionField 

F = FractionField(y.parent()) 

tY = ( tY0*F(inv_t1_3) + (tY1 + tY2)*F(inv_t1_2) ) 

 

return (tX, tY) 

 

 

def __compute_via_velu_numeric(self, xP, yP): 

r""" 

Private function that sorts the list of points in the kernel 

(for Velu's formulas). Sorts out the 2 torsion points, and 

puts them in a dictionary. 

 

EXAMPLES: 

 

The following example inherently exercises this function:: 

 

sage: F = GF(7) 

sage: E = EllipticCurve(F, [0,0,0,-1,0]) 

sage: P = E((4,2)) 

sage: phi = EllipticCurveIsogeny(E, P) 

sage: Q = E((0,0)); phi(Q) 

(0 : 0 : 1) 

sage: Q = E((-1,0)); phi(Q) 

(0 : 0 : 1) 

sage: phi._EllipticCurveIsogeny__compute_via_velu_numeric(F(0), F(0)) 

(0, 0) 

sage: phi._EllipticCurveIsogeny__compute_via_velu_numeric(F(-1), F(0)) 

(0, 0) 

 

""" 

# first check if the point is in the kernel 

if xP in self.__kernel_2tor or xP in self.__kernel_non2tor: 

return self.__intermediate_codomain(0) 

 

outP = self.__compute_via_velu(xP,yP) 

 

return outP 

 

 

def __compute_via_velu(self, xP, yP): 

r""" 

Private function for Velu's formulas, to perform the summation. 

 

EXAMPLES: 

 

The following example inherently exercises this function:: 

 

sage: F = GF(7) 

sage: E = EllipticCurve(F, [0,0,0,-1,0]) 

sage: P = E((4,2)) 

sage: phi = EllipticCurveIsogeny(E, P) 

sage: Q = E((0,0)); phi(Q) 

(0 : 0 : 1) 

sage: phi.rational_maps() 

((x^4 - 2*x^3 + x^2 - 3*x)/(x^3 - 2*x^2 + 3*x - 2), (x^5*y - 2*x^3*y - x^2*y - 2*x*y + 2*y)/(x^5 + 3*x^3 + 3*x^2 + x - 1)) 

sage: phi._EllipticCurveIsogeny__compute_via_velu(F(0), F(0)) 

(0, 0) 

sage: R.<x,y> = GF(7)[] 

sage: phi._EllipticCurveIsogeny__compute_via_velu(x, y) 

((x^4 - 2*x^3 + x^2 - 3*x)/(x^3 - 2*x^2 + 3*x - 2), 

(x^5*y - 2*x^3*y - x^2*y - 2*x*y + 2*y)/(x^5 + 3*x^3 + 3*x^2 + x - 1)) 

""" 

ker_2tor = self.__kernel_2tor 

ker_non2tor = self.__kernel_non2tor 

 

X = 0 

Y = 0 

 

a1 = self.__E1.a1() 

a3 = self.__E1.a3() 

 

# next iterate over the 2torsion points of the kernel 

for Qvalues in itervalues(ker_2tor): 

(tX, tY) = self.__velu_sum_helper(Qvalues, a1, a3, xP, yP) 

X = X + tX 

Y = Y + tY 

 

for Qvalues in itervalues(ker_non2tor): 

(tX, tY) = self.__velu_sum_helper(Qvalues, a1, a3, xP, yP) 

X = X + tX 

Y = Y + tY 

 

X = xP + X 

Y = yP - Y 

 

return (X,Y) 

 

 

def __initialize_rational_maps_via_velu(self): 

r""" 

Private function for Velu's formulas, helper function to 

initialize the rational maps. 

 

EXAMPLES: 

 

The following example inherently exercises this function:: 

 

sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) 

sage: P = E((4,2)) 

sage: phi = EllipticCurveIsogeny(E, P) 

sage: phi.rational_maps() 

((x^4 - 2*x^3 + x^2 - 3*x)/(x^3 - 2*x^2 + 3*x - 2), (x^5*y - 2*x^3*y - x^2*y - 2*x*y + 2*y)/(x^5 + 3*x^3 + 3*x^2 + x - 1)) 

sage: phi._EllipticCurveIsogeny__initialize_rational_maps_via_velu() 

((x^4 + 5*x^3 + x^2 + 4*x)/(x^3 + 5*x^2 + 3*x + 5), (x^5*y - 2*x^3*y - x^2*y - 2*x*y + 2*y)/(x^5 + 3*x^3 + 3*x^2 + x - 1)) 

""" 

x = self.__poly_ring.gen() 

y = self.__mpoly_ring.gen(1) 

 

return self.__compute_via_velu(x,y) 

 

 

def __init_kernel_polynomial_velu(self): 

r""" 

Private function for Velu's formulas, helper function to 

initialize the rational maps. 

 

EXAMPLES: 

 

The following example inherently exercises this function:: 

 

sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) 

sage: P = E((4,2)) 

sage: phi = EllipticCurveIsogeny(E, P) 

sage: phi.kernel_polynomial() 

x^2 + 2*x + 4 

sage: phi._EllipticCurveIsogeny__init_kernel_polynomial_velu() 

[4, 2, 1] 

""" 

poly_ring = self.__poly_ring 

x = poly_ring.gen() 

 

invX = 0 

 

if (self.__pre_isomorphism is not None): 

pre_isom = self.__pre_isomorphism 

u = pre_isom.u 

r = pre_isom.r 

invX = (u**2)*x + r 

else: 

invX = x 

 

psi = poly_ring(1) 

 

for Qvalues in itervalues(self.__kernel_2tor): 

xQ = invX(x=Qvalues[0]) 

psi = psi*(x - xQ) 

 

for Qvalues in itervalues(self.__kernel_non2tor): 

xQ = invX(x=Qvalues[0]) 

psi = psi*(x - xQ) 

 

ker_poly_list = psi.list() 

 

self.__kernel_polynomial_list = ker_poly_list 

self.__kernel_polynomial = psi 

 

return ker_poly_list 

 

 

 

################################### 

# Kohel's Variant of Velu's Formula 

################################### 

 

def __init_from_kernel_polynomial(self, kernel_polynomial): 

r""" 

Private function that initializes the isogeny from a kernel 

polynomial. 

 

EXAMPLES: 

 

These examples inherently exercise this private function:: 

 

sage: R.<x> = GF(7)[] 

sage: E = EllipticCurve(GF(7), [0,0,0,-1,0]) 

sage: phi = EllipticCurveIsogeny(E, x);phi 

Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 6*x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 4*x over Finite Field of size 7 

 

sage: phi._EllipticCurveIsogeny__init_from_kernel_polynomial(x) 

 

sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) 

sage: phi = EllipticCurveIsogeny(E, x+6, degree=3); phi 

Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 1 over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 4*x + 2 over Finite Field of size 7 

 

sage: phi._EllipticCurveIsogeny__init_from_kernel_polynomial(x+6) 

 

""" 

poly_ring = self.__poly_ring 

x = poly_ring.gen() 

E = self.__E1 

 

# Convert to a univariate polynomial, even if it had a 

# bivariate parent, or was given as a list: 

self.__kernel_polynomial = psi = poly_ring(kernel_polynomial) 

 

if psi.leading_coefficient() != 1: 

raise ValueError("The kernel polynomial must be monic.") 

 

self.__kernel_polynomial_list = psi.list() 

 

# 

# Determine if kernel polynomial is entirely a two torsion 

# 

psi_G = two_torsion_part(E, psi).monic() 

 

if (0 != psi_G.degree()): # even degree case 

 

psi_quo = psi//psi_G 

 

if (0 != psi_quo.degree()): 

raise NotImplementedError("For basic Kohel's algorithm, if the kernel degree is even then the kernel must be contained in the two torsion.") 

 

(phi, omega, v, w, n, d) = self.__init_even_kernel_polynomial(E, psi_G) 

 

else: # odd degree case 

 

(phi, omega, v, w, n, d) = self.__init_odd_kernel_polynomial(E, psi) 

 

 

# 

# Set up the necessary instance variables 

# 

 

self.__kernel_polynomial = psi 

self.__inner_kernel_polynomial = psi 

 

self.__degree = Integer(d) # degree of the isogeny 

 

# As a rational map, the isogeny maps (x,y) to (X,Y), where 

# X=phi(x)/psi(x)^2 and Y=omega(x,y)/psi(x)^3. Both phi and 

# psi are univariate polynomials in x, while omega is a 

# bivariate polynomial in x, y. The names are compatible so 

# that univariate polynomials automatically coerce into the 

# bivariate polynomial ring. 

 

self.__psi = psi 

self.__phi = phi 

self.__omega = omega 

 

self.__v = v 

self.__w = w 

 

def __init_even_kernel_polynomial(self, E, psi_G): 

r""" 

Returns the isogeny parameters for the 2-part of an isogeny. 

 

INPUT: 

 

- ``E`` -- an elliptic curve 

 

- ``psi_G`` -- a univariate polynomial over the base field of 

``E`` of degree 1 or 3 dividing its 2-division polynomial 

 

OUTPUT: 

 

(phi, omega, v, w, n, d) where: 

 

- ``phi`` is a univariate polynomial, the numerator of the 

`X`-coordinate of the isogeny; 

 

- ``omega`` is a bivariate polynomial, the numerator of the 

`Y`-coordinate of the isogeny; 

 

- ``v``, ``w`` are the Velu parameters of the isogeny; 

 

- ``n`` is the degree of ``psi``; 

 

- ``d`` is the degree of the isogeny. 

 

EXAMPLES: 

 

These examples inherently exercise this private function:: 

 

sage: R.<x> = GF(7)[] 

sage: E = EllipticCurve(GF(7), [-1,0]) 

sage: phi = EllipticCurveIsogeny(E, x); phi 

Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 6*x over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 4*x over Finite Field of size 7 

 

sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import two_torsion_part 

sage: psig = two_torsion_part(E,x) 

sage: phi._EllipticCurveIsogeny__init_even_kernel_polynomial(E,psig) 

(x^3 + 6*x, x^3*y + x*y, 6, 0, 1, 2) 

 

sage: F = GF(2^4, 'alpha'); R.<x> = F[] 

sage: E = EllipticCurve(F, [1,1,0,1,0]) 

sage: phi = EllipticCurveIsogeny(E, x); phi 

Isogeny of degree 2 from Elliptic Curve defined by y^2 + x*y = x^3 + x^2 + x over Finite Field in alpha of size 2^4 to Elliptic Curve defined by y^2 + x*y = x^3 + x^2 + 1 over Finite Field in alpha of size 2^4 

 

sage: psig = two_torsion_part(E,x) 

sage: phi._EllipticCurveIsogeny__init_even_kernel_polynomial(E,psig) 

(x^3 + x, x^3*y + x^2 + x*y, 1, 0, 1, 2) 

 

sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) 

sage: R.<x> = GF(7)[] 

sage: f = x^3 + 6*x^2 + 1 

sage: phi = EllipticCurveIsogeny(E, f); phi 

Isogeny of degree 4 from Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 1 over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 2*x + 5 over Finite Field of size 7 

sage: psig = two_torsion_part(E,f) 

sage: psig = two_torsion_part(E,f) 

sage: phi._EllipticCurveIsogeny__init_even_kernel_polynomial(E,psig) 

(x^7 + 5*x^6 + 2*x^5 + 6*x^4 + 3*x^3 + 5*x^2 + 6*x + 3, x^9*y - 3*x^8*y + 2*x^7*y - 3*x^3*y + 2*x^2*y + x*y - y, 1, 6, 3, 4) 

""" 

#check if the polynomial really divides the two_torsion_polynomial 

if self.__check and E.division_polynomial(2, x=self.__poly_ring.gen()) % psi_G != 0 : 

raise ValueError("The polynomial does not define a finite subgroup of the elliptic curve.") 

 

n = psi_G.degree() # 1 or 3 

d = n+1 # 2 or 4 

 

base_field = self.__base_field 

char = base_field.characteristic() 

 

a1,a2,a3,a4,a6 = E.ainvs() 

b2,b4,_,_ = E.b_invariants() 

x = self.__poly_ring.gen() 

y = self.__mpoly_ring.gen(1) 

 

if (1 == n): 

x0 = -psi_G.constant_coefficient() 

 

# determine y0 

if (2 == char): 

y0 = (x0**3 + a2*x0**2 + a4*x0 + a6).sqrt() 

else: 

y0 = -(a1*x0 + a3)/2 

 

(v,w) = compute_vw_kohel_even_deg1(x0,y0,a1,a2,a4) 

 

phi = (x*psi_G + v)*psi_G 

omega = (y*psi_G**2 - v*(a1*psi_G + (y - y0)))*psi_G 

 

elif (3 == n): 

s = psi_G.list() 

s1 = -s[n-1] 

s2 = s[n-2] 

s3 = -s[n-3] 

 

psi_G_pr = psi_G.derivative() 

psi_G_prpr = psi_G_pr.derivative() 

 

phi = (psi_G_pr**2) + (-2*psi_G_prpr + (4*x - s1))*psi_G 

phi_pr = phi.derivative(x) 

 

psi_2 = 2*y + a1*x + a3 

 

omega = (psi_2*(phi_pr*psi_G - phi*psi_G_pr) - (a1*phi + a3*psi_G)*psi_G)/2 

 

phi = phi*psi_G 

omega = omega*psi_G 

 

(v,w) = compute_vw_kohel_even_deg3(b2,b4,s1,s2,s3) 

 

else: 

raise ValueError("input polynomial must be of degree 1 or 3, not %d" % n) 

 

return (phi, omega, v, w, n, d) 

 

 

def __init_odd_kernel_polynomial(self, E, psi): 

r""" 

Returns the isogeny parameters for a cyclic isogeny of odd degree. 

 

INPUT: 

 

- ``E`` -- an elliptic curve 

 

- ``psi`` -- a univariate polynomial over the base field of 

``E``, assumed to be a kernel polynomial 

 

OUTPUT: 

 

(phi, omega, v, w, n, d) where: 

 

- ``phi`` is a univariate polynomial, the numerator of the 

`X`-coordinate of the isogeny; 

 

- ``omega`` is a bivariate polynomial, the numerator of the 

`Y`-coordinate of the isogeny; 

 

- ``v``, ``w`` are the Velu parameters of the isogeny; 

 

- ``n`` is the degree of ``psi``; 

 

- ``d`` is the degree of the isogeny. 

 

EXAMPLES: 

 

These examples inherently exercise this private function:: 

 

sage: R.<x> = GF(7)[] 

sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) 

sage: phi = EllipticCurveIsogeny(E, x+6, degree=3); phi 

Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 1 over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 4*x + 2 over Finite Field of size 7 

 

sage: R.<x> = GF(7)[] 

sage: phi._EllipticCurveIsogeny__init_odd_kernel_polynomial(E, x+6) 

(x^3 + 5*x^2 + 3*x + 2, x^3*y - 3*x^2*y + x*y, 2, 6, 1, 3) 

 

sage: F = GF(2^4, 'alpha'); R.<x> = F[] 

sage: alpha = F.gen() 

sage: E = EllipticCurve(F, [1,1,F.gen(),F.gen()^2+1,1]) 

sage: f = x + alpha^2 + 1 

sage: phi = EllipticCurveIsogeny(E, f); phi 

Isogeny of degree 3 from Elliptic Curve defined by y^2 + x*y + alpha*y = x^3 + x^2 + (alpha^2+1)*x + 1 over Finite Field in alpha of size 2^4 to Elliptic Curve defined by y^2 + x*y + alpha*y = x^3 + x^2 + alpha*x + alpha^3 over Finite Field in alpha of size 2^4 

 

sage: R.<x> = F[] 

sage: f = x + alpha^2 + 1 

sage: phi._EllipticCurveIsogeny__init_odd_kernel_polynomial(E, f) 

(x^3 + (alpha^2 + 1)*x + alpha^3 + alpha^2 + alpha, x^3*y + (alpha^2 + 1)*x^2*y + (alpha^2 + alpha + 1)*x^2 + (alpha^2 + 1)*x*y + (alpha^2 + alpha)*x + (alpha)*y + (alpha), alpha^2 + alpha + 1, alpha^3 + alpha^2 + alpha, 1, 3) 

 

sage: E = EllipticCurve(j=-262537412640768000) 

sage: f = (E.isogenies_prime_degree()[0]).kernel_polynomial() 

sage: f.degree() 

81 

sage: E.isogeny(kernel=f) # long time (3.6s, 2014) 

Isogeny of degree 163 from Elliptic Curve defined by y^2 + y = x^3 - 2174420*x + 1234136692 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - 57772164980*x - 5344733777551611 over Rational Field 

""" 

n = psi.degree() 

d = 2*n + 1 

 

# check if the polynomial really divides the torsion polynomial : 

if self.__check: 

alpha = psi.parent().quotient(psi).gen() 

if not E.division_polynomial(d, x=alpha).is_zero(): 

raise ValueError("The polynomial does not define a finite subgroup of the elliptic curve.") 

 

b2, b4, b6, _ = E.b_invariants() 

 

psi_coeffs = psi.list() 

 

s1 = 0; s2 = 0; s3 = 0 

 

if (1 <= n): 

s1 = -psi_coeffs[n-1] 

 

if (2 <= n): 

s2 = psi_coeffs[n-2] 

 

if (3 <= n): 

s3 = -psi_coeffs[n-3] 

 

# initializing these allows us to calculate E2. 

(v,w) = compute_vw_kohel_odd(b2,b4,b6,s1,s2,s3,n) 

 

# initialize the polynomial temporary variables 

 

psi_pr = psi.derivative() 

psi_prpr = psi_pr.derivative() 

 

x = self.__poly_ring.gen() 

 

phi = (4*x**3 + b2*x**2 + 2*b4*x + b6)*(psi_pr**2 - psi_prpr*psi) - \ 

(6*x**2 + b2*x + b4)*psi_pr*psi + (d*x - 2*s1)*psi**2 

 

phi_pr = phi.derivative(x) 

 

if (2 != self.__base_field.characteristic()): 

omega = self.__compute_omega_fast(E, psi, psi_pr, phi, phi_pr) 

else: 

omega = self.__compute_omega_general(E, psi, psi_pr, phi, phi_pr) 

 

return (phi, omega, v, w, n, d) 

 

 

# 

# This is the fast omega computation that works when characteristic is not 2 

# 

def __compute_omega_fast(self, E, psi, psi_pr, phi, phi_pr): 

r""" 

Return omega from phi, psi and their derivatives, used when 

the characteristic field is not 2. 

 

INPUT: 

 

- ``E`` -- an elliptic curve. 

 

- ``psi, psi_pr, phi, phi_pr`` -- univariate polynomials over 

the base field of ``E``, where ``psi`` is the kernel 

polynomial and ``phi`` the numerator of the `X`-coordinate 

of the isogeny, together with their derivatives. 

 

OUTPUT: 

 

- ``omega`` -- a bivariate polynomial giving the numerator of 

the `Y`-coordinate of the isogeny. 

 

EXAMPLES: 

 

These examples inherently exercise this private function:: 

 

sage: R.<x> = GF(7)[] 

sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) 

sage: phi = EllipticCurveIsogeny(E, x+6, degree=3); phi 

Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 1 over Finite Field of size 7 to Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 4*x + 2 over Finite Field of size 7 

 

sage: R.<x,y> = GF(7)[] 

sage: psi = phi._EllipticCurveIsogeny__psi 

sage: psi_pr = psi.derivative() 

sage: fi = phi._EllipticCurveIsogeny__phi 

sage: fi_pr = fi.derivative() 

sage: phi._EllipticCurveIsogeny__compute_omega_fast(E, psi, psi_pr, fi, fi_pr) 

x^3*y - 3*x^2*y + x*y 

 

""" 

 

a1 = E.a1() 

a3 = E.a3() 

 

x, y = self.__mpoly_ring.gens() 

 

psi_2 = 2*y + a1*x + a3 

 

# note, the formula below is correct 

# the formula in Kohel's thesis has some typos 

# notably the first plus sign should be a minus 

# as it is here below. 

 

return phi_pr*psi*psi_2/2 - phi*psi_pr*psi_2 - (a1*phi + a3*psi**2)*psi/2 

 

def __compute_omega_general(self, E, psi, psi_pr, phi, phi_pr): 

r""" 

Return omega from phi, psi and their derivatives, in any 

characteristic. 

 

INPUT: 

 

- ``E`` -- an elliptic curve. 

 

- ``psi, psi_pr, phi, phi_pr`` -- univariate polynomials over 

the base field of ``E``, where ``psi`` is the kernel 

polynomial and ``phi`` the numerator of the `X`-coordinate 

of the isogeny, together with their derivatives. 

 

OUTPUT: 

 

- ``omega`` -- a bivariate polynomial giving the numerator of 

the `Y`-coordinate of the isogeny. 

 

EXAMPLES: 

 

These examples inherently exercise this private function:: 

 

sage: F = GF(2^4, 'alpha'); R.<x> = F[] 

sage: alpha = F.gen() 

sage: E = EllipticCurve(F, [1,1,F.gen(),F.gen()^2+1,1]) 

sage: f = x + alpha^2 + 1 

sage: phi = EllipticCurveIsogeny(E, f); phi 

Isogeny of degree 3 from Elliptic Curve defined by y^2 + x*y + alpha*y = x^3 + x^2 + (alpha^2+1)*x + 1 over Finite Field in alpha of size 2^4 to Elliptic Curve defined by y^2 + x*y + alpha*y = x^3 + x^2 + alpha*x + alpha^3 over Finite Field in alpha of size 2^4 

 

sage: R.<x,y> = F[] 

sage: psi = phi._EllipticCurveIsogeny__psi 

sage: psi_pr = psi.derivative() 

sage: fi = phi._EllipticCurveIsogeny__phi 

sage: fi_pr = fi.derivative() 

sage: phi._EllipticCurveIsogeny__compute_omega_general(E, psi, psi_pr, fi, fi_pr) 

x^3*y + (alpha^2 + 1)*x^2*y + (alpha^2 + alpha + 1)*x^2 + (alpha^2 + 1)*x*y + (alpha^2 + alpha)*x + (alpha)*y + (alpha) 

 

A bug fixed in :trac:`7907`:: 

 

sage: F = GF(128,'a') 

sage: a = F.gen() 

sage: E = EllipticCurve([1,0,0,0,(a**6+a**4+a**2+a)]) 

sage: x = polygen(F) 

sage: ker = (x^6 + (a^6 + a^5 + a^4 + a^3 + a^2 + a)*x^5 + (a^6 + a^5 + a^2 + 1)*x^4 + (a^6 + a^5 + a^4 + a^3 + a^2 + 1)*x^3 + (a^6 + a^3 + a)*x^2 + (a^4 + a^3 + 1)*x + a^5 + a^4 + a) 

sage: E.isogeny(ker) 

Isogeny of degree 13 from Elliptic Curve defined by y^2 + x*y = x^3 + (a^6+a^4+a^2+a) over Finite Field in a of size 2^7 to Elliptic Curve defined by y^2 + x*y = x^3 + (a^6+a^5+a^4+a^3+a^2+a)*x + (a^5+a^3) over Finite Field in a of size 2^7 

 

 

""" 

a1,a2,a3,a4,a6 = E.ainvs() 

b2, b4, _, _ = E.b_invariants() 

 

n = psi.degree() 

d = 2*n+1 

 

x, y = self.__mpoly_ring.gens() 

 

psi_2 = 2*y + a1*x + a3 

 

psi_coeffs = psi.list() 

 

if (0 < n): 

s1 = -psi_coeffs[n-1] 

else: 

s1 = 0 

 

psi_prpr = 0 

cur_x_pow = 1 

 

# Note: we now get the "derivatives" of psi 

# these are not actually the derivatives 

# furthermore, the formulas in Kohel's 

# thesis are wrong, the correct formulas 

# are coded below 

 

from sage.arith.all import binomial 

 

for j in range(n - 1): 

psi_prpr = psi_prpr + \ 

binomial(j+2,2)*psi_coeffs[(j+2)]*cur_x_pow 

cur_x_pow = x*cur_x_pow 

 

psi_prprpr = 0 

cur_x_pow = 1 

 

for j in range(n - 2): 

psi_prprpr = psi_prprpr + \ 

(3*binomial(j+3,3))*psi_coeffs[(j+3)]*cur_x_pow 

cur_x_pow = x*cur_x_pow 

 

 

omega = phi_pr*psi*y - phi*psi_pr*psi_2 + \ 

((a1*x + a3)*(psi_2**2)*(psi_prpr*psi_pr-psi_prprpr*psi) + \ 

(a1*psi_2**2 - 3*(a1*x + a3)*(6*x**2 + b2*x + b4))*psi_prpr*psi + \ 

(a1*x**3 + 3*a3*x**2 + (2*a2*a3 - a1*a4)*x + (a3*a4 - 2*a1*a6))*psi_pr**2 + \ 

(-(3*a1*x**2 + 6*a3*x + (-a1*a4 + 2*a2*a3)) + \ 

(a1*x + a3)*(d*x - 2*s1) )*psi_pr*psi + (a1*s1 + a3*n)*psi**2)*psi 

 

return omega 

 

 

def __compute_via_kohel_numeric(self, xP, yP): 

r""" 

Private function that computes the image of a point under this 

isogeny, using Kohel's formulas. 

 

EXAMPLES: 

 

These examples inherently exercise this private function:: 

 

sage: R.<x> = GF(7)[] 

sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) 

sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) 

sage: P = E((0,1)); phi(P) 

(2 : 0 : 1) 

sage: P = E((1,1)); phi(P) 

(0 : 1 : 0) 

sage: phi._EllipticCurveIsogeny__compute_via_kohel_numeric(0, 1) 

(2, 0) 

sage: phi._EllipticCurveIsogeny__compute_via_kohel_numeric(1, 1) 

(0 : 1 : 0) 

 

""" 

# first check if this point is in the kernel: 

 

if(0 == self.__inner_kernel_polynomial(x=xP)): 

return self.__intermediate_codomain(0) 

 

(xP_out, yP_out) = self.__compute_via_kohel(xP,yP) 

 

# xP_out and yP_out do not always get evaluated to field 

# elements but rather constant polynomials, so we do some 

# explicit casting 

 

return (self.__base_field(xP_out), self.__base_field(yP_out)) 

 

def __compute_via_kohel(self, xP, yP): 

r""" 

Private function that applies Kohel's formulas. 

 

EXAMPLES: 

 

These examples inherently exercise this private function:: 

 

sage: R.<x> = GF(7)[] 

sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) 

sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) 

sage: P = E((0,1)); phi(P) 

(2 : 0 : 1) 

sage: phi.rational_maps() 

((x^3 - 2*x^2 + 3*x + 2)/(x^2 - 2*x + 1), (x^3*y - 3*x^2*y + x*y)/(x^3 - 3*x^2 + 3*x - 1)) 

sage: phi._EllipticCurveIsogeny__compute_via_kohel(0,1) 

(2, 0) 

sage: R.<x,y> = GF(7)[] 

sage: phi._EllipticCurveIsogeny__compute_via_kohel(x,y) 

((x^3 - 2*x^2 + 3*x + 2)/(x^2 - 2*x + 1), (x^3*y - 3*x^2*y + x*y)/(x^3 - 3*x^2 + 3*x - 1)) 

 

""" 

a = self.__phi(xP) 

b = self.__omega(xP, yP) 

c = self.__psi(xP) 

cc = self.__mpoly_ring(c) 

 

return (a/c**2, b/cc**3) 

 

def __initialize_rational_maps_via_kohel(self): 

r""" 

Private function that computes and initializes the rational 

maps of this isogeny. 

 

EXAMPLES: 

 

These examples inherently exercise this private function:: 

 

sage: R.<x> = GF(7)[] 

sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) 

sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) 

sage: phi.rational_maps() 

((x^3 - 2*x^2 + 3*x + 2)/(x^2 - 2*x + 1), (x^3*y - 3*x^2*y + x*y)/(x^3 - 3*x^2 + 3*x - 1)) 

sage: phi._EllipticCurveIsogeny__initialize_rational_maps_via_kohel() 

((x^3 + 5*x^2 + 3*x + 2)/(x^2 + 5*x + 1), (x^3*y - 3*x^2*y + x*y)/(x^3 - 3*x^2 + 3*x - 1)) 

 

 

""" 

x = self.__poly_ring.gen() 

y = self.__mpoly_ring.gen(1) 

return self.__compute_via_kohel(x,y) 

 

# 

# Kohel's formula computing the codomain curve 

# 

def __compute_E2_via_kohel(self): 

r""" 

Private function that computes and initializes the codomain of 

the isogeny (via Kohel's.) 

 

EXAMPLES: 

 

These examples inherently exercise this private function:: 

 

sage: R.<x> = GF(7)[] 

sage: E = EllipticCurve(GF(7), [0,-1,0,0,1]) 

sage: phi = EllipticCurveIsogeny(E, x+6, degree=3) 

sage: phi.codomain() 

Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 4*x + 2 over Finite Field of size 7 

sage: phi._EllipticCurveIsogeny__compute_E2_via_kohel() 

Elliptic Curve defined by y^2 = x^3 + 6*x^2 + 4*x + 2 over Finite Field of size 7 

 

""" 

 

v = self.__v 

w = self.__w 

 

return compute_codomain_formula(self.__E1, v,w) 

 

# 

# public isogeny methods 

# 

 

def degree(self): 

r""" 

Returns the degree of this isogeny. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(QQ, [0,0,0,1,0]) 

sage: phi = EllipticCurveIsogeny(E, E((0,0))) 

sage: phi.degree() 

2 

sage: phi = EllipticCurveIsogeny(E, [0,1,0,1]) 

sage: phi.degree() 

4 

 

sage: E = EllipticCurve(GF(31), [1,0,0,1,2]) 

sage: phi = EllipticCurveIsogeny(E, [17, 1]) 

sage: phi.degree() 

3 

 

""" 

return self.__degree 

 

def rational_maps(self): 

r""" 

Return the pair of rational maps defining this isogeny. 

 

.. NOTE:: 

 

Both components are returned as elements of the function 

field `F(x,y)` in two variables over the base field `F`, 

though the first only involves `x`. To obtain the 

`x`-coordinate function as a rational function in `F(x)`, 

use :meth:`x_rational_map`. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(QQ, [0,2,0,1,-1]) 

sage: phi = EllipticCurveIsogeny(E, [1]) 

sage: phi.rational_maps() 

(x, y) 

 

sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) 

sage: phi = EllipticCurveIsogeny(E, E((0,0))) 

sage: phi.rational_maps() 

((x^2 + 3)/x, (x^2*y - 3*y)/x^2) 

""" 

if (not self.__rational_maps_initialized): 

self.__initialize_rational_maps() 

return (self.__xyfield(self.__X_coord_rational_map), 

self.__Y_coord_rational_map) 

 

def x_rational_map(self): 

r""" 

Return the rational map giving the `x`-coordinate of this isogeny. 

 

.. NOTE:: 

 

This function returns the `x`-coordinate component of the 

isogeny as a rational function in `F(x)`, where `F` is the 

base field. To obtain both coordinate functions as 

elements of the function field `F(x,y)` in two variables, 

use :meth:`rational_maps`. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(QQ, [0,2,0,1,-1]) 

sage: phi = EllipticCurveIsogeny(E, [1]) 

sage: phi.x_rational_map() 

x 

 

sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) 

sage: phi = EllipticCurveIsogeny(E, E((0,0))) 

sage: phi.x_rational_map() 

(x^2 + 3)/x 

""" 

if (not self.__rational_maps_initialized): 

self.__initialize_rational_maps() 

return self.__X_coord_rational_map 

 

def is_separable(self): 

r""" 

Return whether or not this isogeny is separable. 

 

.. NOTE:: 

 

This function always returns ``True`` as currently this 

class only implements separable isogenies. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(GF(17), [0,0,0,3,0]) 

sage: phi = EllipticCurveIsogeny(E, E((0,0))) 

sage: phi.is_separable() 

True 

 

sage: E = EllipticCurve('11a1') 

sage: phi = EllipticCurveIsogeny(E, E.torsion_points()) 

sage: phi.is_separable() 

True 

""" 

return self.__separable 

 

def kernel_polynomial(self): 

r""" 

Return the kernel polynomial of this isogeny. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(QQ, [0,0,0,2,0]) 

sage: phi = EllipticCurveIsogeny(E, E((0,0))) 

sage: phi.kernel_polynomial() 

x 

 

sage: E = EllipticCurve('11a1') 

sage: phi = EllipticCurveIsogeny(E, E.torsion_points()) 

sage: phi.kernel_polynomial() 

x^2 - 21*x + 80 

 

sage: E = EllipticCurve(GF(17), [1,-1,1,-1,1]) 

sage: phi = EllipticCurveIsogeny(E, [1]) 

sage: phi.kernel_polynomial() 

1 

 

sage: E = EllipticCurve(GF(31), [0,0,0,3,0]) 

sage: phi = EllipticCurveIsogeny(E, [0,3,0,1]) 

sage: phi.kernel_polynomial() 

x^3 + 3*x 

""" 

if self.__kernel_polynomial is None: 

self.__init_kernel_polynomial() 

 

return self.__kernel_polynomial 

 

 

def set_pre_isomorphism(self, preWI): 

r""" 

Modify this isogeny by precomposing with a Weierstrass isomorphism. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(GF(31), [1,1,0,1,-1]) 

sage: R.<x> = GF(31)[] 

sage: f = x^3 + 9*x^2 + x + 30 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: Epr = E.short_weierstrass_model() 

sage: isom = Epr.isomorphism_to(E) 

sage: phi.set_pre_isomorphism(isom) 

sage: phi.rational_maps() 

((-6*x^4 - 3*x^3 + 12*x^2 + 10*x - 1)/(x^3 + x - 12), (3*x^7 + x^6*y - 14*x^6 - 3*x^5 + 5*x^4*y + 7*x^4 + 8*x^3*y - 8*x^3 - 5*x^2*y + 5*x^2 - 14*x*y + 14*x - 6*y - 6)/(x^6 + 2*x^4 + 7*x^3 + x^2 + 7*x - 11)) 

sage: phi(Epr((0,22))) 

(13 : 21 : 1) 

sage: phi(Epr((3,7))) 

(14 : 17 : 1) 

 

sage: E = EllipticCurve(GF(29), [0,0,0,1,0]) 

sage: R.<x> = GF(29)[] 

sage: f = x^2 + 5 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: phi 

Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + x over Finite Field of size 29 to Elliptic Curve defined by y^2 = x^3 + 20*x over Finite Field of size 29 

sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism 

sage: inv_isom = WeierstrassIsomorphism(E, (1,-2,5,10)) 

sage: Epr = inv_isom.codomain().codomain() 

sage: isom = Epr.isomorphism_to(E) 

sage: phi.set_pre_isomorphism(isom); phi 

Isogeny of degree 5 from Elliptic Curve defined by y^2 + 10*x*y + 20*y = x^3 + 27*x^2 + 6 over Finite Field of size 29 to Elliptic Curve defined by y^2 = x^3 + 20*x over Finite Field of size 29 

sage: phi(Epr((12,1))) 

(26 : 0 : 1) 

sage: phi(Epr((2,9))) 

(0 : 0 : 1) 

sage: phi(Epr((21,12))) 

(3 : 0 : 1) 

sage: phi.rational_maps()[0] 

(x^5 - 10*x^4 - 6*x^3 - 7*x^2 - x + 3)/(x^4 - 8*x^3 + 5*x^2 - 14*x - 6) 

 

sage: E = EllipticCurve('11a1') 

sage: R.<x> = QQ[] 

sage: f = x^2 - 21*x + 80 

sage: phi = EllipticCurveIsogeny(E, f); phi 

Isogeny of degree 5 from Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - x^2 - 7820*x - 263580 over Rational Field 

sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism 

sage: Epr = E.short_weierstrass_model() 

sage: isom = Epr.isomorphism_to(E) 

sage: phi.set_pre_isomorphism(isom) 

sage: phi 

Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 - 13392*x - 1080432 over Rational Field to Elliptic Curve defined by y^2 + y = x^3 - x^2 - 7820*x - 263580 over Rational Field 

sage: phi(Epr((168,1188))) 

(0 : 1 : 0) 

""" 

WIdom = preWI.domain().codomain() 

WIcod = preWI.codomain().codomain() 

 

if not isinstance(preWI, WeierstrassIsomorphism): 

raise ValueError("Invalid parameter: isomorphism must be of type Weierstrass isomorphism.") 

 

if (self.__E1 != WIcod): 

raise ValueError("Invalid parameter: isomorphism must have codomain curve equal to this isogenies' domain.") 

 

if (self.__pre_isomorphism is None): 

isom = preWI 

domain = WIdom 

else: 

isom = self.__pre_isomorphism*preWI 

domain = WIdom 

 

self.__clear_cached_values() 

 

self.__set_pre_isomorphism(domain, isom) 

 

return 

 

 

def set_post_isomorphism(self, postWI): 

r""" 

Modify this isogeny by postcomposing with a Weierstrass isomorphism. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(j=GF(31)(0)) 

sage: R.<x> = GF(31)[] 

sage: phi = EllipticCurveIsogeny(E, x+18) 

sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism 

sage: phi.set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(), (6,8,10,12))) 

sage: phi 

Isogeny of degree 3 from Elliptic Curve defined by y^2 = x^3 + 1 over Finite Field of size 31 to Elliptic Curve defined by y^2 + 24*x*y + 7*y = x^3 + 22*x^2 + 16*x + 20 over Finite Field of size 31 

 

sage: E = EllipticCurve(j=GF(47)(0)) 

sage: f = E.torsion_polynomial(3)/3 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: E2 = phi.codomain() 

sage: post_isom = E2.isomorphism_to(E) 

sage: phi.set_post_isomorphism(post_isom) 

sage: phi.rational_maps() == E.multiplication_by_m(3) 

False 

sage: phi.switch_sign() 

sage: phi.rational_maps() == E.multiplication_by_m(3) 

True 

 

Example over a number field:: 

 

sage: R.<x> = QQ[] 

sage: K.<a> = NumberField(x^2 + 2) 

sage: E = EllipticCurve(j=K(1728)) 

sage: ker_list = E.torsion_points() 

sage: phi = EllipticCurveIsogeny(E, ker_list) 

sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism 

sage: post_isom = WeierstrassIsomorphism(phi.codomain(), (a,2,3,5)) 

sage: phi 

Isogeny of degree 4 from Elliptic Curve defined by y^2 = x^3 + x over Number Field in a with defining polynomial x^2 + 2 to Elliptic Curve defined by y^2 = x^3 + (-44)*x + 112 over Number Field in a with defining polynomial x^2 + 2 

 

""" 

WIdom = postWI.domain().codomain() 

WIcod = postWI.codomain().codomain() 

 

if not isinstance(postWI, WeierstrassIsomorphism): 

raise ValueError("Invalid parameter: isomorphism must be of type Weierstrass isomorphism.") 

 

if (self.__E2 != WIdom): 

raise ValueError("Invalid parameter: isomorphism must have domain curve equal to this isogenies' codomain.") 

 

if (self.__post_isomorphism is None): 

isom = postWI 

codomain = WIcod 

else: 

isom = postWI*self.__post_isomorphism 

codomain = WIcod 

 

self.__clear_cached_values() 

 

self.__set_post_isomorphism(codomain, isom) 

 

return 

 

 

def get_pre_isomorphism(self): 

r""" 

Return the pre-isomorphism of this isogeny, or ``None``. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(GF(31), [1,1,0,1,-1]) 

sage: R.<x> = GF(31)[] 

sage: f = x^3 + 9*x^2 + x + 30 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: phi.get_post_isomorphism() 

sage: Epr = E.short_weierstrass_model() 

sage: isom = Epr.isomorphism_to(E) 

sage: phi.set_pre_isomorphism(isom) 

sage: isom == phi.get_pre_isomorphism() 

True 

 

sage: E = EllipticCurve(GF(83), [1,0,1,1,0]) 

sage: R.<x> = GF(83)[]; f = x+24 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: E2 = phi.codomain() 

sage: phi2 = EllipticCurveIsogeny(E, None, E2, 2) 

sage: phi2.get_pre_isomorphism() 

Generic morphism: 

From: Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 + x over Finite Field of size 83 

To: Abelian group of points on Elliptic Curve defined by y^2 = x^3 + 62*x + 74 over Finite Field of size 83 

Via: (u,r,s,t) = (1, 76, 41, 3) 

""" 

return self.__pre_isomorphism 

 

def get_post_isomorphism(self): 

r""" 

Return the post-isomorphism of this isogeny, or ``None``. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(j=GF(31)(0)) 

sage: R.<x> = GF(31)[] 

sage: phi = EllipticCurveIsogeny(E, x+18) 

sage: phi.get_post_isomorphism() 

sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism 

sage: isom = WeierstrassIsomorphism(phi.codomain(), (6,8,10,12)) 

sage: phi.set_post_isomorphism(isom) 

sage: isom == phi.get_post_isomorphism() 

True 

 

sage: E = EllipticCurve(GF(83), [1,0,1,1,0]) 

sage: R.<x> = GF(83)[]; f = x+24 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: E2 = phi.codomain() 

sage: phi2 = EllipticCurveIsogeny(E, None, E2, 2) 

sage: phi2.get_post_isomorphism() 

Generic morphism: 

From: Abelian group of points on Elliptic Curve defined by y^2 = x^3 + 65*x + 69 over Finite Field of size 83 

To: Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + 16 over Finite Field of size 83 

Via: (u,r,s,t) = (1, 7, 42, 42) 

""" 

return self.__post_isomorphism 

 

 

def switch_sign(self): 

r""" 

Compose this isogeny with `[-1]` (negation). 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(GF(23), [0,0,0,1,0]) 

sage: f = E.torsion_polynomial(3)/3 

sage: phi = EllipticCurveIsogeny(E, f, E) 

sage: phi.rational_maps() == E.multiplication_by_m(3) 

False 

sage: phi.switch_sign() 

sage: phi.rational_maps() == E.multiplication_by_m(3) 

True 

 

sage: E = EllipticCurve(GF(17), [-2, 3, -5, 7, -11]) 

sage: R.<x> = GF(17)[] 

sage: f = x+6 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: phi 

Isogeny of degree 2 from Elliptic Curve defined by y^2 + 15*x*y + 12*y = x^3 + 3*x^2 + 7*x + 6 over Finite Field of size 17 to Elliptic Curve defined by y^2 + 15*x*y + 12*y = x^3 + 3*x^2 + 4*x + 8 over Finite Field of size 17 

sage: phi.rational_maps() 

((x^2 + 6*x + 4)/(x + 6), (x^2*y - 5*x*y + 8*x - 2*y)/(x^2 - 5*x + 2)) 

sage: phi.switch_sign() 

sage: phi 

Isogeny of degree 2 from Elliptic Curve defined by y^2 + 15*x*y + 12*y = x^3 + 3*x^2 + 7*x + 6 over Finite Field of size 17 to Elliptic Curve defined by y^2 + 15*x*y + 12*y = x^3 + 3*x^2 + 4*x + 8 over Finite Field of size 17 

sage: phi.rational_maps() 

((x^2 + 6*x + 4)/(x + 6), 

(2*x^3 - x^2*y - 5*x^2 + 5*x*y - 4*x + 2*y + 7)/(x^2 - 5*x + 2)) 

 

sage: E = EllipticCurve('11a1') 

sage: R.<x> = QQ[] 

sage: f = x^2 - 21*x + 80 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: (xmap1, ymap1) = phi.rational_maps() 

sage: phi.switch_sign() 

sage: (xmap2, ymap2) = phi.rational_maps() 

sage: xmap1 == xmap2 

True 

sage: ymap1 == -ymap2 - E.a1()*xmap2 - E.a3() 

True 

 

sage: K.<a> = NumberField(x^2 + 1) 

sage: E = EllipticCurve(K, [0,0,0,1,0]) 

sage: R.<x> = K[] 

sage: phi = EllipticCurveIsogeny(E, x-a) 

sage: phi.rational_maps() 

((x^2 + (-a)*x - 2)/(x + (-a)), (x^2*y + (-2*a)*x*y + y)/(x^2 + (-2*a)*x - 1)) 

sage: phi.switch_sign() 

sage: phi.rational_maps() 

((x^2 + (-a)*x - 2)/(x + (-a)), (-x^2*y + (2*a)*x*y - y)/(x^2 + (-2*a)*x - 1)) 

 

""" 

self.set_post_isomorphism(WeierstrassIsomorphism(self.__E2, (-1,0,-self.__E2.a1(),-self.__E2.a3()))) 

 

def is_normalized(self, via_formal=True, check_by_pullback=True): 

r""" 

Return whether this isogeny is normalized. 

 

.. NOTE:: 

 

An isogeny `\varphi\colon E\to E_2` between two given 

Weierstrass equations is said to be normalized if the 

constant `c` is `1` in `\varphi*(\omega_2) = c\cdot\omega`, 

where `\omega` and `omega_2` are the invariant 

differentials on `E` and `E_2` corresponding to the given 

equation. 

 

INPUT: 

 

- ``via_formal`` - (default: ``True``) If ``True`` it simply 

checks if the leading term of the formal series is 

1. Otherwise it uses a deprecated algorithm involving the 

second optional argument. 

 

- ``check_by_pullback`` - (default:``True``) Deprecated. 

 

EXAMPLES:: 

 

sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism 

sage: E = EllipticCurve(GF(7), [0,0,0,1,0]) 

sage: R.<x> = GF(7)[] 

sage: phi = EllipticCurveIsogeny(E, x) 

sage: phi.is_normalized() 

True 

sage: isom = WeierstrassIsomorphism(phi.codomain(), (3, 0, 0, 0)) 

sage: phi.set_post_isomorphism(isom) 

sage: phi.is_normalized() 

False 

sage: isom = WeierstrassIsomorphism(phi.codomain(), (5, 0, 0, 0)) 

sage: phi.set_post_isomorphism(isom) 

sage: phi.is_normalized() 

True 

sage: isom = WeierstrassIsomorphism(phi.codomain(), (1, 1, 1, 1)) 

sage: phi.set_post_isomorphism(isom) 

sage: phi.is_normalized() 

True 

 

sage: F = GF(2^5, 'alpha'); alpha = F.gen() 

sage: E = EllipticCurve(F, [1,0,1,1,1]) 

sage: R.<x> = F[] 

sage: phi = EllipticCurveIsogeny(E, x+1) 

sage: isom = WeierstrassIsomorphism(phi.codomain(), (alpha, 0, 0, 0)) 

sage: phi.is_normalized() 

True 

sage: phi.set_post_isomorphism(isom) 

sage: phi.is_normalized() 

False 

sage: isom = WeierstrassIsomorphism(phi.codomain(), (1/alpha, 0, 0, 0)) 

sage: phi.set_post_isomorphism(isom) 

sage: phi.is_normalized() 

True 

sage: isom = WeierstrassIsomorphism(phi.codomain(), (1, 1, 1, 1)) 

sage: phi.set_post_isomorphism(isom) 

sage: phi.is_normalized() 

True 

 

sage: E = EllipticCurve('11a1') 

sage: R.<x> = QQ[] 

sage: f = x^3 - x^2 - 10*x - 79/4 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: isom = WeierstrassIsomorphism(phi.codomain(), (2, 0, 0, 0)) 

sage: phi.is_normalized() 

True 

sage: phi.set_post_isomorphism(isom) 

sage: phi.is_normalized() 

False 

sage: isom = WeierstrassIsomorphism(phi.codomain(), (1/2, 0, 0, 0)) 

sage: phi.set_post_isomorphism(isom) 

sage: phi.is_normalized() 

True 

sage: isom = WeierstrassIsomorphism(phi.codomain(), (1, 1, 1, 1)) 

sage: phi.set_post_isomorphism(isom) 

sage: phi.is_normalized() 

True 

""" 

# easy algorithm using the formal expansion. 

if via_formal: 

phi_formal = self.formal(prec=5) 

return phi_formal[1] == 1 

 

# this is the old algorithm. it should be deprecated. 

check_prepost_isomorphism = False 

 

f_normalized = True 

 

if (check_by_pullback): 

 

(Xmap, Ymap) = self.rational_maps() 

 

E1 = self.__E1 

E2 = self.__E2 

 

a1 = E1.a1() 

a3 = E1.a3() 

 

a1pr = E2.a1() 

a3pr = E2.a3() 

 

x, y = self.__mpoly_ring.gens() 

 

Xmap_pr = Xmap.derivative(x) 

 

domain_inv_diff = 1/(2*y + a1*x + a3) 

codomain_inv_diff = Xmap_pr/(2*Ymap + a1pr*Xmap + a3pr) 

 

inv_diff_quo = domain_inv_diff/codomain_inv_diff 

 

if (1 == inv_diff_quo): 

f_normalized = True 

else: 

# For some reason, in certain cases, when the isogeny 

# is pre or post composed with a translation the 

# resulting rational functions are too complicated for 

# sage to simplify down to a constant in this case, we 

# do some cheating by checking if the post-composition 

# by isogeny has a non 1 scaling factor 

if ( inv_diff_quo.numerator().is_constant() and (inv_diff_quo.denominator().is_constant) ): 

f_normalized = False 

else: 

check_prepost_isomorphism = True 

else: 

check_prepost_isomorphism = True 

 

# If we skip checking by the pullback of the invariant 

# differential OR if that was inconclusive We explicitly check 

# if there is a post isomorphism and if it has a non 1 scaling 

# factor or if it is a just a translation. NOTE: This only 

# works because we are using algorithms for calculating the 

# isogenies that calculate a separable normalized isogeny, if 

# this changes, this check will no longer be correct. 

# 

if (check_prepost_isomorphism): 

post_isom = self.__post_isomorphism 

if (post_isom is not None): 

if (1 == self.__base_field(post_isom.u)): 

f_post_normalized = True 

else: 

f_post_normalized = False 

else: 

f_post_normalized = True 

 

pre_isom = self.__pre_isomorphism 

if (pre_isom is not None): 

if (1 == self.__base_field(pre_isom.u)): 

f_pre_normalized = True 

else: 

f_pre_normalized = False 

else: 

f_pre_normalized = True 

 

f_normalized = f_pre_normalized and f_post_normalized 

 

return f_normalized 

 

def dual(self): 

r""" 

Return the isogeny dual to this isogeny. 

 

.. NOTE:: 

 

If `\varphi\colon E \to E_2` is the given isogeny and `n` 

is its degree, then the dual is by definition the unique 

isogeny `\hat\varphi\colon E_2\to E` such that the 

compositions `\hat\varphi\circ\varphi` and 

`\varphi\circ\hat\varphi` are the multiplication-by-`n` 

maps on `E` and `E_2`, respectively. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a1') 

sage: R.<x> = QQ[] 

sage: f = x^2 - 21*x + 80 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: phi_hat = phi.dual() 

sage: phi_hat.domain() == phi.codomain() 

True 

sage: phi_hat.codomain() == phi.domain() 

True 

sage: (X, Y) = phi.rational_maps() 

sage: (Xhat, Yhat) = phi_hat.rational_maps() 

sage: Xm = Xhat.subs(x=X, y=Y) 

sage: Ym = Yhat.subs(x=X, y=Y) 

sage: (Xm, Ym) == E.multiplication_by_m(5) 

True 

 

sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) 

sage: R.<x> = GF(37)[] 

sage: f = x^3 + x^2 + 28*x + 33 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: phi_hat = phi.dual() 

sage: phi_hat.codomain() == phi.domain() 

True 

sage: phi_hat.domain() == phi.codomain() 

True 

sage: (X, Y) = phi.rational_maps() 

sage: (Xhat, Yhat) = phi_hat.rational_maps() 

sage: Xm = Xhat.subs(x=X, y=Y) 

sage: Ym = Yhat.subs(x=X, y=Y) 

sage: (Xm, Ym) == E.multiplication_by_m(7) 

True 

 

sage: E = EllipticCurve(GF(31), [0,0,0,1,8]) 

sage: R.<x> = GF(31)[] 

sage: f = x^2 + 17*x + 29 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: phi_hat = phi.dual() 

sage: phi_hat.codomain() == phi.domain() 

True 

sage: phi_hat.domain() == phi.codomain() 

True 

sage: (X, Y) = phi.rational_maps() 

sage: (Xhat, Yhat) = phi_hat.rational_maps() 

sage: Xm = Xhat.subs(x=X, y=Y) 

sage: Ym = Yhat.subs(x=X, y=Y) 

sage: (Xm, Ym) == E.multiplication_by_m(5) 

True 

 

Test for :trac:`23928`:: 

 

sage: E = EllipticCurve(j=GF(431**2)(4)) 

sage: phi = E.isogeny(E.lift_x(0)) 

sage: phi.dual() 

Isogeny of degree 2 from Elliptic Curve defined by y^2 = x^3 + 427*x over Finite Field in z2 of size 431^2 to Elliptic Curve defined by y^2 = x^3 + x over Finite Field in z2 of size 431^2 

 

Test (for :trac:`7096`):: 

 

sage: E = EllipticCurve('11a1') 

sage: phi = E.isogeny(E(5,5)) 

sage: phi.dual().dual() == phi 

True 

 

sage: k = GF(103) 

sage: E = EllipticCurve(k,[11,11]) 

sage: phi = E.isogeny(E(4,4)) 

sage: phi 

Isogeny of degree 5 from Elliptic Curve defined by y^2 = x^3 + 11*x + 11 over Finite Field of size 103 to Elliptic Curve defined by y^2 = x^3 + 25*x + 80 over Finite Field of size 103 

sage: from sage.schemes.elliptic_curves.weierstrass_morphism import WeierstrassIsomorphism 

sage: phi.set_post_isomorphism(WeierstrassIsomorphism(phi.codomain(),(5,0,1,2))) 

sage: phi.dual().dual() == phi 

True 

 

sage: E = EllipticCurve(GF(103),[1,0,0,1,-1]) 

sage: phi = E.isogeny(E(60,85)) 

sage: phi.dual() 

Isogeny of degree 7 from Elliptic Curve defined by y^2 + x*y = x^3 + 84*x + 34 over Finite Field of size 103 to Elliptic Curve defined by y^2 + x*y = x^3 + x + 102 over Finite Field of size 103 

 

Check that :trac:`17293` is fixed: 

 

sage: k.<s> = QuadraticField(2) 

sage: E = EllipticCurve(k, [-3*s*(4 + 5*s), 2*s*(2 + 14*s + 11*s^2)]) 

sage: phi = E.isogenies_prime_degree(3)[0] 

sage: (-phi).dual() == -(phi.dual()) 

True 

sage: phi._EllipticCurveIsogeny__clear_cached_values() # forget the dual 

sage: -(phi.dual()) == (-phi).dual() 

True 

 

""" 

if (self.__base_field.characteristic() in [2,3]): 

raise NotImplementedError("Computation of dual isogenies not yet implemented in characteristics 2 and 3") 

 

if (self.__dual is not None): 

return self.__dual 

 

# trac 7096 

(E1, E2pr, pre_isom, post_isom) = compute_intermediate_curves(self.codomain(), self.domain()) 

 

F = self.__base_field 

d = self.__degree 

 

# trac 7096 

if F(d) == 0: 

raise NotImplementedError("The dual isogeny is not separable: only separable isogenies are currently implemented") 

 

# trac 7096 

# this should take care of the case when the isogeny is not normalized. 

u = self.formal()[1] 

isom = WeierstrassIsomorphism(E2pr, (u/F(d), 0, 0, 0)) 

 

E2 = isom.codomain().codomain() 

 

pre_isom = self.__E2.isomorphism_to(E1) 

post_isom = E2.isomorphism_to(self.__E1) 

 

phi_hat = EllipticCurveIsogeny(E1, None, E2, d) 

 

phi_hat.set_pre_isomorphism(pre_isom) 

phi_hat.set_post_isomorphism(post_isom) 

phi_hat.__perform_inheritance_housekeeping() 

 

assert phi_hat.codomain() == self.domain() 

 

# trac 7096 : this adjusts a posteriori the automorphism on 

# the codomain of the dual isogeny. we used _a_ Weierstrass 

# isomorphism to get to the original curve, but we may have to 

# change it by an automorphism. We impose the condition that 

# the composition has the degree as a leading coefficient in 

# the formal expansion. 

 

phi_sc = self.formal()[1] 

phihat_sc = phi_hat.formal()[1] 

 

sc = phi_sc * phihat_sc/F(d) 

 

if sc == 0: 

raise RuntimeError("Bug in computing dual isogeny: sc = 0") 

 

if sc != 1: 

auts = self.__E1.automorphisms() 

aut = [a for a in auts if a.u == sc] 

if len(aut) != 1: 

raise ValueError("There is a bug in dual().") 

phi_hat.set_post_isomorphism(aut[0]) 

 

self.__dual = phi_hat 

 

return phi_hat 

 

def formal(self,prec=20): 

r""" 

Return the formal isogeny as a power series in the variable 

`t=-x/y` on the domain curve. 

 

INPUT: 

 

- ``prec`` - (default = 20), the precision with which the 

computations in the formal group are carried out. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(GF(13),[1,7]) 

sage: phi = E.isogeny(E(10,4)) 

sage: phi.formal() 

t + 12*t^13 + 2*t^17 + 8*t^19 + 2*t^21 + O(t^23) 

 

sage: E = EllipticCurve([0,1]) 

sage: phi = E.isogeny(E(2,3)) 

sage: phi.formal(prec=10) 

t + 54*t^5 + 255*t^7 + 2430*t^9 + 19278*t^11 + O(t^13) 

 

sage: E = EllipticCurve('11a2') 

sage: R.<x> = QQ[] 

sage: phi = E.isogeny(x^2 + 101*x + 12751/5) 

sage: phi.formal(prec=7) 

t - 2724/5*t^5 + 209046/5*t^7 - 4767/5*t^8 + 29200946/5*t^9 + O(t^10) 

""" 

Eh = self.__E1.formal() 

f, g = self.rational_maps() 

xh = Eh.x(prec=prec) 

if xh.valuation() != -2: 

raise RuntimeError("xh has valuation %s (should be -2)" % xh.valuation()) 

yh = Eh.y(prec=prec) 

if yh.valuation() != -3: 

raise RuntimeError("yh has valuation %s (should be -3)" % yh.valuation()) 

fh = f(xh,yh) 

if fh.valuation() != -2: 

raise RuntimeError("fh has valuation %s (should be -2)" % fh.valuation()) 

gh = g(xh,yh) 

if gh.valuation() != -3: 

raise RuntimeError("gh has valuation %s (should be -3)" % gh.valuation()) 

th = -fh/gh 

if th.valuation() != 1: 

raise RuntimeError("th has valuation %s (should be +1)" % th.valuation()) 

return th 

 

# 

# Overload Morphism methods that we want to 

# 

 

def is_injective(self): 

r""" 

Return ``True`` if and only if this isogeny has trivial 

kernel. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a1') 

sage: R.<x> = QQ[] 

sage: f = x^2 + x - 29/5 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: phi.is_injective() 

False 

sage: phi = EllipticCurveIsogeny(E, R(1)) 

sage: phi.is_injective() 

True 

 

sage: F = GF(7) 

sage: E = EllipticCurve(j=F(0)) 

sage: phi = EllipticCurveIsogeny(E, [ E((0,-1)), E((0,1))]) 

sage: phi.is_injective() 

False 

sage: phi = EllipticCurveIsogeny(E, E(0)) 

sage: phi.is_injective() 

True 

""" 

if (1 < self.__degree): return False 

return True 

 

def is_surjective(self): 

r""" 

Return ``True`` if and only if this isogeny is surjective. 

 

.. NOTE:: 

 

This function always returns ``True``, as a non-constant 

map of algebraic curves must be surjective, and this class 

does not model the constant `0` isogeny. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve('11a1') 

sage: R.<x> = QQ[] 

sage: f = x^2 + x - 29/5 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: phi.is_surjective() 

True 

 

sage: E = EllipticCurve(GF(7), [0,0,0,1,0]) 

sage: phi = EllipticCurveIsogeny(E, E((0,0))) 

sage: phi.is_surjective() 

True 

 

sage: F = GF(2^5, 'omega') 

sage: E = EllipticCurve(j=F(0)) 

sage: R.<x> = F[] 

sage: phi = EllipticCurveIsogeny(E, x) 

sage: phi.is_surjective() 

True 

""" 

return True 

 

def is_zero(self): 

r""" 

Return whether this isogeny is zero. 

 

.. NOTE:: 

 

Currently this class does not allow zero isogenies, so this 

function will always return True. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(j=GF(7)(0)) 

sage: phi = EllipticCurveIsogeny(E, [ E((0,1)), E((0,-1))]) 

sage: phi.is_zero() 

False 

""" 

return self.degree().is_zero() 

 

def post_compose(self, left): 

r""" 

Return the post-composition of this isogeny with ``left``. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(j=GF(7)(0)) 

sage: phi = EllipticCurveIsogeny(E, [ E((0,1)), E((0,-1))]) 

sage: phi.post_compose(phi) 

Traceback (most recent call last): 

... 

NotImplementedError: post-composition of isogenies not yet implemented 

""" 

raise NotImplementedError("post-composition of isogenies not yet implemented") 

 

def pre_compose(self, right): 

r""" 

Return the pre-composition of this isogeny with ``right``. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(j=GF(7)(0)) 

sage: phi = EllipticCurveIsogeny(E, [ E((0,1)), E((0,-1))]) 

sage: phi.pre_compose(phi) 

Traceback (most recent call last): 

... 

NotImplementedError: pre-composition of isogenies not yet implemented 

""" 

raise NotImplementedError("pre-composition of isogenies not yet implemented") 

 

def n(self): 

r""" 

Numerical Approximation inherited from Map (through morphism), 

nonsensical for isogenies. 

 

EXAMPLES:: 

 

sage: E = EllipticCurve(j=GF(7)(0)) 

sage: phi = EllipticCurveIsogeny(E, [ E((0,1)), E((0,-1))]) 

sage: phi.n() 

Traceback (most recent call last): 

... 

NotImplementedError: Numerical approximations do not make sense for Elliptic Curve Isogenies 

""" 

raise NotImplementedError("Numerical approximations do not make sense for Elliptic Curve Isogenies") 

 

def compute_isogeny_starks(E1, E2, ell): 

r""" 

Return the kernel polynomials of an isogeny of degree ``ell`` 

between ``E1`` and ``E2``. 

 

INPUT: 

 

- ``E1`` - an elliptic curve in short Weierstrass form. 

- ``E2`` - an elliptic curve in short Weierstrass form. 

- ``ell`` - the degree of the isogeny from E1 to E2. 

 

OUTPUT: 

 

polynomial over the field of definition of ``E1``, ``E2``, that is 

the kernel polynomial of the isogeny from ``E1`` to ``E2``. 

 

.. NOTE:: 

 

There must be a degree ``ell``, separable, normalized cyclic 

isogeny from ``E1`` to ``E2``, or an error will be raised. 

 

ALGORITHM: 

 

This function uses Starks Algorithm as presented in section 6.2 of 

[BMSS]_. 

 

.. NOTE:: 

 

As published in [BMSS]_, the algorithm is incorrect, and a 

correct version (with slightly different notation) can be found 

in [M09]_. The algorithm originates in [S72]_. 

 

REFERENCES: 

 

.. [BMSS] Boston, Morain, Salvy, Schost, "Fast Algorithms for Isogenies." 

.. [M09] Moody, "The Diffie-Hellman Problem and Generalization of Verheul's Theorem" 

.. [S72] Stark, "Class-numbers of complex quadratic fields." 

 

EXAMPLES:: 

 

sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_isogeny_starks, compute_sequence_of_maps 

 

sage: E = EllipticCurve(GF(97), [1,0,1,1,0]) 

sage: R.<x> = GF(97)[]; f = x^5 + 27*x^4 + 61*x^3 + 58*x^2 + 28*x + 21 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: E2 = phi.codomain() 

sage: (isom1, isom2, E1pr, E2pr, ker_poly) = compute_sequence_of_maps(E, E2, 11) 

sage: compute_isogeny_starks(E1pr, E2pr, 11) 

x^10 + 37*x^9 + 53*x^8 + 66*x^7 + 66*x^6 + 17*x^5 + 57*x^4 + 6*x^3 + 89*x^2 + 53*x + 8 

 

sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) 

sage: R.<x> = GF(37)[] 

sage: f = (x + 14) * (x + 30) 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: E2 = phi.codomain() 

sage: compute_isogeny_starks(E, E2, 5) 

x^4 + 14*x^3 + x^2 + 34*x + 21 

sage: f**2 

x^4 + 14*x^3 + x^2 + 34*x + 21 

 

sage: E = EllipticCurve(QQ, [0,0,0,1,0]) 

sage: R.<x> = QQ[] 

sage: f = x 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: E2 = phi.codomain() 

sage: compute_isogeny_starks(E, E2, 2) 

x 

""" 

K = E1.base_field() 

R = PolynomialRing(K, 'x') 

x = R.gen() 

 

wp1 = E1.weierstrass_p(prec=4*ell+4) #BMSS claim 2*ell is enough, but it is not M09 

wp2 = E2.weierstrass_p(prec=4*ell+4) 

 

# viewed them as power series in Z = z^2 

S = LaurentSeriesRing(K, 'Z') 

Z = S.gen() 

pe1 = 1/Z 

pe2 = 1/Z 

for i in range(2 * ell + 1): 

pe1 += wp1[2*i] * Z**i 

pe2 += wp2[2*i] * Z**i 

pe1 = pe1.add_bigoh(2*ell+2) 

pe2 = pe2.add_bigoh(2*ell+2) 

 

n = 1 

q = [R(1), R(0)] 

T = pe2 

 

while ( q[n].degree() < (ell-1) ): 

n += 1 

a_n = 0 

r = -T.valuation() 

while (0 <= r): 

t_r = T[-r] 

a_n = a_n + t_r * x**r 

T = T - t_r*pe1**r 

r = -T.valuation() 

 

q_n = a_n*q[n-1] + q[n-2] 

q.append(q_n) 

 

if (n == ell+1 or T == 0): 

if (T == 0 or T.valuation()<2): 

raise ValueError("The two curves are not linked by a cyclic normalized isogeny of degree %s" % ell) 

break 

 

T = 1/T 

 

qn = q[n] 

qn = (1/qn.leading_coefficient())*qn 

 

return qn 

 

def split_kernel_polynomial(poly): 

r""" 

Internal helper function for ``compute_isogeny_kernel_polynomial``. 

 

INPUT: 

 

- ``poly`` -- a nonzero univariate polynomial. 

 

OUTPUT: 

 

The maximum separable divisor of ``poly``. If the input is a full 

kernel polynomial where the roots which are `x`-coordinates of 

points of order greater than 2 have multiplicity 1, the output 

will be a polynomial with the same roots, all of multiplicity 1. 

 

EXAMPLES: 

 

The following example implicitly exercises this function:: 

 

sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) 

sage: R.<x> = GF(37)[] 

sage: f = (x + 10) * (x + 12) * (x + 16) 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: E2 = phi.codomain() 

sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_isogeny_starks 

sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import split_kernel_polynomial 

sage: ker_poly = compute_isogeny_starks(E, E2, 7); ker_poly 

x^6 + 2*x^5 + 20*x^4 + 11*x^3 + 36*x^2 + 35*x + 16 

sage: ker_poly.factor() 

(x + 10)^2 * (x + 12)^2 * (x + 16)^2 

sage: poly = split_kernel_polynomial(ker_poly); poly 

x^3 + x^2 + 28*x + 33 

sage: poly.factor() 

(x + 10) * (x + 12) * (x + 16) 

""" 

from sage.misc.all import prod 

return prod([p for p,e in poly.squarefree_decomposition()]) 

 

def compute_isogeny_kernel_polynomial(E1, E2, ell, algorithm="starks"): 

r""" 

Return the kernel polynomial of an isogeny of degree ``ell`` 

between ``E1`` and ``E2``. 

 

INPUT: 

 

- ``E1`` - an elliptic curve in short Weierstrass form. 

 

- ``E2`` - an elliptic curve in short Weierstrass form. 

 

- ``ell`` - the degree of the isogeny from ``E1`` to ``E2``. 

 

- ``algorithm`` - currently only ``starks`` (default) is implemented. 

 

OUTPUT: 

 

polynomial over the field of definition of ``E1``, ``E2``, that is 

the kernel polynomial of the isogeny from ``E1`` to ``E2``. 

 

 

.. NOTE:: 

 

If there is no degree ``ell``, cyclic, separable, normalized 

isogeny from ``E1`` to ``E2`` then an error will be raised. 

 

 

EXAMPLES:: 

 

sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_isogeny_kernel_polynomial 

 

sage: E = EllipticCurve(GF(37), [0,0,0,1,8]) 

sage: R.<x> = GF(37)[] 

sage: f = (x + 14) * (x + 30) 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: E2 = phi.codomain() 

sage: compute_isogeny_kernel_polynomial(E, E2, 5) 

x^2 + 7*x + 13 

sage: f 

x^2 + 7*x + 13 

 

sage: R.<x> = QQ[] 

sage: K.<i> = NumberField(x^2 + 1) 

sage: E = EllipticCurve(K, [0,0,0,1,0]) 

sage: E2 = EllipticCurve(K, [0,0,0,16,0]) 

sage: compute_isogeny_kernel_polynomial(E, E2, 4) 

x^3 + x 

""" 

return split_kernel_polynomial(compute_isogeny_starks(E1, E2, ell)) 

 

def compute_intermediate_curves(E1, E2): 

r""" 

Return intermediate curves and isomorphisms. 

 

.. NOTE:: 

 

This is used so we can compute `\wp` functions from the short 

Weierstrass model more easily. 

 

.. WARNING:: 

 

The base field must be of characteristic not equal to 2,3. 

 

INPUT: 

 

- ``E1`` - an elliptic curve 

- ``E2`` - an elliptic curve 

 

OUTPUT: 

 

tuple (``pre_isomorphism``, ``post_isomorphism``, 

``intermediate_domain``, ``intermediate_codomain``): 

 

- ``intermediate_domain``: a short Weierstrass model isomorphic to 

``E1`` 

 

- ``intermediate_codomain``: a short Weierstrass model isomorphic 

to ``E2`` 

 

- ``pre_isomorphism``: normalized isomorphism from ``E1`` to 

intermediate_domain 

 

- ``post_isomorphism``: normalized isomorphism from 

intermediate_codomain to ``E2`` 

 

EXAMPLES:: 

 

sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_intermediate_curves 

sage: E = EllipticCurve(GF(83), [1,0,1,1,0]) 

sage: R.<x> = GF(83)[]; f = x+24 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: E2 = phi.codomain() 

sage: compute_intermediate_curves(E, E2) 

(Elliptic Curve defined by y^2 = x^3 + 62*x + 74 over Finite Field of size 83, 

Elliptic Curve defined by y^2 = x^3 + 65*x + 69 over Finite Field of size 83, 

Generic morphism: 

From: Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 + x over Finite Field of size 83 

To: Abelian group of points on Elliptic Curve defined by y^2 = x^3 + 62*x + 74 over Finite Field of size 83 

Via: (u,r,s,t) = (1, 76, 41, 3), 

Generic morphism: 

From: Abelian group of points on Elliptic Curve defined by y^2 = x^3 + 65*x + 69 over Finite Field of size 83 

To: Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 + 4*x + 16 over Finite Field of size 83 

Via: (u,r,s,t) = (1, 7, 42, 42)) 

 

sage: R.<x> = QQ[] 

sage: K.<i> = NumberField(x^2 + 1) 

sage: E = EllipticCurve(K, [0,0,0,1,0]) 

sage: E2 = EllipticCurve(K, [0,0,0,16,0]) 

sage: compute_intermediate_curves(E, E2) 

(Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1, 

Elliptic Curve defined by y^2 = x^3 + 16*x over Number Field in i with defining polynomial x^2 + 1, 

Generic endomorphism of Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1 

Via: (u,r,s,t) = (1, 0, 0, 0), 

Generic endomorphism of Abelian group of points on Elliptic Curve defined by y^2 = x^3 + 16*x over Number Field in i with defining polynomial x^2 + 1 

Via: (u,r,s,t) = (1, 0, 0, 0)) 

 

""" 

if (E1.base_ring().characteristic() in [2,3]): 

raise NotImplementedError("compute_intermediate_curves is only defined for characteristics not 2 or 3") 

 

# We cannot just use 

# E1w = E1.short_weierstrass_model() 

# E2w = E2.short_weierstrass_model() 

# as the resulting isomorphisms would not be normalised (u=1) 

 

c4, c6 = E1.c_invariants() 

E1w = EllipticCurve([0,0,0,-c4/48, -c6/864]) 

c4, c6 = E2.c_invariants() 

E2w = EllipticCurve([0,0,0,-c4/48, -c6/864]) 

 

# We cannot even just use pre_iso = E1.isomorphism_to(E1w) since 

# it may have u=-1; similarly for E2 

 

urst = [w for w in isomorphisms(E1,E1w) if w[0]==1][0] 

pre_iso = WeierstrassIsomorphism(E1,urst,E1w) 

urst = [w for w in isomorphisms(E2w,E2) if w[0]==1][0] 

post_iso = WeierstrassIsomorphism(E2w,urst,E2) 

return (E1w, E2w, pre_iso, post_iso) 

 

def compute_sequence_of_maps(E1, E2, ell): 

r""" 

Return intermediate curves, isomorphisms and kernel polynomial. 

 

INPUT: 

 

- ``E1``, ``E2`` -- elliptic curves. 

 

- ``ell`` -- a prime such that there is a degree ``ell`` separable 

normalized isogeny from ``E1`` to ``E2``. 

 

OUTPUT: 

 

(pre_isom, post_isom, E1pr, E2pr, ker_poly) where: 

 

- ``E1pr`` is an elliptic curve in short Weierstrass form 

isomorphic to ``E1``; 

 

- ``E2pr`` is an elliptic curve in short Weierstrass form 

isomorphic to ``E2``; 

 

- ``pre_isom`` is a normalised isomorphism from ``E1`` to 

``E1pr``; 

 

- ``post_isom`` is a normalised isomorphism from ``E2pr`` to 

``E2``; 

 

- ``ker_poly`` is the kernel polynomial of an ``ell``-isogeny from 

``E1pr`` to ``E2pr``. 

 

EXAMPLES:: 

 

sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import compute_sequence_of_maps 

sage: E = EllipticCurve('11a1') 

sage: R.<x> = QQ[]; f = x^2 - 21*x + 80 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: E2 = phi.codomain() 

sage: compute_sequence_of_maps(E, E2, 5) 

(Generic morphism: 

From: Abelian group of points on Elliptic Curve defined by y^2 + y = x^3 - x^2 - 10*x - 20 over Rational Field 

To: Abelian group of points on Elliptic Curve defined by y^2 = x^3 - 31/3*x - 2501/108 over Rational Field 

Via: (u,r,s,t) = (1, 1/3, 0, -1/2), 

Generic morphism: 

From: Abelian group of points on Elliptic Curve defined by y^2 = x^3 - 23461/3*x - 28748141/108 over Rational Field 

To: Abelian group of points on Elliptic Curve defined by y^2 + y = x^3 - x^2 - 7820*x - 263580 over Rational Field 

Via: (u,r,s,t) = (1, -1/3, 0, 1/2), 

Elliptic Curve defined by y^2 = x^3 - 31/3*x - 2501/108 over Rational Field, 

Elliptic Curve defined by y^2 = x^3 - 23461/3*x - 28748141/108 over Rational Field, 

x^2 - 61/3*x + 658/9) 

 

sage: K.<i> = NumberField(x^2 + 1) 

sage: E = EllipticCurve(K, [0,0,0,1,0]) 

sage: E2 = EllipticCurve(K, [0,0,0,16,0]) 

sage: compute_sequence_of_maps(E, E2, 4) 

(Generic endomorphism of Abelian group of points on Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1 

Via: (u,r,s,t) = (1, 0, 0, 0), 

Generic endomorphism of Abelian group of points on Elliptic Curve defined by y^2 = x^3 + 16*x over Number Field in i with defining polynomial x^2 + 1 

Via: (u,r,s,t) = (1, 0, 0, 0), 

Elliptic Curve defined by y^2 = x^3 + x over Number Field in i with defining polynomial x^2 + 1, 

Elliptic Curve defined by y^2 = x^3 + 16*x over Number Field in i with defining polynomial x^2 + 1, 

x^3 + x) 

 

sage: E = EllipticCurve(GF(97), [1,0,1,1,0]) 

sage: R.<x> = GF(97)[]; f = x^5 + 27*x^4 + 61*x^3 + 58*x^2 + 28*x + 21 

sage: phi = EllipticCurveIsogeny(E, f) 

sage: E2 = phi.codomain() 

sage: compute_sequence_of_maps(E, E2, 11) 

(Generic morphism: 

From: Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 + x over Finite Field of size 97 

To: Abelian group of points on Elliptic Curve defined by y^2 = x^3 + 52*x + 31 over Finite Field of size 97 

Via: (u,r,s,t) = (1, 8, 48, 44), 

Generic morphism: 

From: Abelian group of points on Elliptic Curve defined by y^2 = x^3 + 41*x + 66 over Finite Field of size 97 

To: Abelian group of points on Elliptic Curve defined by y^2 + x*y + y = x^3 + 87*x + 26 over Finite Field of size 97 

Via: (u,r,s,t) = (1, 89, 49, 49), 

Elliptic Curve defined by y^2 = x^3 + 52*x + 31 over Finite Field of size 97, 

Elliptic Curve defined by y^2 = x^3 + 41*x + 66 over Finite Field of size 97, 

x^5 + 67*x^4 + 13*x^3 + 35*x^2 + 77*x + 69) 

""" 

(E1pr, E2pr, pre_isom, post_isom) = compute_intermediate_curves(E1, E2) 

 

ker_poly = compute_isogeny_kernel_polynomial(E1pr, E2pr, ell) 

 

return (pre_isom, post_isom, E1pr, E2pr, ker_poly) 

 

 

# Utility function for manipulating isogeny degree matrices 

 

def fill_isogeny_matrix(M): 

""" 

Returns a filled isogeny matrix giving all degrees from one giving only prime degrees. 

 

INPUT: 

 

- ``M`` -- a square symmetric matrix whose off-diagonal `i`, `j` 

entry is either a prime `l` (if the `i`'th and `j`'th curves 

have an `l`-isogeny between them), otherwise is 0. 

 

OUTPUT: 

 

(matrix) a square matrix with entries `1` on the diagonal, and in 

general the `i`, `j` entry is `d>0` if `d` is the minimal degree 

of an isogeny from the `i`'th to the `j`'th curve, 

 

EXAMPLES:: 

 

sage: M = Matrix([[0, 2, 3, 3, 0, 0], [2, 0, 0, 0, 3, 3], [3, 0, 0, 0, 2, 0], [3, 0, 0, 0, 0, 2], [0, 3, 2, 0, 0, 0], [0, 3, 0, 2, 0, 0]]); M 

[0 2 3 3 0 0] 

[2 0 0 0 3 3] 

[3 0 0 0 2 0] 

[3 0 0 0 0 2] 

[0 3 2 0 0 0] 

[0 3 0 2 0 0] 

sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import fill_isogeny_matrix 

sage: fill_isogeny_matrix(M) 

[ 1 2 3 3 6 6] 

[ 2 1 6 6 3 3] 

[ 3 6 1 9 2 18] 

[ 3 6 9 1 18 2] 

[ 6 3 2 18 1 9] 

[ 6 3 18 2 9 1] 

""" 

from sage.matrix.all import Matrix 

from sage.rings.infinity import Infinity 

 

n = M.nrows() 

M0 = copy(M) 

for i in range(n): 

M0[i,i]=1 

 

def fix(d): 

if d==0: return Infinity 

return d 

 

def fix2(d): 

if d==Infinity: return 0 

return d 

 

def pr(M1,M2): 

return Matrix([[fix2(min([fix(M1[i,k]*M2[k,j]) for k in range(n)])) for i in range(n)] for j in range(n)]) 

 

M1 = M0 

M2 = pr(M0,M1) 

while M1!=M2: 

M1 = M2 

M2 = pr(M0,M1) 

 

return M1 

 

def unfill_isogeny_matrix(M): 

""" 

Reverses the action of ``fill_isogeny_matrix``. 

 

INPUT: 

 

- ``M`` -- a square symmetric matrix of integers. 

 

OUTPUT: 

 

(matrix) a square symmetric matrix obtained from ``M`` by 

replacing non-prime entries with `0`. 

 

EXAMPLES:: 

 

sage: M = Matrix([[0, 2, 3, 3, 0, 0], [2, 0, 0, 0, 3, 3], [3, 0, 0, 0, 2, 0], [3, 0, 0, 0, 0, 2], [0, 3, 2, 0, 0, 0], [0, 3, 0, 2, 0, 0]]); M 

[0 2 3 3 0 0] 

[2 0 0 0 3 3] 

[3 0 0 0 2 0] 

[3 0 0 0 0 2] 

[0 3 2 0 0 0] 

[0 3 0 2 0 0] 

sage: from sage.schemes.elliptic_curves.ell_curve_isogeny import fill_isogeny_matrix, unfill_isogeny_matrix 

sage: M1 = fill_isogeny_matrix(M); M1 

[ 1 2 3 3 6 6] 

[ 2 1 6 6 3 3] 

[ 3 6 1 9 2 18] 

[ 3 6 9 1 18 2] 

[ 6 3 2 18 1 9] 

[ 6 3 18 2 9 1] 

sage: unfill_isogeny_matrix(M1) 

[0 2 3 3 0 0] 

[2 0 0 0 3 3] 

[3 0 0 0 2 0] 

[3 0 0 0 0 2] 

[0 3 2 0 0 0] 

[0 3 0 2 0 0] 

sage: unfill_isogeny_matrix(M1) == M 

True 

""" 

from sage.matrix.all import Matrix 

from sage.rings.infinity import Infinity 

 

n = M.nrows() 

M1 = copy(M) 

zero = Integer(0) 

for i in range(n): 

M1[i,i] = zero 

for j in range(i): 

if not M1[i,j].is_prime(): 

M1[i,j] = zero 

M1[j,i] = zero 

return M1