Skip to content

Commit 0dfd8b6

Browse files
authored
Revert "python-bindings: Add pickle support for G1Element (dashpay#265)" (dashpay#278)
This reverts commit 616230c.
1 parent 45cca81 commit 0dfd8b6

File tree

2 files changed

+0
-24
lines changed

2 files changed

+0
-24
lines changed

python-bindings/pythonbindings.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -373,16 +373,6 @@ PYBIND11_MODULE(blspy, m)
373373
// PythonGIL release_lock;
374374
return G1Element::FromBytes(Bytes(data_ptr, G1Element::SIZE));
375375
})
376-
.def(py::pickle(
377-
[](const G1Element &dp) { // __getstate__
378-
return py::make_tuple(dp.Serialize());
379-
},
380-
[](py::tuple t) { // __setstate__
381-
if (t.size() != 1)
382-
throw std::runtime_error("Invalid state!");
383-
auto vecBytes = t[0].cast<std::vector<uint8_t>>();
384-
return G1Element::FromByteVector(vecBytes);
385-
}))
386376
.def("generator", &G1Element::Generator)
387377
.def("from_message", py::overload_cast<const std::vector<uint8_t>&, const uint8_t*, int>(&G1Element::FromMessage))
388378
.def("pair", &G1Element::Pair)

python-bindings/test.py

-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# flake8: noqa: E501
22
import binascii
3-
import pickle
43
from copy import deepcopy
54

65
from blspy import (
@@ -336,24 +335,11 @@ def test_aggregate_verify_zero_items():
336335
assert AugSchemeMPL.aggregate_verify([], [], G2Element())
337336

338337

339-
def test_pickle_support():
340-
seed = bytes([
341-
0, 50, 6, 244, 24, 199, 1, 25, 52, 88, 192, 19, 18, 12, 89, 6,
342-
220, 18, 102, 58, 209, 82, 12, 62, 89, 110, 182, 9, 44, 20, 254, 22
343-
])
344-
key: PrivateKey = AugSchemeMPL.key_gen(seed)
345-
g1: G1Element = key.get_g1()
346-
g1_data = pickle.dumps(g1)
347-
g1_restored = pickle.loads(g1_data)
348-
assert g1 == g1_restored
349-
350-
351338
test_schemes()
352339
test_vectors_invalid()
353340
test_vectors_valid()
354341
test_readme()
355342
test_aggregate_verify_zero_items()
356-
test_pickle_support()
357343

358344
print("\nAll tests passed.")
359345

0 commit comments

Comments
 (0)