~mdw
/
catacomb-python
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Reorganization: split out utilities; mapping methods
[catacomb-python]
/
ec.c
diff --git
a/ec.c
b/ec.c
index
8fd32ca
..
685b4bf
100644
(file)
--- a/
ec.c
+++ b/
ec.c
@@
-179,7
+179,7
@@
static void ecpt_pydealloc(PyObject *x)
{
EC_DESTROY(ECPT_P(x));
Py_DECREF(ECPT_COBJ(x));
{
EC_DESTROY(ECPT_P(x));
Py_DECREF(ECPT_COBJ(x));
-
PyObject_DEL
(x);
+
FREEOBJ
(x);
}
static PyObject *ecpt_pymul(PyObject *x, PyObject *y)
}
static PyObject *ecpt_pymul(PyObject *x, PyObject *y)
@@
-472,16
+472,6
@@
static int ecptxl(ec_curve *c, ec *p, PyObject *x, PyObject *y, PyObject *z)
return (ecptxl_1(c, p, x));
}
return (ecptxl_1(c, p, x));
}
-static int ecpt_fromobjects(PyObject *cc, ec *p,
- PyObject *x, PyObject *y, PyObject *z)
-{
- ec_curve *c = 0;
-
- if (cc && PyType_IsSubtype((PyTypeObject *)cc, ecptcurve_pytype))
- c = ECCURVE_C(cc);
- return (ecptxl(c, p, x, y, z));
-}
-
static PyObject *ecptnc_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
{
PyObject *x = 0, *y = 0, *z = 0;
static PyObject *ecptnc_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
{
PyObject *x = 0, *y = 0, *z = 0;
@@
-599,7
+589,7
@@
static PyNumberMethods ecpt_pynumber = {
};
static PyTypeObject ecpt_pytype_skel = {
};
static PyTypeObject ecpt_pytype_skel = {
- PyObject_HEAD_INIT(
&PyType_Type) 0,
/* Header */
+ PyObject_HEAD_INIT(
0) 0,
/* Header */
"catacomb.ECPt", /* @tp_name@ */
sizeof(ecpt_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
"catacomb.ECPt", /* @tp_name@ */
sizeof(ecpt_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
@@
-631,7
+621,7
@@
static PyTypeObject ecpt_pytype_skel = {
ecpt_pyrichcompare, /* @tp_richcompare@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
ecpt_pyrichcompare, /* @tp_richcompare@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
- 0, /* @tp_iternex
r
@ */
+ 0, /* @tp_iternex
t
@ */
ecptnc_pymethods, /* @tp_methods@ */
0, /* @tp_members@ */
ecptnc_pygetset, /* @tp_getset@ */
ecptnc_pymethods, /* @tp_methods@ */
0, /* @tp_members@ */
ecptnc_pygetset, /* @tp_getset@ */
@@
-643,7
+633,7
@@
static PyTypeObject ecpt_pytype_skel = {
0, /* @tp_init@ */
PyType_GenericAlloc, /* @tp_alloc@ */
ecptnc_pynew, /* @tp_new@ */
0, /* @tp_init@ */
PyType_GenericAlloc, /* @tp_alloc@ */
ecptnc_pynew, /* @tp_new@ */
-
_PyObject_Del,
/* @tp_free@ */
+
0,
/* @tp_free@ */
0 /* @tp_is_gc@ */
};
0 /* @tp_is_gc@ */
};
@@
-664,6
+654,7
@@
static PyMethodDef ecpt_pymethods[] = {
#define METHNAME(func) epmeth_##func
METH (toraw, "X.toraw() -> BIN")
METH (dbl, "X.dbl() -> X + X")
#define METHNAME(func) epmeth_##func
METH (toraw, "X.toraw() -> BIN")
METH (dbl, "X.dbl() -> X + X")
+ METH (oncurvep, "X.oncurvep() -> BOOL")
#undef METHNAME
{ 0 }
};
#undef METHNAME
{ 0 }
};
@@
-712,7
+703,7
@@
static PyNumberMethods ecptcurve_pynumber = {
};
static PyTypeObject ecptcurve_pytype_skel = {
};
static PyTypeObject ecptcurve_pytype_skel = {
- PyObject_HEAD_INIT(
&PyType_Type) 0,
/* Header */
+ PyObject_HEAD_INIT(
0) 0,
/* Header */
"catacomb.ECPtCurve", /* @tp_name@ */
sizeof(ecpt_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
"catacomb.ECPtCurve", /* @tp_name@ */
sizeof(ecpt_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
@@
-744,7
+735,7
@@
static PyTypeObject ecptcurve_pytype_skel = {
0, /* @tp_richcompare@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
0, /* @tp_richcompare@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
- 0, /* @tp_iternex
r
@ */
+ 0, /* @tp_iternex
t
@ */
ecpt_pymethods, /* @tp_methods@ */
0, /* @tp_members@ */
ecpt_pygetset, /* @tp_getset@ */
ecpt_pymethods, /* @tp_methods@ */
0, /* @tp_members@ */
ecpt_pygetset, /* @tp_getset@ */
@@
-756,7
+747,7
@@
static PyTypeObject ecptcurve_pytype_skel = {
0, /* @tp_init@ */
PyType_GenericAlloc, /* @tp_alloc@ */
abstract_pynew, /* @tp_new@ */
0, /* @tp_init@ */
PyType_GenericAlloc, /* @tp_alloc@ */
abstract_pynew, /* @tp_new@ */
-
_PyObject_Del,
/* @tp_free@ */
+
0,
/* @tp_free@ */
0 /* @tp_is_gc@ */
};
0 /* @tp_is_gc@ */
};
@@
-909,21
+900,20
@@
static PyObject *ecmeth_rand(PyObject *me, PyObject *arg, PyObject *kw)
static PyObject *eccurve_dopywrap(PyTypeObject *ty,
PyObject *fobj, ec_curve *c)
{
static PyObject *eccurve_dopywrap(PyTypeObject *ty,
PyObject *fobj, ec_curve *c)
{
- eccurve_pyobj *cobj = newtype(ty, 0);
+ eccurve_pyobj *cobj = newtype(ty, 0
, c->ops->name
);
cobj->c = c;
cobj->fobj = fobj;
cobj->c = c;
cobj->fobj = fobj;
- cobj->ty.tp_name = (/*unconst*/ char *)c->ops->name;
- cobj->ty.tp_basicsize = sizeof(ecpt_pyobj);
- cobj->ty.tp_base = ecptcurve_pytype;
+ cobj->ty.type.tp_basicsize = sizeof(ecpt_pyobj);
+ cobj->ty.type.tp_base = ecptcurve_pytype;
Py_INCREF(ecptcurve_pytype);
Py_INCREF(ecptcurve_pytype);
- cobj->ty.tp_flags = (Py_TPFLAGS_DEFAULT |
- Py_TPFLAGS_BASETYPE |
- Py_TPFLAGS_CHECKTYPES |
- Py_TPFLAGS_HEAPTYPE);
- cobj->ty.tp_alloc = PyType_GenericAlloc;
- cobj->ty.t
p_free =_PyObject_Del
;
- cobj->ty.tp_new = ecpt_pynew;
- PyType_Ready(&cobj->ty);
+ cobj->ty.t
ype.t
p_flags = (Py_TPFLAGS_DEFAULT |
+
Py_TPFLAGS_BASETYPE |
+
Py_TPFLAGS_CHECKTYPES |
+
Py_TPFLAGS_HEAPTYPE);
+ cobj->ty.t
ype.t
p_alloc = PyType_GenericAlloc;
+ cobj->ty.t
ype.tp_free = 0
;
+ cobj->ty.t
ype.t
p_new = ecpt_pynew;
+ PyType_Ready(&cobj->ty
.type
);
return ((PyObject *)cobj);
}
return ((PyObject *)cobj);
}
@@
-977,7
+967,7
@@
static PyObject *meth__ECCurve_parse(PyObject *me, PyObject *arg)
ec_curve *c;
PyObject *rc = 0;
ec_curve *c;
PyObject *rc = 0;
- if (!PyArg_ParseTuple(arg, "Os", &me, &p))
+ if (!PyArg_ParseTuple(arg, "Os
:parse
", &me, &p))
goto end;
qd.p = p;
qd.e = 0;
goto end;
qd.p = p;
qd.e = 0;
@@
-1025,7
+1015,7
@@
E.mmul([(P0, N0), (P1, N1), ...]) = N0 P0 + N1 P1 + ...")
};
static PyTypeObject eccurve_pytype_skel = {
};
static PyTypeObject eccurve_pytype_skel = {
- PyObject_HEAD_INIT(
&PyType_Type) 0,
/* Header */
+ PyObject_HEAD_INIT(
0) 0,
/* Header */
"catacomb.ECCurve", /* @tp_name@ */
sizeof(eccurve_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
"catacomb.ECCurve", /* @tp_name@ */
sizeof(eccurve_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
@@
-1056,7
+1046,7
@@
static PyTypeObject eccurve_pytype_skel = {
eccurve_pyrichcompare, /* @tp_richcompare@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
eccurve_pyrichcompare, /* @tp_richcompare@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
- 0, /* @tp_iternex
r
@ */
+ 0, /* @tp_iternex
t
@ */
eccurve_pymethods, /* @tp_methods@ */
0, /* @tp_members@ */
eccurve_pygetset, /* @tp_getset@ */
eccurve_pymethods, /* @tp_methods@ */
0, /* @tp_members@ */
eccurve_pygetset, /* @tp_getset@ */
@@
-1068,7
+1058,7
@@
static PyTypeObject eccurve_pytype_skel = {
0, /* @tp_init@ */
PyType_GenericAlloc, /* @tp_alloc@ */
abstract_pynew, /* @tp_new@ */
0, /* @tp_init@ */
PyType_GenericAlloc, /* @tp_alloc@ */
abstract_pynew, /* @tp_new@ */
-
_PyObject_Del,
/* @tp_free@ */
+
0,
/* @tp_free@ */
0 /* @tp_is_gc@ */
};
0 /* @tp_is_gc@ */
};
@@
-1079,7
+1069,7
@@
static PyObject *ecprimecurve_pynew(PyTypeObject *ty,
}
static PyTypeObject ecprimecurve_pytype_skel = {
}
static PyTypeObject ecprimecurve_pytype_skel = {
- PyObject_HEAD_INIT(
&PyType_Type) 0,
/* Header */
+ PyObject_HEAD_INIT(
0) 0,
/* Header */
"catacomb.ECPrimeCurve", /* @tp_name@ */
sizeof(eccurve_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
"catacomb.ECPrimeCurve", /* @tp_name@ */
sizeof(eccurve_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
@@
-1110,7
+1100,7
@@
static PyTypeObject ecprimecurve_pytype_skel = {
eccurve_pyrichcompare, /* @tp_richcompare@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
eccurve_pyrichcompare, /* @tp_richcompare@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
- 0, /* @tp_iternex
r
@ */
+ 0, /* @tp_iternex
t
@ */
0, /* @tp_methods@ */
0, /* @tp_members@ */
0, /* @tp_getset@ */
0, /* @tp_methods@ */
0, /* @tp_members@ */
0, /* @tp_getset@ */
@@
-1122,7
+1112,7
@@
static PyTypeObject ecprimecurve_pytype_skel = {
0, /* @tp_init@ */
PyType_GenericAlloc, /* @tp_alloc@ */
ecprimecurve_pynew, /* @tp_new@ */
0, /* @tp_init@ */
PyType_GenericAlloc, /* @tp_alloc@ */
ecprimecurve_pynew, /* @tp_new@ */
-
_PyObject_Del,
/* @tp_free@ */
+
0,
/* @tp_free@ */
0 /* @tp_is_gc@ */
};
0 /* @tp_is_gc@ */
};
@@
-1133,7
+1123,7
@@
static PyObject *ecprimeprojcurve_pynew(PyTypeObject *ty,
}
static PyTypeObject ecprimeprojcurve_pytype_skel = {
}
static PyTypeObject ecprimeprojcurve_pytype_skel = {
- PyObject_HEAD_INIT(
&PyType_Type) 0,
/* Header */
+ PyObject_HEAD_INIT(
0) 0,
/* Header */
"catacomb.ECPrimeProjCurve", /* @tp_name@ */
sizeof(eccurve_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
"catacomb.ECPrimeProjCurve", /* @tp_name@ */
sizeof(eccurve_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
@@
-1164,7
+1154,7
@@
static PyTypeObject ecprimeprojcurve_pytype_skel = {
eccurve_pyrichcompare, /* @tp_richcompare@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
eccurve_pyrichcompare, /* @tp_richcompare@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
- 0, /* @tp_iternex
r
@ */
+ 0, /* @tp_iternex
t
@ */
0, /* @tp_methods@ */
0, /* @tp_members@ */
0, /* @tp_getset@ */
0, /* @tp_methods@ */
0, /* @tp_members@ */
0, /* @tp_getset@ */
@@
-1176,7
+1166,7
@@
static PyTypeObject ecprimeprojcurve_pytype_skel = {
0, /* @tp_init@ */
PyType_GenericAlloc, /* @tp_alloc@ */
ecprimeprojcurve_pynew, /* @tp_new@ */
0, /* @tp_init@ */
PyType_GenericAlloc, /* @tp_alloc@ */
ecprimeprojcurve_pynew, /* @tp_new@ */
-
_PyObject_Del,
/* @tp_free@ */
+
0,
/* @tp_free@ */
0 /* @tp_is_gc@ */
};
0 /* @tp_is_gc@ */
};
@@
-1187,7
+1177,7
@@
static PyObject *ecbincurve_pynew(PyTypeObject *ty,
}
static PyTypeObject ecbincurve_pytype_skel = {
}
static PyTypeObject ecbincurve_pytype_skel = {
- PyObject_HEAD_INIT(
&PyType_Type) 0,
/* Header */
+ PyObject_HEAD_INIT(
0) 0,
/* Header */
"catacomb.ECBinCurve", /* @tp_name@ */
sizeof(eccurve_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
"catacomb.ECBinCurve", /* @tp_name@ */
sizeof(eccurve_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
@@
-1218,7
+1208,7
@@
static PyTypeObject ecbincurve_pytype_skel = {
eccurve_pyrichcompare, /* @tp_richcompare@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
eccurve_pyrichcompare, /* @tp_richcompare@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
- 0, /* @tp_iternex
r
@ */
+ 0, /* @tp_iternex
t
@ */
0, /* @tp_methods@ */
0, /* @tp_members@ */
0, /* @tp_getset@ */
0, /* @tp_methods@ */
0, /* @tp_members@ */
0, /* @tp_getset@ */
@@
-1230,7
+1220,7
@@
static PyTypeObject ecbincurve_pytype_skel = {
0, /* @tp_init@ */
PyType_GenericAlloc, /* @tp_alloc@ */
ecbincurve_pynew, /* @tp_new@ */
0, /* @tp_init@ */
PyType_GenericAlloc, /* @tp_alloc@ */
ecbincurve_pynew, /* @tp_new@ */
-
_PyObject_Del,
/* @tp_free@ */
+
0,
/* @tp_free@ */
0 /* @tp_is_gc@ */
};
0 /* @tp_is_gc@ */
};
@@
-1241,7
+1231,7
@@
static PyObject *ecbinprojcurve_pynew(PyTypeObject *ty,
}
static PyTypeObject ecbinprojcurve_pytype_skel = {
}
static PyTypeObject ecbinprojcurve_pytype_skel = {
- PyObject_HEAD_INIT(
&PyType_Type) 0,
/* Header */
+ PyObject_HEAD_INIT(
0) 0,
/* Header */
"catacomb.ECBinProjCurve", /* @tp_name@ */
sizeof(eccurve_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
"catacomb.ECBinProjCurve", /* @tp_name@ */
sizeof(eccurve_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
@@
-1272,7
+1262,7
@@
static PyTypeObject ecbinprojcurve_pytype_skel = {
eccurve_pyrichcompare, /* @tp_richcompare@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
eccurve_pyrichcompare, /* @tp_richcompare@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
- 0, /* @tp_iternex
r
@ */
+ 0, /* @tp_iternex
t
@ */
0, /* @tp_methods@ */
0, /* @tp_members@ */
0, /* @tp_getset@ */
0, /* @tp_methods@ */
0, /* @tp_members@ */
0, /* @tp_getset@ */
@@
-1284,7
+1274,7
@@
static PyTypeObject ecbinprojcurve_pytype_skel = {
0, /* @tp_init@ */
PyType_GenericAlloc, /* @tp_alloc@ */
ecbinprojcurve_pynew, /* @tp_new@ */
0, /* @tp_init@ */
PyType_GenericAlloc, /* @tp_alloc@ */
ecbinprojcurve_pynew, /* @tp_new@ */
-
_PyObject_Del,
/* @tp_free@ */
+
0,
/* @tp_free@ */
0 /* @tp_is_gc@ */
};
0 /* @tp_is_gc@ */
};
@@
-1319,7
+1309,7
@@
static void ecinfo_pydealloc(PyObject *me)
MP_DROP(ei->r);
MP_DROP(ei->h);
Py_DECREF(ECINFO_COBJ(me));
MP_DROP(ei->r);
MP_DROP(ei->h);
Py_DECREF(ECINFO_COBJ(me));
-
PyObject_DEL
(me);
+
FREEOBJ
(me);
}
static PyObject *ecinfo_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
}
static PyObject *ecinfo_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
@@
-1446,7
+1436,7
@@
static PyMethodDef ecinfo_pymethods[] = {
};
static PyTypeObject ecinfo_pytype_skel = {
};
static PyTypeObject ecinfo_pytype_skel = {
- PyObject_HEAD_INIT(
&PyType_Type) 0,
/* Header */
+ PyObject_HEAD_INIT(
0) 0,
/* Header */
"catacomb.ECInfo", /* @tp_name@ */
sizeof(ecinfo_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
"catacomb.ECInfo", /* @tp_name@ */
sizeof(ecinfo_pyobj), /* @tp_basicsize@ */
0, /* @tp_itemsize@ */
@@
-1477,7
+1467,7
@@
static PyTypeObject ecinfo_pytype_skel = {
ecinfo_pyrichcompare, /* @tp_richcompare@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
ecinfo_pyrichcompare, /* @tp_richcompare@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
- 0, /* @tp_iternex
r
@ */
+ 0, /* @tp_iternex
t
@ */
ecinfo_pymethods, /* @tp_methods@ */
0, /* @tp_members@ */
ecinfo_pygetset, /* @tp_getset@ */
ecinfo_pymethods, /* @tp_methods@ */
0, /* @tp_members@ */
ecinfo_pygetset, /* @tp_getset@ */
@@
-1489,7
+1479,7
@@
static PyTypeObject ecinfo_pytype_skel = {
0, /* @tp_init@ */
PyType_GenericAlloc, /* @tp_alloc@ */
ecinfo_pynew, /* @tp_new@ */
0, /* @tp_init@ */
PyType_GenericAlloc, /* @tp_alloc@ */
ecinfo_pynew, /* @tp_new@ */
-
_PyObject_Del,
/* @tp_free@ */
+
0,
/* @tp_free@ */
0 /* @tp_is_gc@ */
};
0 /* @tp_is_gc@ */
};