Add Python binding for loading trusted setup from filename

This commit is contained in:
Ramana Kumar 2022-09-29 20:08:23 +01:00
parent 2628661be5
commit 90eadda3cb
No known key found for this signature in database
GPG Key ID: ED471C788B900433
1 changed files with 15 additions and 0 deletions

View File

@ -55,6 +55,21 @@
#endif #endif
} }
#if defined(SWIGPYTHON)
%typemap(in) FILE* {
if (PyUnicode_Check($input)) {
$1 = fopen(PyUnicode_AsUTF8($input), "r");
if ($1 == NULL) {
PyErr_SetString(PyExc_RuntimeError, "failed to load file");
SWIG_fail;
}
} else {
PyErr_SetString(PyExc_TypeError, "expected bytes (utf-8 encoded file path)");
SWIG_fail;
}
}
#endif
%array_class(scalar_t, scalars) %array_class(scalar_t, scalars)
%array_class(BLSFieldElement, BLSFieldElements) %array_class(BLSFieldElement, BLSFieldElements)
%pointer_class(PolynomialEvalForm, PolynomialEvalFormPtr) %pointer_class(PolynomialEvalForm, PolynomialEvalFormPtr)