Skip to content

Commit

Permalink
adds comment and fixes whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
wbendick committed Apr 7, 2021
1 parent 051caa3 commit 1d83c1e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions python-bindings/pythonbindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ namespace py = pybind11;
using namespace bls;
using std::vector;


/* This class releases the Python GIL until the end of the scope.
This is different from gil_scoped_release in that it can't be reacquired early. */
class PythonGIL {
public:
PythonGIL() { _save = PyEval_SaveThread(); }
Expand Down Expand Up @@ -53,13 +56,13 @@ PYBIND11_MODULE(blspy, m)
"Length of bytes object not equal to PrivateKey::SIZE");
}
auto data_ptr = reinterpret_cast<const uint8_t *>(info.ptr);
PythonGIL release_lock;
PythonGIL release_lock;
return PrivateKey::FromBytes(Bytes(data_ptr, PrivateKey::PRIVATE_KEY_SIZE));
})
.def(
"__bytes__",
[](const PrivateKey &k) {
PythonGIL release_lock;
PythonGIL release_lock;
uint8_t *output =
Util::SecAlloc<uint8_t>(PrivateKey::PRIVATE_KEY_SIZE);
k.Serialize(output);
Expand Down Expand Up @@ -163,7 +166,7 @@ PYBIND11_MODULE(blspy, m)
return AugSchemeMPL().KeyGen(inputVec);
})
.def("derive_child_sk", [](const PrivateKey& sk, uint32_t index){
PythonGIL release_lock;
PythonGIL release_lock;
return AugSchemeMPL().DeriveChildSk(sk, index);
})
.def("derive_child_sk_unhardened", [](const PrivateKey& sk, uint32_t index){
Expand Down Expand Up @@ -326,7 +329,7 @@ PYBIND11_MODULE(blspy, m)
"Length of bytes object not equal to G1Element::SIZE");
}
auto data_ptr = reinterpret_cast<const uint8_t *>(info.ptr);
PythonGIL release_lock;
PythonGIL release_lock;
return G1Element::FromBytes(Bytes(data_ptr, G1Element::SIZE));
})
.def("generator", &G1Element::Generator)
Expand Down Expand Up @@ -374,7 +377,7 @@ PYBIND11_MODULE(blspy, m)
.def(
"__bytes__",
[](const G1Element &ele) {
PythonGIL release_lock;
PythonGIL release_lock;
vector<uint8_t> out = ele.Serialize();
py::bytes ans = py::bytes(
reinterpret_cast<const char *>(out.data()), G1Element::SIZE);
Expand Down

0 comments on commit 1d83c1e

Please sign in to comment.