X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb-python/blobdiff_plain/d7ab1bab81155baa763449d5afa81e16df98dbe7..183e9cd31b1ac2f14b86c5de6ac2643b8a4364a2:/group.c diff --git a/group.c b/group.c index 9049bba..b3c8b6a 100644 --- a/group.c +++ b/group.c @@ -1,13 +1,11 @@ /* -*-c-*- - * - * $Id$ * * Abstract group inteface * * (c) 2004 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * This file is part of the Python interface to Catacomb. * @@ -15,12 +13,12 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - * + * * Catacomb/Python is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with Catacomb/Python; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. @@ -35,9 +33,7 @@ PyObject *fginfo_pywrap(gprime_param *dp, PyTypeObject *ty) { fginfo_pyobj *z = PyObject_New(fginfo_pyobj, ty); - z->dp.p = MP_COPY(dp->p); - z->dp.q = MP_COPY(dp->q); - z->dp.g = MP_COPY(dp->g); + z->dp = *dp; return ((PyObject *)z); } @@ -51,7 +47,7 @@ static PyObject *fginfo_pynew(PyTypeObject *ty, if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&O&:new", kwlist, convmp, &dp.p, convmp, &dp.q, - &convmp, dp.g)) + convmp, &dp.g)) goto end; z = PyObject_New(fginfo_pyobj, ty); z->dp = dp; @@ -64,29 +60,29 @@ end: } static PyObject *figet_r(PyObject *me, void *hunoz) - { return mp_pywrap(FGINFO_DP(me)->q); } + { return mp_pywrap(MP_COPY(FGINFO_DP(me)->q)); } static PyObject *diget_p(PyObject *me, void *hunoz) - { return mp_pywrap(FGINFO_DP(me)->p); } + { return mp_pywrap(MP_COPY(FGINFO_DP(me)->p)); } static PyObject *diget_g(PyObject *me, void *hunoz) - { return mp_pywrap(FGINFO_DP(me)->g); } + { return mp_pywrap(MP_COPY(FGINFO_DP(me)->g)); } static PyObject *biget_p(PyObject *me, void *hunoz) - { return gf_pywrap(FGINFO_DP(me)->p); } + { return gf_pywrap(MP_COPY(FGINFO_DP(me)->p)); } static PyObject *biget_m(PyObject *me, void *hunoz) { return PyInt_FromLong(mp_octets(FGINFO_DP(me)->p) - 1); } static PyObject *biget_g(PyObject *me, void *hunoz) - { return gf_pywrap(FGINFO_DP(me)->g); } + { return gf_pywrap(MP_COPY(FGINFO_DP(me)->g)); } static void fginfo_pydealloc(PyObject *me) { mp_drop(FGINFO_DP(me)->p); mp_drop(FGINFO_DP(me)->q); mp_drop(FGINFO_DP(me)->g); - _PyObject_Del(me); + FREEOBJ(me); } static PyObject *meth__DHInfo_generate(PyObject *me, @@ -151,6 +147,35 @@ end: return (rc); } +static PyObject *meth__DHInfo_genkcdsa(PyObject *me, + PyObject *arg, PyObject *kw) +{ + dh_param dp; + unsigned ql, pl; + unsigned steps = 0; + grand *r = &rand_global; + pgev evt = { 0 }; + char *kwlist[] = { "class", "pbits", "qbits", + "event", "rng", "nsteps", 0 }; + mp *v = MP_NEW; + PyObject *rc = 0; + + if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&O&|O&O&O&:genkcdsa", kwlist, + &me, convuint, &pl, convuint, &ql, + convpgev, &evt, convgrand, &r, + convuint, &steps)) + goto end; + if (dh_kcdsagen(&dp, ql, pl, 0, steps, r, evt.proc, evt.ctx)) + PGENERR; + mp_div(&v, 0, dp.p, dp.q); + v = mp_lsr(v, v, 1); + rc = Py_BuildValue("(NN)", fginfo_pywrap(&dp, dhinfo_pytype), + mp_pywrap(v)); +end: + droppgev(&evt); + return (rc); +} + static PyObject *meth__DHInfo_gendsa(PyObject *me, PyObject *arg, PyObject *kw) { @@ -159,13 +184,13 @@ static PyObject *meth__DHInfo_gendsa(PyObject *me, unsigned steps = 0; dsa_seed ds; char *k; - int ksz; + Py_ssize_t ksz; pgev evt = { 0 }; char *kwlist[] = { "class", "pbits", "qbits", "seed", "event", "nsteps", 0 }; PyObject *rc = 0; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&O&s#|O&O&:generate", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&O&s#|O&O&:gendsa", kwlist, &me, convuint, &pl, convuint, &ql, &k, &ksz, convpgev, &evt, convuint, &steps)) @@ -200,11 +225,11 @@ static PyObject *namedgroups(const pentry *pp, int *ne) } c = PyInt_FromLong(i); found: - PyDict_SetItemString(d, (/*unconst*/ char *)pp[i].name, c); + PyDict_SetItemString(d, (/*unconst*/ char *)p, c); Py_DECREF(c); } *ne = i; - return (d); + return (d); } static PyObject *meth__groupn(PyObject *me, PyObject *arg, @@ -239,10 +264,10 @@ static PyObject *meth__parse(PyObject *me, PyObject *arg, PyTypeObject *ty, if (!PyArg_ParseTuple(arg, "Os:parse", &me, &p)) goto end; qd.p = p; qd.e = 0; - if (parse(&qd, &gp)) SYNERR(qd.e); + if (parse(&qd, &gp)) VALERR(qd.e); rc = fginfo_pywrap(&gp, ty); end: - return (rc); + return (rc); } static PyObject *meth__DHInfo_parse(PyObject *me, PyObject *arg) @@ -276,8 +301,8 @@ static PyGetSetDef bindhinfo_pygetset[] = { }; static PyTypeObject fginfo_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ - "catacomb.FGInfo", /* @tp_name@ */ + PyObject_HEAD_INIT(0) 0, /* Header */ + "FGInfo", /* @tp_name@ */ sizeof(fginfo_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -300,14 +325,14 @@ static PyTypeObject fginfo_pytype_skel = { Py_TPFLAGS_BASETYPE, /* @tp_doc@ */ - "Abstract base class for field-group information objects.", +"Abstract base class for field-group information objects.", 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ 0, /* @tp_methods@ */ 0, /* @tp_members@ */ fginfo_pygetset, /* @tp_getset@ */ @@ -319,13 +344,13 @@ static PyTypeObject fginfo_pytype_skel = { 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ abstract_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ }; static PyTypeObject dhinfo_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ - "catacomb.DHInfo", /* @tp_name@ */ + PyObject_HEAD_INIT(0) 0, /* Header */ + "DHInfo", /* @tp_name@ */ sizeof(fginfo_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -348,14 +373,14 @@ static PyTypeObject dhinfo_pytype_skel = { Py_TPFLAGS_BASETYPE, /* @tp_doc@ */ - "Standard (integer) Diffie-Hellman group information.", +"DHInfo(P, R, G): standard (integer) Diffie-Hellman group information.", 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ 0, /* @tp_methods@ */ 0, /* @tp_members@ */ dhinfo_pygetset, /* @tp_getset@ */ @@ -367,13 +392,13 @@ static PyTypeObject dhinfo_pytype_skel = { 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ fginfo_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ }; static PyTypeObject bindhinfo_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ - "catacomb.BinDHInfo", /* @tp_name@ */ + PyObject_HEAD_INIT(0) 0, /* Header */ + "BinDHInfo", /* @tp_name@ */ sizeof(fginfo_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -396,14 +421,14 @@ static PyTypeObject bindhinfo_pytype_skel = { Py_TPFLAGS_BASETYPE, /* @tp_doc@ */ - "Binary-field Diffie-Hellman group information.", +"BinDHInfo(P, R, G): binary-field Diffie-Hellman group information.", 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ 0, /* @tp_methods@ */ 0, /* @tp_members@ */ bindhinfo_pygetset, /* @tp_getset@ */ @@ -415,7 +440,7 @@ static PyTypeObject bindhinfo_pytype_skel = { 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ fginfo_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ }; @@ -441,7 +466,7 @@ group *group_copy(group *g) gb.p = gc->r.p; gb.q = gc->g.r; g = group_binary(&gb); - MP_DROP(gb.g); + MP_DROP(gb.g); } else if (strcmp(G_NAME(g), "ec") == 0) { gctx_ec *gc = (gctx_ec *)g; ec_info ei; @@ -492,7 +517,7 @@ static PyObject *ge_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw) sc.buf = PyString_AS_STRING(x); sc.lim = sc.buf + PyString_GET_SIZE(x); if (G_READ(g, xx, &mptext_stringops, &sc) || sc.buf < sc.lim) - SYNERR("malformed group element string"); + VALERR("malformed group element string"); } else TYERR("can't convert to group element"); return (ge_pywrap((PyObject *)ty, xx)); @@ -505,20 +530,19 @@ end: static PyObject *group_dopywrap(PyTypeObject *ty, group *g) { - group_pyobj *gobj = newtype(ty, 0); + group_pyobj *gobj = newtype(ty, 0, g->ops->name); gobj->g = g; - gobj->ty.tp_name = (/*unconst*/ char *)g->ops->name; - gobj->ty.tp_basicsize = sizeof(ge_pyobj); - gobj->ty.tp_base = ge_pytype; + gobj->ty.ht_type.tp_basicsize = sizeof(ge_pyobj); + gobj->ty.ht_type.tp_base = ge_pytype; Py_INCREF(group_pytype); - gobj->ty.tp_flags = (Py_TPFLAGS_DEFAULT | - Py_TPFLAGS_BASETYPE | - Py_TPFLAGS_CHECKTYPES | - Py_TPFLAGS_HEAPTYPE); - gobj->ty.tp_alloc = PyType_GenericAlloc; - gobj->ty.tp_free =_PyObject_Del; - gobj->ty.tp_new = ge_pynew; - PyType_Ready(&gobj->ty); + gobj->ty.ht_type.tp_flags = (Py_TPFLAGS_DEFAULT | + Py_TPFLAGS_BASETYPE | + Py_TPFLAGS_CHECKTYPES | + Py_TPFLAGS_HEAPTYPE); + gobj->ty.ht_type.tp_alloc = PyType_GenericAlloc; + gobj->ty.ht_type.tp_free = 0; + gobj->ty.ht_type.tp_new = ge_pynew; + typeready(&gobj->ty.ht_type); return ((PyObject *)gobj); } @@ -584,7 +608,7 @@ static void ge_pydealloc(PyObject *me) { G_DESTROY(GE_G(me), GE_X(me)); Py_DECREF(GE_GOBJ(me)); - PyObject_DEL(me); + FREEOBJ(me); } static void group_pydealloc(PyObject *me) @@ -657,7 +681,7 @@ static PyObject *ge_pylong(PyObject *me) if ((x = G_TOINT(GE_G(me), MP_NEW, GE_X(me))) == 0) TYERR("can't convert to integer"); - rc = (PyObject *)mp_topylong(x); + rc = mp_topylong(x); end: mp_drop(x); return (rc); @@ -671,8 +695,8 @@ static PyObject *ge_pyint(PyObject *me) if ((x = G_TOINT(GE_G(me), MP_NEW, GE_X(me))) == 0) TYERR("can't convert to integer"); - if (mp_tolong_checked(x, &l)) goto end; - rc = PyInt_FromLong(l); + if (!mp_tolong_checked(x, &l, 0)) rc = PyInt_FromLong(l); + else rc = mp_topylong(x); end: mp_drop(x); return (rc); @@ -693,18 +717,34 @@ end: static PyObject *gemeth_toec(PyObject *me, PyObject *arg, PyObject *kw) { char *kwlist[] = { "curve", 0 }; - PyTypeObject *cty = ecpt_pytype; + PyTypeObject *cty = 0; + PyObject *rc = 0; + group *g; + ec_curve *c; ec p = EC_INIT; if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O:toec", kwlist, &cty)) goto end; - if (!PyType_Check(cty) || !PyType_IsSubtype(cty, ecpt_pytype)) - TYERR("want subtype of catacomb.ECPt"); - if (G_TOEC(GE_G(me), &p, GE_X(me))) + g = GROUP_G(GE_GOBJ(me)); + if (cty) { + if (!PyType_Check(cty) || !PyType_IsSubtype(cty, ecpt_pytype)) + TYERR("want subtype of catacomb.ECPt"); + Py_INCREF((PyObject *)cty); + } else if (strcmp(G_NAME(g), "ec") == 0) { + c = eccurve_copy(((gctx_ec *)g)->ei.c); + cty = (PyTypeObject *)eccurve_pywrap(0, c); + } else { + cty = ecpt_pytype; + Py_INCREF((PyObject *)cty); + } + if (G_TOEC(GE_G(me), &p, GE_X(me))) { + Py_DECREF((PyObject *)cty); TYERR("can't convert to ec point"); - return (ecpt_pywrapout(cty, &p)); + } + rc = ecpt_pywrapout(cty, &p); + Py_DECREF((PyObject *)cty); end: - return (0); + return (rc); } static PyObject *gemeth_tobuf(PyObject *me, PyObject *arg) @@ -758,13 +798,13 @@ static PyObject *gmeth_mexp(PyObject *me, PyObject *arg) gmexp_id, gmexp_fill, gmexp_exp, gmexp_drop)); } -static PyObject *gmeth_check(PyObject *me, PyObject *arg, PyObject *kw) +static PyObject *gmeth_checkgroup(PyObject *me, PyObject *arg, PyObject *kw) { char *kwlist[] = { "rng", 0 }; grand *r = &rand_global; const char *p; - if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:check", kwlist, + if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:checkgroup", kwlist, convgrand, &r)) goto end; if ((p = G_CHECK(GROUP_G(me), r)) != 0) @@ -791,7 +831,7 @@ static PyObject *meth__GE_frombuf(PyObject *me, PyObject *arg) { buf b; char *p; - int n; + Py_ssize_t n; group *g; ge *x = 0; @@ -812,7 +852,7 @@ static PyObject *meth__GE_fromraw(PyObject *me, PyObject *arg) { buf b; char *p; - int n; + Py_ssize_t n; group *g; ge *x = 0; @@ -833,7 +873,7 @@ static PyObject *meth__GE_fromstring(PyObject *me, PyObject *arg) { mptext_stringctx sc; char *p; - int n; + Py_ssize_t n; group *g; ge *x = 0; @@ -844,9 +884,9 @@ static PyObject *meth__GE_fromstring(PyObject *me, PyObject *arg) g = GROUP_G(me); x = G_CREATE(g); if (G_READ(g, x, &mptext_stringops, &sc)) - SYNERR("bad group element string"); + VALERR("bad group element string"); return (Py_BuildValue("(Ns#)", ge_pywrap(me, x), - sc.buf, (int)(sc.lim - sc.buf))); + sc.buf, (Py_ssize_t)(sc.lim - sc.buf))); end: if (x) G_DESTROY(g, x); return (0); @@ -863,7 +903,7 @@ static PyObject *meth__Group_parse(PyObject *me, PyObject *arg) qd.p = p; qd.e = 0; if ((g = group_parse(&qd)) == 0) - SYNERR(qd.e); + VALERR(qd.e); return (group_pywrap(g)); end: return (0); @@ -890,6 +930,20 @@ static PyObject *gget_g(PyObject *me, void *hunoz) G_COPY(g, x, g->g); return (ge_pywrap(me, x)); } +static long ge_pyhash(PyObject *me) +{ + buf b; + size_t sz = GE_G(me)->noctets + 4; + uint32 h = 0xf672c776 + GE_G(me)->ops->ty; + octet *p = xmalloc(sz); + buf_init(&b, p, sz); + G_TOBUF(GE_G(me), &b, GE_X(me)); + assert(BOK(&b)); + h = unihash_hash(&unihash_global, h, BBASE(&b), BLEN(&b)); + xfree(p); + return (h % LONG_MAX); +} + static PyObject *gget_r(PyObject *me, void *hunoz) { return (mp_pywrap(MP_COPY(GROUP_G(me)->r))); } @@ -961,8 +1015,8 @@ static PyNumberMethods ge_pynumber = { }; static PyTypeObject ge_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ - "catacomb.GE", /* @tp_name@ */ + PyObject_HEAD_INIT(0) 0, /* Header */ + "GE", /* @tp_name@ */ sizeof(ge_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -975,7 +1029,7 @@ static PyTypeObject ge_pytype_skel = { &ge_pynumber, /* @tp_as_number@ */ 0, /* @tp_as_sequence@ */ 0, /* @tp_as_mapping@ */ - 0, /* @tp_hash@ */ + ge_pyhash, /* @tp_hash@ */ 0, /* @tp_call@ */ ge_pystr, /* @tp_str@ */ 0, /* @tp_getattro@ */ @@ -993,7 +1047,7 @@ static PyTypeObject ge_pytype_skel = { ge_pyrichcompare, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ ge_pymethods, /* @tp_methods@ */ 0, /* @tp_members@ */ ge_pygetset, /* @tp_getset@ */ @@ -1005,7 +1059,7 @@ static PyTypeObject ge_pytype_skel = { 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ abstract_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ }; @@ -1025,14 +1079,14 @@ static PyMethodDef group_pymethods[] = { #define METHNAME(name) gmeth_##name METH (mexp, "\ G.mexp([(X0, N0), (X1, N1), ...]) -> X0^N0 X1^N1 ...") - KWMETH(check, "G.check(rand = random): check group is good") + KWMETH(checkgroup, "G.checkgroup(rand = random): check group is good") #undef METHNAME { 0 } }; static PyTypeObject group_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ - "catacomb.Group", /* @tp_name@ */ + PyObject_HEAD_INIT(0) 0, /* Header */ + "Group", /* @tp_name@ */ sizeof(group_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -1062,7 +1116,7 @@ static PyTypeObject group_pytype_skel = { group_pyrichcompare, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ group_pymethods, /* @tp_methods@ */ 0, /* @tp_members@ */ group_pygetset, /* @tp_getset@ */ @@ -1074,7 +1128,7 @@ static PyTypeObject group_pytype_skel = { 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ abstract_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ }; @@ -1084,7 +1138,7 @@ static PyObject *pgget_info(PyObject *me, void *hunoz) gctx_prime *gg = (gctx_prime *)GROUP_G(me); dp.p = MP_COPY(gg->mm.m); dp.q = MP_COPY(gg->g.r); - dp.g = mpmont_reduce(&gg->mm, MP_NEW, gg->gen); + dp.g = mpmont_reduce(&gg->mm, MP_NEW, gg->gen.x); return (fginfo_pywrap(&dp, dhinfo_pytype)); } @@ -1108,8 +1162,8 @@ static PyObject *primegroup_pynew(PyTypeObject *ty, } static PyTypeObject primegroup_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ - "catacomb.PrimeGroup", /* @tp_name@ */ + PyObject_HEAD_INIT(0) 0, /* Header */ + "PrimeGroup", /* @tp_name@ */ sizeof(group_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -1132,14 +1186,14 @@ static PyTypeObject primegroup_pytype_skel = { Py_TPFLAGS_BASETYPE, /* @tp_doc@ */ -"Subgroups of prime fields.", +"PrimeGroup(INFO): subgroups of prime fields.", 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ 0, /* @tp_methods@ */ 0, /* @tp_members@ */ primegroup_pygetset, /* @tp_getset@ */ @@ -1151,7 +1205,7 @@ static PyTypeObject primegroup_pytype_skel = { 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ primegroup_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ }; @@ -1161,7 +1215,7 @@ static PyObject *bgget_info(PyObject *me, void *hunoz) gctx_bin *gg = (gctx_bin *)GROUP_G(me); dp.p = MP_COPY(gg->r.p); dp.q = MP_COPY(gg->g.r); - dp.g = MP_COPY(gg->gen); + dp.g = MP_COPY(gg->gen.x); return (fginfo_pywrap(&dp, bindhinfo_pytype)); } @@ -1185,8 +1239,8 @@ static PyObject *bingroup_pynew(PyTypeObject *ty, } static PyTypeObject bingroup_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ - "catacomb.BinGroup", /* @tp_name@ */ + PyObject_HEAD_INIT(0) 0, /* Header */ + "BinGroup", /* @tp_name@ */ sizeof(group_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -1209,14 +1263,14 @@ static PyTypeObject bingroup_pytype_skel = { Py_TPFLAGS_BASETYPE, /* @tp_doc@ */ -"Subgroups of binary fields.", +"BinGroup(INFO): subgroups of binary fields.", 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ 0, /* @tp_methods@ */ 0, /* @tp_members@ */ bingroup_pygetset, /* @tp_getset@ */ @@ -1228,7 +1282,7 @@ static PyTypeObject bingroup_pytype_skel = { 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ bingroup_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ }; @@ -1263,8 +1317,8 @@ static PyObject *ecgroup_pynew(PyTypeObject *ty, } static PyTypeObject ecgroup_pytype_skel = { - PyObject_HEAD_INIT(&PyType_Type) 0, /* Header */ - "catacomb.ECGroup", /* @tp_name@ */ + PyObject_HEAD_INIT(0) 0, /* Header */ + "ECGroup", /* @tp_name@ */ sizeof(group_pyobj), /* @tp_basicsize@ */ 0, /* @tp_itemsize@ */ @@ -1287,14 +1341,14 @@ static PyTypeObject ecgroup_pytype_skel = { Py_TPFLAGS_BASETYPE, /* @tp_doc@ */ -"Elliptic curve groups.", +"ECGroup(INFO): elliptic curve groups.", 0, /* @tp_traverse@ */ 0, /* @tp_clear@ */ 0, /* @tp_richcompare@ */ 0, /* @tp_weaklistoffset@ */ 0, /* @tp_iter@ */ - 0, /* @tp_iternexr@ */ + 0, /* @tp_iternext@ */ 0, /* @tp_methods@ */ 0, /* @tp_members@ */ ecgroup_pygetset, /* @tp_getset@ */ @@ -1306,7 +1360,7 @@ static PyTypeObject ecgroup_pytype_skel = { 0, /* @tp_init@ */ PyType_GenericAlloc, /* @tp_alloc@ */ ecgroup_pynew, /* @tp_new@ */ - _PyObject_Del, /* @tp_free@ */ + 0, /* @tp_free@ */ 0 /* @tp_is_gc@ */ }; @@ -1323,14 +1377,17 @@ static PyMethodDef methods[] = { METH (_DHInfo__groupn, 0) METH (_BinDHInfo__groupn, 0) KWMETH(_DHInfo_generate, "\ -generate(PBITS, [qbits = 0, event = pgen_nullev, - rng = rand, nsteps = 0]) -> D") +generate(PBITS, [qbits = 0, event = pgen_nullev,\n\ + rng = rand, nsteps = 0]) -> D") KWMETH(_DHInfo_genlimlee, "\ genlimlee(PBITS, QBITS, [event = pgen_nullev, ievent = pgen_nullev,\n\ - rng = rand, nsteps = 0, subgroupp = True]) -> (D, [Q, ...])") + rng = rand, nsteps = 0, subgroupp = True]) -> (D, [Q, ...])") KWMETH(_DHInfo_gendsa, "\ gendsa(PBITS, QBITS, SEED, [event = pgen_nullev, nsteps = 0])\n\ -> (D, SEED, COUNT)") + KWMETH(_DHInfo_genkcdsa, "\ +gendsa(PBITS, QBITS, [event = pgen_nullev, rng = rand, nsteps = 0])\n\ + -> (D, V)") #undef METHNAME { 0 } };