@@ -29,13 +29,13 @@ using std::vector;
29
29
30
30
/* This class releases the Python GIL until the end of the scope.
31
31
This is different from gil_scoped_release in that it can't be reacquired early. */
32
- class PythonGIL {
33
- public:
34
- PythonGIL () { _save = PyEval_SaveThread (); }
35
- ~PythonGIL () { PyEval_RestoreThread (_save); }
36
- private:
37
- PyThreadState *_save;
38
- };
32
+ // class PythonGIL {
33
+ // public:
34
+ // PythonGIL() { _save = PyEval_SaveThread(); }
35
+ // ~PythonGIL() { PyEval_RestoreThread(_save); }
36
+ // private:
37
+ // PyThreadState *_save;
38
+ // };
39
39
40
40
PYBIND11_MODULE (blspy, m)
41
41
{
@@ -56,13 +56,13 @@ PYBIND11_MODULE(blspy, m)
56
56
" Length of bytes object not equal to PrivateKey::SIZE" );
57
57
}
58
58
auto data_ptr = reinterpret_cast <const uint8_t *>(info.ptr );
59
- PythonGIL release_lock;
59
+ // PythonGIL release_lock;
60
60
return PrivateKey::FromBytes (Bytes (data_ptr, PrivateKey::PRIVATE_KEY_SIZE));
61
61
})
62
62
.def (
63
63
" __bytes__" ,
64
64
[](const PrivateKey &k) {
65
- PythonGIL release_lock;
65
+ // PythonGIL release_lock;
66
66
uint8_t *output =
67
67
Util::SecAlloc<uint8_t >(PrivateKey::PRIVATE_KEY_SIZE);
68
68
k.Serialize (output);
@@ -77,7 +77,10 @@ PYBIND11_MODULE(blspy, m)
77
77
[](const PrivateKey &k, const py::object &memo) {
78
78
return PrivateKey (k);
79
79
})
80
- .def (" get_g1" , [](const PrivateKey &k) { PythonGIL release_lock; return k.GetG1Element (); })
80
+ .def (" get_g1" , [](const PrivateKey &k) {
81
+ // PythonGIL release_lock;
82
+ return k.GetG1Element ();
83
+ })
81
84
.def (" aggregate" , &PrivateKey::Aggregate)
82
85
.def (py::self == py::self)
83
86
.def (py::self != py::self)
@@ -137,7 +140,7 @@ PYBIND11_MODULE(blspy, m)
137
140
const py::bytes &msg,
138
141
const G2Element &sig) {
139
142
std::string s (msg);
140
- PythonGIL release_lock;
143
+ // PythonGIL release_lock;
141
144
vector<uint8_t > v (s.begin (), s.end ());
142
145
return BasicSchemeMPL ().Verify (pk, v, sig);
143
146
})
@@ -151,7 +154,7 @@ PYBIND11_MODULE(blspy, m)
151
154
std::string s (msgs[i]);
152
155
vecs[i] = vector<uint8_t >(s.begin (), s.end ());
153
156
}
154
- PythonGIL release_lock;
157
+ // PythonGIL release_lock;
155
158
return BasicSchemeMPL ().AggregateVerify (pks, vecs, sig);
156
159
})
157
160
.def (
@@ -178,7 +181,7 @@ PYBIND11_MODULE(blspy, m)
178
181
return AugSchemeMPL ().KeyGen (inputVec);
179
182
})
180
183
.def (" derive_child_sk" , [](const PrivateKey& sk, uint32_t index ){
181
- PythonGIL release_lock;
184
+ // PythonGIL release_lock;
182
185
return AugSchemeMPL ().DeriveChildSk (sk, index );
183
186
})
184
187
.def (" derive_child_sk_unhardened" , [](const PrivateKey& sk, uint32_t index ){
@@ -212,7 +215,7 @@ PYBIND11_MODULE(blspy, m)
212
215
const py::bytes &msg,
213
216
const G2Element &sig) {
214
217
std::string s (msg);
215
- PythonGIL release_lock;
218
+ // PythonGIL release_lock;
216
219
vector<uint8_t > v (s.begin (), s.end ());
217
220
return AugSchemeMPL ().Verify (pk, v, sig);
218
221
})
@@ -226,7 +229,7 @@ PYBIND11_MODULE(blspy, m)
226
229
std::string s (msgs[i]);
227
230
vecs[i] = vector<uint8_t >(s.begin (), s.end ());
228
231
}
229
- PythonGIL release_lock;
232
+ // PythonGIL release_lock;
230
233
return AugSchemeMPL ().AggregateVerify (pks, vecs, sig);
231
234
})
232
235
.def (
@@ -277,7 +280,7 @@ PYBIND11_MODULE(blspy, m)
277
280
const py::bytes &msg,
278
281
const G2Element &sig) {
279
282
std::string s (msg);
280
- PythonGIL release_lock;
283
+ // PythonGIL release_lock;
281
284
vector<uint8_t > v (s.begin (), s.end ());
282
285
return PopSchemeMPL ().Verify (pk, v, sig);
283
286
})
@@ -291,7 +294,7 @@ PYBIND11_MODULE(blspy, m)
291
294
std::string s (msgs[i]);
292
295
vecs[i] = vector<uint8_t >(s.begin (), s.end ());
293
296
}
294
- PythonGIL release_lock;
297
+ // PythonGIL release_lock;
295
298
return PopSchemeMPL ().AggregateVerify (pks, vecs, sig);
296
299
})
297
300
.def (
@@ -309,7 +312,7 @@ PYBIND11_MODULE(blspy, m)
309
312
return PopSchemeMPL ().PopProve (privateKey);
310
313
})
311
314
.def (" pop_verify" , [](const G1Element& pubkey, const G2Element& signature){
312
- PythonGIL release_lock;
315
+ // PythonGIL release_lock;
313
316
return PopSchemeMPL ().PopVerify (pubkey, signature);
314
317
})
315
318
.def (
@@ -318,7 +321,7 @@ PYBIND11_MODULE(blspy, m)
318
321
const py::bytes &msg,
319
322
const G2Element &sig) {
320
323
std::string s (msg);
321
- PythonGIL release_lock;
324
+ // PythonGIL release_lock;
322
325
vector<uint8_t > v (s.begin (), s.end ());
323
326
return PopSchemeMPL ().FastAggregateVerify (pks, v, sig);
324
327
});
@@ -367,7 +370,7 @@ PYBIND11_MODULE(blspy, m)
367
370
" Length of bytes object not equal to G1Element::SIZE" );
368
371
}
369
372
auto data_ptr = reinterpret_cast <const uint8_t *>(info.ptr );
370
- PythonGIL release_lock;
373
+ // PythonGIL release_lock;
371
374
return G1Element::FromBytes (Bytes (data_ptr, G1Element::SIZE));
372
375
})
373
376
.def (" generator" , &G1Element::Generator)
@@ -385,7 +388,10 @@ PYBIND11_MODULE(blspy, m)
385
388
})
386
389
.def (
387
390
" __add__" ,
388
- [](G1Element &self, G1Element &other) { PythonGIL release_lock; return self + other; },
391
+ [](G1Element &self, G1Element &other) {
392
+ // PythonGIL release_lock;
393
+ return self + other;
394
+ },
389
395
py::is_operator ())
390
396
.def (
391
397
" __mul__" ,
@@ -421,9 +427,9 @@ PYBIND11_MODULE(blspy, m)
421
427
" __bytes__" ,
422
428
[](const G1Element &ele) {
423
429
vector<uint8_t > out;
424
- Py_BEGIN_ALLOW_THREADS
430
+ // Py_BEGIN_ALLOW_THREADS
425
431
out = ele.Serialize ();
426
- Py_END_ALLOW_THREADS
432
+ // Py_END_ALLOW_THREADS
427
433
py::bytes ans = py::bytes (
428
434
reinterpret_cast <const char *>(out.data ()), G1Element::SIZE);
429
435
return ans;
0 commit comments