static PyObject *gfsget_size(PyObject *me, void *hunoz)
{ return (PyInt_FromLong(GFSHARE_S(me)->sz)); }
-static PyGetSetDef gfshare_pygetset[]= {
+static const PyGetSetDef gfshare_pygetset[]= {
#define GETSETNAME(op, name) gfs##op##_##name
GET (threshold, "S.threshold -> THRESHOLD")
GET (size, "S.size -> SECRETSZ")
Py_TPFLAGS_BASETYPE,
/* @tp_doc@ */
-"Binary-field secret sharing base class.",
+ "Binary-field secret sharing base class.",
0, /* @tp_traverse@ */
0, /* @tp_clear@ */
0, /* @tp_iternext@ */
0, /* @tp_methods@ */
0, /* @tp_members@ */
- gfshare_pygetset, /* @tp_getset@ */
+ PYGETSET(gfshare), /* @tp_getset@ */
0, /* @tp_base@ */
0, /* @tp_dict@ */
0, /* @tp_descr_get@ */
PyObject *arg, PyObject *kw)
{
char *p;
- int n;
+ Py_ssize_t n;
unsigned t;
grand *r = &rand_global;
gfshare_pyobj *s;
- char *kwlist[] = { "threshold", "secret", "rng", 0 };
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&s#|O&:new", kwlist,
+ static const char *const kwlist[] = { "threshold", "secret", "rng", 0 };
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&s#|O&:new", KWLIST,
convuint, &t, &p, &n, convgrand, &r))
goto end;
if (!t || t > 255) VALERR("threshold must be nonzero and < 256");
return (rc);
}
-static PyMethodDef gfsharesplit_pymethods[] = {
+static const PyMethodDef gfsharesplit_pymethods[] = {
#define METHNAME(name) gfsmeth_##name
METH (get, "S.get(I) -> SHARE")
#undef METHNAME
Py_TPFLAGS_BASETYPE,
/* @tp_doc@ */
-"Binary field secret sharing: split secret into shares.",
+ "GFShareSplit(THRESHOLD, SECRET, [rng = rand]): binary-field sharing:\n"
+ " split secret into shares.",
0, /* @tp_traverse@ */
0, /* @tp_clear@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
0, /* @tp_iternext@ */
- gfsharesplit_pymethods, /* @tp_methods@ */
+ PYMETHODS(gfsharesplit), /* @tp_methods@ */
0, /* @tp_members@ */
0, /* @tp_getset@ */
0, /* @tp_base@ */
{
unsigned t, sz;
gfshare_pyobj *s;
- char *kwlist[] = { "threshold", "size", 0 };
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", kwlist,
+ static const char *const kwlist[] = { "threshold", "size", 0 };
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", KWLIST,
convuint, &t, convuint, &sz))
goto end;
if (!t || t > 255) VALERR("threshold must be nonzero and < 256");
{
unsigned i;
char *p;
- int n;
+ Py_ssize_t n;
if (!PyArg_ParseTuple(arg, "O&s#:add", convuint, &i, &p, &n)) goto end;
if (i > 254) VALERR("index must be < 255");
if (n != GFSHARE_S(me)->sz) VALERR("bad share size");
return (0);
}
-static PyObject *gfsmeth_combine(PyObject *me, PyObject *arg)
+static PyObject *gfsmeth_combine(PyObject *me)
{
PyObject *rc = 0;
- if (!PyArg_ParseTuple(arg, ":combine")) goto end;
if (GFSHARE_S(me)->i < GFSHARE_S(me)->t) VALERR("not enough shares yet");
rc = bytestring_pywrap(0, GFSHARE_S(me)->sz);
gfshare_combine(GFSHARE_S(me), PyString_AS_STRING(rc));
return (rc);
}
-static PyMethodDef gfsharejoin_pymethods[] = {
+static const PyMethodDef gfsharejoin_pymethods[] = {
#define METHNAME(name) gfsmeth_##name
METH (addedp, "S.addedp(I) -> BOOL")
METH (add, "S.add(I, SHARE) -> REMAIN")
- METH (combine, "S.combine() -> SECRET")
+ NAMETH(combine, "S.combine() -> SECRET")
#undef METHNAME
{ 0 }
};
static PyObject *gfsget_remain(PyObject *me, void *hunoz)
{ return (PyInt_FromLong(GFSHARE_S(me)->t - GFSHARE_S(me)->i)); }
-static PyGetSetDef gfsharejoin_pygetset[]= {
+static const PyGetSetDef gfsharejoin_pygetset[]= {
#define GETSETNAME(op, name) gfs##op##_##name
GET (remain, "S.remain -> REMAIN")
#undef GETSETNAME
Py_TPFLAGS_BASETYPE,
/* @tp_doc@ */
-"Binary field secret sharing: join shares to recover secret.",
+ "GFShareJoin(THRESHOLD, SIZE): binary field sharing:\n"
+ " join shares to recover secret.",
0, /* @tp_traverse@ */
0, /* @tp_clear@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
0, /* @tp_iternext@ */
- gfsharejoin_pymethods, /* @tp_methods@ */
+ PYMETHODS(gfsharejoin), /* @tp_methods@ */
0, /* @tp_members@ */
- gfsharejoin_pygetset, /* @tp_getset@ */
+ PYGETSET(gfsharejoin), /* @tp_getset@ */
0, /* @tp_base@ */
0, /* @tp_dict@ */
0, /* @tp_descr_get@ */
static PyObject *sget_modulus(PyObject *me, void *hunoz)
{ return (mp_pywrap(SHARE_S(me)->p)); }
-static PyGetSetDef share_pygetset[]= {
+static const PyGetSetDef share_pygetset[]= {
#define GETSETNAME(op, name) s##op##_##name
GET (threshold, "S.threshold -> THRESHOLD")
GET (modulus, "S.modulus -> MODULUS")
Py_TPFLAGS_BASETYPE,
/* @tp_doc@ */
-"Prime-field secret sharing base class.",
+ "Prime-field secret sharing base class.",
0, /* @tp_traverse@ */
0, /* @tp_clear@ */
0, /* @tp_iternext@ */
0, /* @tp_methods@ */
0, /* @tp_members@ */
- share_pygetset, /* @tp_getset@ */
+ PYGETSET(share), /* @tp_getset@ */
0, /* @tp_base@ */
0, /* @tp_dict@ */
0, /* @tp_descr_get@ */
grand *r = &rand_global;
mp *m = 0;
share_pyobj *s;
- char *kwlist[] = { "threshold", "secret", "modulus", "rng", 0 };
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&|O&O&:new", kwlist,
+ static const char *const kwlist[] =
+ { "threshold", "secret", "modulus", "rng", 0 };
+
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&|O&O&:new", KWLIST,
convuint, &t, convmp, &sec,
convmp, &m, convgrand, &r))
goto end;
return (rc);
}
-static PyMethodDef sharesplit_pymethods[] = {
+static const PyMethodDef sharesplit_pymethods[] = {
#define METHNAME(name) smeth_##name
METH (get, "S.get(I) -> SHARE")
#undef METHNAME
Py_TPFLAGS_BASETYPE,
/* @tp_doc@ */
-"Prime field secret sharing: split secret into shares.",
+ "ShareSplit(THRESHOLD, SECRET, [modulus = ?], [rng = rand]):\n"
+ " prime field secret sharing: split secret into shares.",
0, /* @tp_traverse@ */
0, /* @tp_clear@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
0, /* @tp_iternext@ */
- sharesplit_pymethods, /* @tp_methods@ */
+ PYMETHODS(sharesplit), /* @tp_methods@ */
0, /* @tp_members@ */
0, /* @tp_getset@ */
0, /* @tp_base@ */
unsigned t;
mp *m = 0;
share_pyobj *s;
- char *kwlist[] = { "threshold", "modulus", 0 };
- if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", kwlist,
+ static const char *const kwlist[] = { "threshold", "modulus", 0 };
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", KWLIST,
convuint, &t, convmp, &m))
goto end;
if (!t) VALERR("threshold must be nonzero");
return (rc);
}
-static PyObject *smeth_combine(PyObject *me, PyObject *arg)
+static PyObject *smeth_combine(PyObject *me)
{
PyObject *rc = 0;
- if (!PyArg_ParseTuple(arg, ":combine")) goto end;
if (SHARE_S(me)->i < SHARE_S(me)->t) VALERR("not enough shares yet");
rc = mp_pywrap(share_combine(SHARE_S(me)));
end:
return (rc);
}
-static PyMethodDef sharejoin_pymethods[] = {
+static const PyMethodDef sharejoin_pymethods[] = {
#define METHNAME(name) smeth_##name
METH (addedp, "S.addedp(I) -> BOOL")
METH (add, "S.add(I, SHARE) -> REMAIN")
- METH (combine, "S.combine() -> SECRET")
+ NAMETH(combine, "S.combine() -> SECRET")
#undef METHNAME
{ 0 }
};
static PyObject *sget_remain(PyObject *me, void *hunoz)
{ return (PyInt_FromLong(SHARE_S(me)->t - SHARE_S(me)->i)); }
-static PyGetSetDef sharejoin_pygetset[]= {
+static const PyGetSetDef sharejoin_pygetset[]= {
#define GETSETNAME(op, name) s##op##_##name
GET (remain, "S.remain -> REMAIN")
#undef GETSETNAME
Py_TPFLAGS_BASETYPE,
/* @tp_doc@ */
-"Prime field secret sharing: join shares to recover secret.",
+ "ShareJoin(THRESHOLD, MODULUS): prime field secret sharing:\n"
+ " join shares to recover secret.",
0, /* @tp_traverse@ */
0, /* @tp_clear@ */
0, /* @tp_weaklistoffset@ */
0, /* @tp_iter@ */
0, /* @tp_iternext@ */
- sharejoin_pymethods, /* @tp_methods@ */
+ PYMETHODS(sharejoin), /* @tp_methods@ */
0, /* @tp_members@ */
- sharejoin_pygetset, /* @tp_getset@ */
+ PYGETSET(sharejoin), /* @tp_getset@ */
0, /* @tp_base@ */
0, /* @tp_dict@ */
0, /* @tp_descr_get@ */