ec.c (ecpt_pyrichcompare): Fix point comparisons.
authorMark Wooding <mdw@distorted.org.uk>
Tue, 15 Oct 2019 11:09:44 +0000 (12:09 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Sun, 17 Nov 2019 02:50:40 +0000 (02:50 +0000)
Previously we'd just reject comparisons of points with different curves.
Instead, support comparing curveless points with curvy ones by just
comparing the points coordinatewise.

Unfortunately, to make equality be transitive, this means permitting
comparisons between points on different curves, which is unpleasant.

ec.c

diff --git a/ec.c b/ec.c
index 1bf24cf..cfe785a 100644 (file)
--- a/ec.c
+++ b/ec.c
@@ -206,15 +206,13 @@ static long ecpt_pyhash(PyObject *me)
 
 static PyObject *ecpt_pyrichcompare(PyObject *x, PyObject *y, int op)
 {
-  ec_curve *c;
-  PyObject *cobj;
   ec p = EC_INIT, q = EC_INIT;
   int b;
   PyObject *rc = 0;
 
-  if (ecbinop(x, y, &c, &cobj, &p, &q)) RETURN_NOTIMPL;
-  EC_OUT(c, &p, &p);
-  EC_OUT(c, &q, &q);
+  if (!ECPT_PYCHECK(y)) RETURN_NOTIMPL;
+  getecptout(&p, x);
+  getecptout(&q, y);
   switch (op) {
     case Py_EQ: b = EC_EQ(&p, &q); break;
     case Py_NE: b = !EC_EQ(&p, &q); break;