39
39
#include < nil/marshalling/field_type.hpp>
40
40
#include < nil/marshalling/endianness.hpp>
41
41
42
- #include < nil/crypto3/multiprecision/cpp_int.hpp>
43
- #include < nil/crypto3/multiprecision/number.hpp>
44
-
45
42
#include < nil/crypto3/algebra/random_element.hpp>
46
43
#include < nil/crypto3/algebra/curves/bls12.hpp>
47
- #include < nil/crypto3/algebra/curves/detail/marshalling.hpp>
44
+
45
+ #include < nil/marshalling/algorithms/pack.hpp>
46
+ #include < nil/marshalling/algorithms/unpack.hpp>
48
47
49
48
#include < nil/crypto3/marshalling/algebra/types/curve_element.hpp>
50
49
@@ -55,51 +54,63 @@ void print_byteblob(TIter iter_begin, TIter iter_end) {
55
54
}
56
55
}
57
56
58
- template <typename Endianness, class CurveGroupElement , std::size_t TSize>
59
- void test_curve_element_non_fixed_size_container (std::vector<CurveGroupElement > val_container) {
57
+ template <typename Endianness, class T , std::size_t TSize>
58
+ void test_curve_element_non_fixed_size_container (std::vector<T > val_container) {
60
59
using namespace nil ::crypto3::marshalling;
61
60
std::size_t units_bits = 8 ;
62
61
using unit_type = unsigned char ;
63
- using CurveGroup = typename CurveGroupElement::group_type;
64
62
65
- using curve_element_type = types::curve_element<nil::marshalling::field_type<Endianness>, CurveGroup>;
66
- using curve_type = typename CurveGroup::curve_type;
63
+ nil::marshalling::status_type status;
64
+ std::vector<unit_type> cv =
65
+ nil::marshalling::unpack<Endianness, unit_type>(val_container, status);
67
66
68
- using container_type = nil::marshalling::types::array_list<
69
- nil::marshalling::field_type<Endianness>,
70
- curve_element_type,
71
- nil::marshalling::option::sequence_size_field_prefix<
72
- nil::marshalling::types::integral<nil::marshalling::field_type<Endianness>, std::size_t >>>;
67
+ BOOST_CHECK (status == nil::marshalling::status_type::success);
73
68
74
- std::size_t unitblob_size =
75
- curve_element_type::bit_length () / units_bits + ((curve_element_type::bit_length () % units_bits) ? 1 : 0 );
76
- std::vector<unit_type> cv;
77
- cv.resize (unitblob_size * TSize + sizeof (std::size_t ), 0x00 );
69
+ std::vector<T> test_val = nil::marshalling::pack<Endianness, std::vector<T>>(cv, status);
78
70
79
- std::vector<curve_element_type> container_data;
71
+ BOOST_CHECK (std::equal (val_container.begin (), val_container.end (), test_val.begin ()));
72
+ BOOST_CHECK (status == nil::marshalling::status_type::success);
80
73
81
- for (std::size_t i = 0 ; i < TSize; i++) {
82
- container_data.push_back (curve_element_type (val_container[i]));
83
- }
74
+ // using CurveGroup = typename T::group_type;
75
+
76
+ // using curve_element_type = types::curve_element<nil::marshalling::field_type<Endianness>, CurveGroup>;
77
+ // using curve_type = typename CurveGroup::curve_type;
78
+
79
+ // using container_type = nil::marshalling::types::array_list<
80
+ // nil::marshalling::field_type<Endianness>,
81
+ // curve_element_type,
82
+ // nil::marshalling::option::sequence_size_field_prefix<
83
+ // nil::marshalling::types::integral<nil::marshalling::field_type<Endianness>, std::size_t>>>;
84
+
85
+ // std::size_t unitblob_size =
86
+ // curve_element_type::bit_length() / units_bits + ((curve_element_type::bit_length() % units_bits) ? 1 : 0);
87
+ // std::vector<unit_type> cv;
88
+ // cv.resize(unitblob_size * TSize + sizeof(std::size_t), 0x00);
89
+
90
+ // std::vector<curve_element_type> container_data;
91
+
92
+ // for (std::size_t i = 0; i < TSize; i++) {
93
+ // container_data.push_back(curve_element_type(val_container[i]));
94
+ // }
84
95
85
- container_type test_val = container_type (container_data);
96
+ // container_type test_val = container_type(container_data);
86
97
87
- container_type filled_val = types::fill_curve_element_vector<CurveGroup, Endianness>(val_container);
98
+ // container_type filled_val = types::fill_curve_element_vector<CurveGroup, Endianness>(val_container);
88
99
89
- std::vector<typename CurveGroup::value_type> constructed_val =
90
- types::make_curve_element_vector<CurveGroup, Endianness>(filled_val);
91
- BOOST_CHECK (std::equal (val_container.begin (), val_container.end (), constructed_val.begin ()));
100
+ // std::vector<typename CurveGroup::value_type> constructed_val =
101
+ // types::make_curve_element_vector<CurveGroup, Endianness>(filled_val);
102
+ // BOOST_CHECK(std::equal(val_container.begin(), val_container.end(), constructed_val.begin()));
92
103
93
- auto write_iter = cv.begin ();
104
+ // auto write_iter = cv.begin();
94
105
95
- nil::marshalling::status_type status = test_val.write (write_iter, cv.size ());
106
+ // nil::marshalling::status_type status = test_val.write(write_iter, cv.size());
96
107
97
- container_type test_val_read;
108
+ // container_type test_val_read;
98
109
99
- auto read_iter = cv.begin ();
100
- status = test_val_read.read (read_iter, cv.size ());
110
+ // auto read_iter = cv.begin();
111
+ // status = test_val_read.read(read_iter, cv.size());
101
112
102
- BOOST_CHECK (std::equal (test_val.value ().begin (), test_val.value ().end (), test_val_read.value ().begin ()));
113
+ // BOOST_CHECK(std::equal(test_val.value().begin(), test_val.value().end(), test_val_read.value().begin()));
103
114
}
104
115
105
116
template <typename Endianness, class CurveGroup , std::size_t TSize>
0 commit comments