+static PyObject *epmeth_frombuf(PyObject *me, PyObject *arg)
+{
+ struct bin in;
+ buf b;
+ PyObject *rc = 0;
+ ec pp = EC_INIT;
+
+ if (!PyArg_ParseTuple(arg, "O&:frombuf", convbin, &in)) goto end;
+ buf_init(&b, (/*unconst*/ void *)in.p, in.sz);
+ if (buf_getec(&b, &pp)) VALERR("malformed data");
+ rc = Py_BuildValue("(NN)", ecpt_pywrapout(me, &pp),
+ bytestring_pywrapbuf(&b));
+end:
+ return (rc);
+}
+
+static PyObject *epmeth_parse(PyObject *me, PyObject *arg)
+{
+ char *p;
+ qd_parse qd;
+ PyObject *rc = 0;
+ ec pp = EC_INIT;
+
+ if (!PyArg_ParseTuple(arg, "s:parse", &p)) goto end;
+ qd.p = p; qd.e = 0;
+ if (!ec_ptparse(&qd, &pp)) VALERR(qd.e);
+ rc = Py_BuildValue("(Ns)", ecpt_pywrapout(me, &pp), qd.p);
+end:
+ return (rc);
+}
+
+static PyObject *epmeth_fromraw(PyObject *me, PyObject *arg)
+{
+ struct bin in;
+ buf b;
+ PyObject *rc = 0;
+ ec_curve *cc;
+ ec pp = EC_INIT;
+
+ if (!PyArg_ParseTuple(arg, "O&:fromraw", convbin, &in)) return (0);
+ buf_init(&b, (/*unconst*/ void *)in.p, in.sz);
+ cc = ECCURVE_C(me);
+ if (ec_getraw(cc, &b, &pp))
+ VALERR("bad point");
+ EC_IN(cc, &pp, &pp);
+ rc = Py_BuildValue("(NN)", ecpt_pywrap(me, &pp), bytestring_pywrapbuf(&b));
+end:
+ return (rc);
+}
+
+static PyObject *epmeth_os2ecp(PyObject *me, PyObject *arg, PyObject *kw)
+{
+ struct bin in;
+ buf b;
+ PyObject *rc = 0;
+ ec_curve *cc;
+ unsigned f = EC_XONLY | EC_LSB | EC_SORT | EC_EXPLY;
+ ec pp = EC_INIT;
+ static const char *const kwlist[] = { "buf", "flags", 0 };
+
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O&:os2ecp", KWLIST,
+ convbin, &in, convuint, &f))
+ return (0);
+ buf_init(&b, (/*unconst*/ void *)in.p, in.sz);
+ cc = ECCURVE_C(me);
+ if (ec_os2ecp(cc, f, &b, &pp)) VALERR("bad point");
+ EC_IN(cc, &pp, &pp);
+ rc = Py_BuildValue("(NN)", ecpt_pywrap(me, &pp), bytestring_pywrapbuf(&b));
+end:
+ return (rc);
+}