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;
if (EC_ATINF(&p))
n = 2;
else
- n = mp_octets(p.x) + mp_octets(p.y) + 4;
+ n = mp_octets(p.x) + mp_octets(p.y) + 6;
rc = bytestring_pywrap(0, n);
buf_init(&b, PyString_AS_STRING(rc), n);
buf_putec(&b, &p);
getecptout(p, x);
goto fix;
} else if (PyString_Check(x)) {
- if (PyObject_AsReadBuffer(x, &q, 0))
+ if (PyObject_AsReadBuffer(x, &q, &n))
goto end;
qd.p = q;
qd.e = 0;
if (!EC_FIND(c, p, xx)) VALERR("not on the curve");
} else if (PySequence_Check(x)) {
t = x; x = 0;
- n = PySequence_Size(t);
+ n = PySequence_Size(t); if (n < 0) goto end;
if (n != 2 && (n != 3 || !c))
TYERR("want sequence of two or three items");
if ((x = PySequence_GetItem(t, 0)) == 0 ||
(n == 3 && (z = PySequence_GetItem(t, 2)) == 0))
goto end;
rc = (n == 2) ? ecptxl_2(c, p, x, y) : ecptxl_3(c, p, x, y, z);
+ goto end;
} else
TYERR("can't convert to curve point");
goto ok;
goto end;
return (ecpt_pywrapout(ty, &p));
end:
- EC_DESTROY(&p);
+ mp_drop(p.x); mp_drop(p.y); mp_drop(p.z);
return (0);
}
goto end;
return (ecpt_pywrap((PyObject *)ty, &p));
end:
- EC_DESTROY(&p);
+ mp_drop(p.x); mp_drop(p.y); mp_drop(p.z);
return (0);
}
METH (mmul, "\
E.mmul([(P0, N0), (P1, N1), ...]) = N0 P0 + N1 P1 + ...")
METH (find, "E.find(X) -> P")
- KWMETH(rand, "E.rand(rng = rand) ->P")
+ KWMETH(rand, "E.rand([rng = rand]) -> P")
#undef METHNAME
{ 0 }
};
static PyMethodDef ecinfo_pymethods[] = {
#define METHNAME(name) eimeth_##name
- KWMETH(check, "I.check() -> None")
+ KWMETH(check, "I.check([rng = rand]) -> None")
#undef METHNAME
{ 0 }
};