Skip to content

Lifting x-coordinates for Hyperelliptic curves over finite fields of characteristic two fails #37097

@GiacomoPope

Description

@GiacomoPope

Steps To Reproduce

There is no handling for characteristic two when lifting points on a hyperelliptic curve as there is a division by two when computing the roots.

sage: F = GF(2^4)
sage: R.<x> = PolynomialRing(F)
sage: f = x^5 + x^2 + 1
sage: h = 1
sage: H.lift_x(1)
---------------------------------------------------------------------------
ZeroDivisionError                         Traceback (most recent call last)
Cell In [19], line 1
----> 1 H.lift_x(Integer(1))

File ~/sage/sage-10.2/src/sage/schemes/hyperelliptic_curves/hyperelliptic_generic.py:269, in HyperellipticCurve_generic.lift_x(self, x, all)
    267             return [self.point([x, (-b+d)/2, one], check=False) for d in D.sqrt(all=True)]
    268         else:
--> 269             return self.point([x, (-b+D.sqrt())/2, one], check=False)
    270 if all:
    271     return []

File ~/sage/sage-10.2/src/sage/structure/element.pyx:1742, in sage.structure.element.Element.__truediv__()
   1740 
   1741         try:
-> 1742             return coercion_model.bin_op(left, right, truediv)
   1743         except TypeError:
   1744             return NotImplemented

File ~/sage/sage-10.2/src/sage/structure/coerce.pyx:1232, in sage.structure.coerce.CoercionModel.bin_op()
   1230     self._record_exception()
   1231 else:
-> 1232     return PyObject_CallObject(op, xy)
   1233 
   1234 if op is mul:

File ~/sage/sage-10.2/src/sage/structure/element.pyx:1737, in sage.structure.element.Element.__truediv__()
   1735 cdef int cl = classify_elements(left, right)
   1736 if HAVE_SAME_PARENT(cl):
-> 1737     return (<Element>left)._div_(right)
   1738 if BOTH_ARE_ELEMENT(cl):
   1739     return coercion_model.bin_op(left, right, truediv)

File ~/sage/sage-10.2/src/sage/rings/finite_rings/element_givaro.pyx:1128, in sage.rings.finite_rings.element_givaro.FiniteField_givaroElement._div_()
   1126 cdef int r = 0
   1127 if (<FiniteField_givaroElement>right).element == 0:
-> 1128     raise ZeroDivisionError('division by zero in finite field')
   1129 self._cache.objectptr.div(r, self.element,
   1130                           (<FiniteField_givaroElement>right).element)

ZeroDivisionError: division by zero in finite field

Expected Behavior

Characteristic two is handled properly

Actual Behavior

The code crashes.

Additional Information

No response

Environment

- **OS**:
- **Sage Version**:

Checklist

  • I have searched the existing issues for a bug report that matches the one I want to file, without success.
  • I have read the documentation and troubleshoot guide

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions