/src/cryptofuzz/components.cpp
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | #include <cryptofuzz/crypto.h>  | 
2  |  | #include <cryptofuzz/generic.h>  | 
3  |  | #include <cryptofuzz/components.h>  | 
4  |  | #include <cryptofuzz/util.h>  | 
5  |  | #include <boost/multiprecision/cpp_int.hpp>  | 
6  |  | #include <cryptofuzz/repository.h>  | 
7  |  | #include "third_party/json/json.hpp"  | 
8  |  | #include "config.h"  | 
9  |  |  | 
10  |  | namespace cryptofuzz { | 
11  |  |  | 
12  |  | /* Type */  | 
13  |  |  | 
14  |  | Type::Type(Datasource& ds) :  | 
15  |  |     type ( ds.Get<uint64_t>(0) )  | 
16  | 63.4k  | { } | 
17  |  |  | 
18  |  | Type::Type(const Type& other) :  | 
19  |  |     type(other.type)  | 
20  | 981k  | { } | 
21  |  |  | 
22  |  | Type::Type(nlohmann::json json) :  | 
23  |  |     type(json.get<uint64_t>())  | 
24  | 0  | { } | 
25  |  |  | 
26  | 564k  | uint64_t Type::Get(void) const { | 
27  | 564k  |     return type;  | 
28  | 564k  | }  | 
29  |  |  | 
30  | 86.5k  | bool Type::Is(const uint64_t t) const { | 
31  | 86.5k  |     return type == t;  | 
32  | 86.5k  | }  | 
33  |  |  | 
34  | 0  | bool Type::Is(const std::vector<uint64_t> t) const { | 
35  | 0  |     return std::find(t.begin(), t.end(), type) != t.end();  | 
36  | 0  | }  | 
37  |  |  | 
38  | 0  | nlohmann::json Type::ToJSON(void) const { | 
39  | 0  |     nlohmann::json j;  | 
40  |  |     /* Store as string, not as number, because JavaScript's number  | 
41  |  |      * type has only 53 bits of precision.  | 
42  |  |      */  | 
43  | 0  |     j = std::to_string(type);  | 
44  | 0  |     return j;  | 
45  | 0  | }  | 
46  |  |  | 
47  | 0  | bool Type::operator==(const Type& rhs) const { | 
48  | 0  |     return type == rhs.type;  | 
49  | 0  | }  | 
50  |  |  | 
51  | 0  | void Type::Serialize(Datasource& ds) const { | 
52  | 0  |     ds.Put<>(type);  | 
53  | 0  | }  | 
54  |  |  | 
55  |  | /* Buffer */  | 
56  |  |  | 
57  |  | Buffer::Buffer(Datasource& ds) :  | 
58  |  |     data( ds.GetData(0, 0, (10*1024*1024)) )  | 
59  | 502k  | { } | 
60  |  |  | 
61  | 0  | Buffer::Buffer(nlohmann::json json) { | 
62  | 0  |     const auto s = json.get<std::string>();  | 
63  | 0  |     boost::algorithm::unhex(s, std::back_inserter(data));  | 
64  | 0  | }  | 
65  |  |  | 
66  |  | Buffer::Buffer(const std::vector<uint8_t>& data) :  | 
67  |  |     data(data)  | 
68  | 3.17k  | { } | 
69  |  |  | 
70  |  | Buffer::Buffer(const uint8_t* data, const size_t size) :  | 
71  |  |     data(data, data + size)  | 
72  | 346k  | { } | 
73  |  |  | 
74  | 0  | Buffer::Buffer(void) { } | 
75  |  |  | 
76  | 3.39k  | std::vector<uint8_t> Buffer::Get(void) const { | 
77  | 3.39k  |     return data;  | 
78  | 3.39k  | }  | 
79  |  |  | 
80  | 1.20M  | const uint8_t* Buffer::GetPtr(fuzzing::datasource::Datasource* ds) const { | 
81  | 1.20M  |     if ( data.size() == 0 ) { | 
82  | 359k  |         return util::GetNullPtr(ds);  | 
83  | 845k  |     } else { | 
84  | 845k  |         return data.data();  | 
85  | 845k  |     }  | 
86  | 1.20M  | }  | 
87  |  |  | 
88  | 503k  | std::vector<uint8_t>& Buffer::GetVectorPtr(void) { | 
89  | 503k  |     return data;  | 
90  | 503k  | }  | 
91  |  |  | 
92  | 60.4k  | const std::vector<uint8_t>& Buffer::GetConstVectorPtr(void) const { | 
93  | 60.4k  |     return data;  | 
94  | 60.4k  | }  | 
95  |  |  | 
96  | 2.52M  | size_t Buffer::GetSize(void) const { | 
97  | 2.52M  |     return data.size();  | 
98  | 2.52M  | }  | 
99  |  |  | 
100  | 86.2k  | bool Buffer::operator==(const Buffer& rhs) const { | 
101  | 86.2k  |     return data == rhs.data;  | 
102  | 86.2k  | }  | 
103  |  |  | 
104  | 0  | nlohmann::json Buffer::ToJSON(void) const { | 
105  | 0  |     nlohmann::json j;  | 
106  | 0  |     std::string asHex;  | 
107  | 0  |     boost::algorithm::hex(data, std::back_inserter(asHex));  | 
108  | 0  |     j = asHex;  | 
109  | 0  |     return j;  | 
110  | 0  | }  | 
111  |  |  | 
112  | 4.64k  | std::string Buffer::ToHex(void) const { | 
113  | 4.64k  |     std::string asHex;  | 
114  | 4.64k  |     boost::algorithm::hex(data, std::back_inserter(asHex));  | 
115  | 4.64k  |     return asHex;  | 
116  | 4.64k  | }  | 
117  |  |  | 
118  | 0  | void Buffer::Serialize(Datasource& ds) const { | 
119  | 0  |     ds.PutData(data);  | 
120  | 0  | }  | 
121  |  |  | 
122  | 0  | Datasource Buffer::AsDatasource(void) const { | 
123  | 0  |     return Datasource(data.data(), data.size());  | 
124  | 0  | }  | 
125  |  |  | 
126  | 0  | std::string Buffer::AsString(void) const { | 
127  | 0  |     return std::string(data.data(), data.data() + data.size());  | 
128  | 0  | }  | 
129  |  |  | 
130  | 0  | Buffer Buffer::ECDSA_Pad(const size_t retSize) const { | 
131  | 0  |     size_t bufSize = GetSize();  | 
132  |  | 
  | 
133  | 0  |     if ( bufSize > retSize ) { | 
134  | 0  |         bufSize = retSize;  | 
135  | 0  |     }  | 
136  |  | 
  | 
137  | 0  |     std::vector<uint8_t> ret(retSize);  | 
138  |  | 
  | 
139  | 0  |     if ( retSize != 0 ) { | 
140  | 0  |         const size_t delta = retSize - bufSize;  | 
141  |  | 
  | 
142  | 0  |         if ( delta != 0 ) { | 
143  | 0  |             memset(ret.data(), 0, delta);  | 
144  | 0  |         }  | 
145  |  | 
  | 
146  | 0  |         if ( bufSize != 0 ) { | 
147  | 0  |             memcpy(ret.data() + delta, GetPtr(), bufSize);  | 
148  | 0  |         }  | 
149  | 0  |     }  | 
150  |  | 
  | 
151  | 0  |     return Buffer(ret);  | 
152  | 0  | }  | 
153  |  |  | 
154  |  | /* Randomly modify an ECDSA input in such a way that it remains equivalent  | 
155  |  |  * to ECDSA verify/sign functions  | 
156  |  |  */  | 
157  | 0  | Buffer Buffer::ECDSA_RandomPad(Datasource& ds, const Type& curveType) const { | 
158  | 0  |     const auto numBits = cryptofuzz::repository::ECC_CurveToBits(curveType.Get());  | 
159  | 0  |     if ( numBits == std::nullopt ) { | 
160  |  |         /* The size of this curve is not known, so return the original buffer */  | 
161  | 0  |         return Buffer(data);  | 
162  | 0  |     }  | 
163  |  |  | 
164  | 0  |     if ( *numBits % 8 != 0 ) { | 
165  |  |         /* Curve sizes which are not a byte multiple are currently not supported,  | 
166  |  |          * so return the original buffer  | 
167  |  |          */  | 
168  | 0  |         return Buffer(data);  | 
169  | 0  |     }  | 
170  |  |  | 
171  | 0  |     const size_t numBytes = (*numBits + 7) / 8;  | 
172  |  | 
  | 
173  | 0  |     std::vector<uint8_t> stripped;  | 
174  | 0  |     { | 
175  | 0  |         size_t startPos;  | 
176  | 0  |         const size_t endPos = GetSize() > numBytes ? numBytes : GetSize();  | 
177  |  | 
  | 
178  | 0  |         for (startPos = 0; startPos < endPos; startPos++) { | 
179  | 0  |             if ( data[startPos] != 0 ) { | 
180  | 0  |                 break;  | 
181  | 0  |             }  | 
182  | 0  |         }  | 
183  | 0  |         const auto& ref = GetConstVectorPtr();  | 
184  |  | 
  | 
185  | 0  |         stripped.insert(std::end(stripped), std::begin(ref) + startPos, std::begin(ref) + endPos);  | 
186  | 0  |     }  | 
187  |  |  | 
188  |  |     /* Decide how many bytes to insert */  | 
189  | 0  |     uint16_t numInserts = 0;  | 
190  | 0  |     try { | 
191  | 0  |         numInserts = ds.Get<uint16_t>();  | 
192  | 0  |     } catch ( fuzzing::datasource::Datasource::OutOfData& ) { } | 
193  |  | 
  | 
194  | 0  |     std::vector<uint8_t> ret;  | 
195  |  |  | 
196  |  |     /* Left-pad the input until it is the curve size */  | 
197  | 0  |     { | 
198  | 0  |         if ( stripped.size() < numBytes ) { | 
199  | 0  |             const size_t needed = numBytes - stripped.size();  | 
200  | 0  |             const std::vector<uint8_t> zeroes(numInserts > needed ? needed : numInserts, 0);  | 
201  | 0  |             ret.insert(std::end(ret), std::begin(zeroes), std::end(zeroes));  | 
202  | 0  |             numInserts -= zeroes.size();  | 
203  | 0  |         }  | 
204  | 0  |     }  | 
205  |  |  | 
206  |  |     /* Insert the input */  | 
207  | 0  |     ret.insert(std::end(ret), std::begin(stripped), std::end(stripped));  | 
208  |  |  | 
209  |  |     /* Right-pad the input with random bytes (if available) or zeroes */  | 
210  | 0  |     if ( numInserts > 0 ) { | 
211  | 0  |         std::vector<uint8_t> toInsert;  | 
212  | 0  |         try { | 
213  | 0  |             toInsert = ds.GetData(0, numInserts, numInserts);  | 
214  | 0  |         } catch ( fuzzing::datasource::Datasource::OutOfData& ) { | 
215  | 0  |             toInsert = std::vector<uint8_t>(numInserts, 0);  | 
216  | 0  |         }  | 
217  | 0  |         ret.insert(std::end(ret), std::begin(toInsert), std::end(toInsert));  | 
218  | 0  |     }  | 
219  |  | 
  | 
220  | 0  |     return Buffer(ret);  | 
221  | 0  | }  | 
222  |  |  | 
223  | 0  | Buffer Buffer::SHA256(void) const { | 
224  | 0  |     const auto hash = crypto::sha256(Get());  | 
225  | 0  |     return Buffer(hash);  | 
226  | 0  | }  | 
227  |  |  | 
228  | 0  | bool Buffer::IsZero(void) const { | 
229  | 0  |     for (size_t i = 0; i < data.size(); i++) { | 
230  | 0  |         if ( data[i] != 0 ) { | 
231  | 0  |             return false;  | 
232  | 0  |         }  | 
233  | 0  |     }  | 
234  |  |  | 
235  | 0  |     return true;  | 
236  | 0  | }  | 
237  |  |  | 
238  |  | /* Bignum */  | 
239  |  |  | 
240  |  | Bignum::Bignum(Datasource& ds) :  | 
241  | 491k  |     data(ds) { | 
242  | 491k  |     transform();  | 
243  | 491k  | }  | 
244  |  |  | 
245  |  | Bignum::Bignum(nlohmann::json json) :  | 
246  |  |     Bignum(json.get<std::string>())  | 
247  | 0  | { | 
248  | 0  | }  | 
249  |  |  | 
250  |  | Bignum::Bignum(const std::string s) :  | 
251  |  |     data((const uint8_t*)s.data(), s.size())  | 
252  | 281k  | { } | 
253  |  |  | 
254  | 491k  | void Bignum::transform(void) { | 
255  | 491k  |     auto& ptr = data.GetVectorPtr();  | 
256  |  |  | 
257  | 15.1M  |     for (size_t i = 0; i < ptr.size(); i++) { | 
258  | 14.6M  |         if ( isdigit(ptr[i]) ) continue;  | 
259  | 4.85M  |         if ( config::kNegativeIntegers == true ) { | 
260  | 0  |             if ( i == 0 && ptr[i] == '-') continue;  | 
261  | 0  |         }  | 
262  | 4.85M  |         ptr[i] %= 10;  | 
263  | 4.85M  |         ptr[i] += '0';  | 
264  | 4.85M  |     }  | 
265  | 491k  | }  | 
266  |  |  | 
267  | 73.7k  | bool Bignum::operator==(const Bignum& rhs) const { | 
268  | 73.7k  |     return data == rhs.data;  | 
269  | 73.7k  | }  | 
270  |  |  | 
271  | 1.21M  | size_t Bignum::GetSize(void) const { | 
272  | 1.21M  |     return data.GetSize();  | 
273  | 1.21M  | }  | 
274  |  |  | 
275  | 1.48k  | bool Bignum::IsZero(void) const { | 
276  | 1.48k  |     const auto t = ToTrimmedString();  | 
277  | 1.48k  |     return t == "0" || t == "-" || t == "-0";  | 
278  | 1.48k  | }  | 
279  |  |  | 
280  | 450  | bool Bignum::IsOne(void) const { | 
281  | 450  |     const auto t = ToTrimmedString();  | 
282  | 450  |     return t == "1";  | 
283  | 450  | }  | 
284  |  |  | 
285  | 112k  | bool Bignum::IsNegative(void) const { | 
286  | 112k  |     return data.GetSize() && data.GetConstVectorPtr()[0] == '-';  | 
287  | 112k  | }  | 
288  |  |  | 
289  | 1.47k  | bool Bignum::IsPositive(void) const { | 
290  | 1.47k  |     return !IsZero() && !IsNegative();  | 
291  | 1.47k  | }  | 
292  |  |  | 
293  | 760  | bool Bignum::IsGreaterThan(const std::string& other) const { | 
294  | 760  |     CF_ASSERT(IsNegative() == false, "IsGreaterThan on negative numbers not supported");  | 
295  | 760  |     const auto s = ToTrimmedString();  | 
296  | 760  |     if ( s.size() > other.size() ) { | 
297  | 476  |         return true;  | 
298  | 476  |     } else if ( s.size() < other.size() ) { | 
299  | 133  |         return false;  | 
300  | 151  |     } else { | 
301  | 3.68k  |         for (size_t i = 0; i < s.size(); i++) { | 
302  | 3.68k  |             const int a = s[i];  | 
303  | 3.68k  |             const int b = other[i];  | 
304  | 3.68k  |             if ( a > b ) { | 
305  | 131  |                 return true;  | 
306  | 3.55k  |             } else if ( a < b ) { | 
307  | 17  |                 return false;  | 
308  | 17  |             }  | 
309  | 3.68k  |         }  | 
310  | 151  |     }  | 
311  |  |  | 
312  | 3  |     CF_ASSERT(s == other, "Logic error");  | 
313  | 3  |     return false;  | 
314  | 3  | }  | 
315  |  |  | 
316  | 0  | bool Bignum::IsLessThan(const std::string& other) const { | 
317  | 0  |     boost::multiprecision::cpp_int A(ToTrimmedString());  | 
318  | 0  |     boost::multiprecision::cpp_int B(other);  | 
319  | 0  |     return A < B;  | 
320  | 0  | }  | 
321  |  |  | 
322  | 1.13k  | bool Bignum::IsOdd(void) const { | 
323  | 1.13k  |     const auto s = ToTrimmedString();  | 
324  | 1.13k  |     return ((s.back() - '0') % 2) == 1;  | 
325  | 1.13k  | }  | 
326  |  |  | 
327  | 0  | void Bignum::ToPositive(void) { | 
328  | 0  |     if ( !IsNegative() ) { | 
329  | 0  |         return;  | 
330  | 0  |     }  | 
331  |  |  | 
332  | 0  |     data.GetVectorPtr().erase(data.GetVectorPtr().begin());  | 
333  | 0  | }  | 
334  |  |  | 
335  | 0  | void Bignum::SubFrom(const std::string& v) { | 
336  | 0  |     boost::multiprecision::cpp_int A(ToTrimmedString());  | 
337  | 0  |     boost::multiprecision::cpp_int B(v);  | 
338  | 0  |     boost::multiprecision::cpp_int res = B - A;  | 
339  | 0  |     const auto s = res.str();  | 
340  | 0  |     data = {(const uint8_t*)s.data(), s.size()}; | 
341  | 0  | }  | 
342  |  |  | 
343  | 1.07M  | std::string Bignum::ToString(void) const { | 
344  | 1.07M  |     const auto ptr = data.GetPtr();  | 
345  | 1.07M  |     return std::string(ptr, ptr + data.GetSize());  | 
346  | 1.07M  | }  | 
347  |  |  | 
348  | 1.07M  | std::string Bignum::ToTrimmedString(void) const { | 
349  | 1.07M  |     auto s = ToString();  | 
350  | 1.07M  |     trim_left_if(s, boost::is_any_of("0")); | 
351  |  |  | 
352  | 1.07M  |     if ( s == "" ) { | 
353  | 500k  |         return "0";  | 
354  | 574k  |     } else { | 
355  | 574k  |         return s;  | 
356  | 574k  |     }  | 
357  | 1.07M  | }  | 
358  |  |  | 
359  |  | /* Prefix the string with a pseudo-random amount of zeroes */  | 
360  | 57.6k  | std::string Bignum::ToString(Datasource& ds) const { | 
361  | 57.6k  |     std::string zeros;  | 
362  |  |  | 
363  | 57.6k  |     try { | 
364  | 107k  |         while ( ds.Get<bool>() == true ) { | 
365  | 49.4k  |             zeros += "0";  | 
366  | 49.4k  |         }  | 
367  | 57.6k  |     } catch ( fuzzing::datasource::Datasource::OutOfData& ) { } | 
368  |  |  | 
369  | 57.6k  |     auto s = ToTrimmedString();  | 
370  | 57.6k  |     const bool isNegative = IsNegative();  | 
371  | 57.6k  |     if ( s.size() && s[0] == '-' ) { | 
372  | 0  |         s.erase(0, 1);  | 
373  | 0  |     }  | 
374  | 57.6k  |     return (isNegative ? "-" : "") + zeros + s;  | 
375  | 57.6k  | }  | 
376  |  |  | 
377  | 408  | std::optional<std::vector<uint8_t>> Bignum::ToBin(std::optional<size_t> size) const { | 
378  | 408  |     return util::DecToBin(ToTrimmedString(), size);  | 
379  | 408  | }  | 
380  |  |  | 
381  | 0  | nlohmann::json Bignum::ToJSON(void) const { | 
382  | 0  |     return ToString();  | 
383  | 0  | }  | 
384  |  |  | 
385  | 0  | void Bignum::Serialize(Datasource& ds) const { | 
386  | 0  |     data.Serialize(ds);  | 
387  | 0  | }  | 
388  |  |  | 
389  |  | namespace component { | 
390  |  | /* SymmetricCipher */  | 
391  |  |  | 
392  |  | SymmetricCipher::SymmetricCipher(Datasource& ds) :  | 
393  |  |     iv(ds),  | 
394  |  |     key(ds),  | 
395  |  |     cipherType(ds)  | 
396  | 0  | { } | 
397  |  |  | 
398  |  | SymmetricCipher::SymmetricCipher(nlohmann::json json) :  | 
399  |  |     iv(json["iv"]),  | 
400  |  |     key(json["key"]),  | 
401  |  |     cipherType(json["cipherType"])  | 
402  | 0  | { } | 
403  |  |  | 
404  | 0  | nlohmann::json SymmetricCipher::ToJSON(void) const { | 
405  | 0  |     nlohmann::json j;  | 
406  | 0  |     j["iv"] = iv.ToJSON();  | 
407  | 0  |     j["key"] = key.ToJSON();  | 
408  | 0  |     j["cipherType"] = cipherType.ToJSON();  | 
409  | 0  |     return j;  | 
410  | 0  | }  | 
411  |  |  | 
412  | 0  | bool SymmetricCipher::operator==(const SymmetricCipher& rhs) const { | 
413  | 0  |     return  | 
414  | 0  |         (iv == rhs.iv) &&  | 
415  | 0  |         (key == rhs.key) &&  | 
416  | 0  |         (cipherType == rhs.cipherType);  | 
417  | 0  | }  | 
418  | 0  | void SymmetricCipher::Serialize(Datasource& ds) const { | 
419  | 0  |     iv.Serialize(ds);  | 
420  | 0  |     key.Serialize(ds);  | 
421  | 0  |     cipherType.Serialize(ds);  | 
422  | 0  | }  | 
423  |  |  | 
424  |  | /* Ciphertext */  | 
425  |  |  | 
426  |  | Ciphertext::Ciphertext(Datasource& ds) :  | 
427  |  |     ciphertext(ds),  | 
428  |  |     tag( ds.Get<bool>() ? std::nullopt : std::make_optional<Tag>(ds) )  | 
429  | 0  | { } | 
430  |  |  | 
431  |  | Ciphertext::Ciphertext(Buffer ciphertext, std::optional<Tag> tag) :  | 
432  |  |     ciphertext(ciphertext),  | 
433  |  |     tag(tag)  | 
434  | 0  | { } | 
435  |  |  | 
436  | 0  | bool Ciphertext::operator==(const Ciphertext& rhs) const { | 
437  | 0  |     return (ciphertext == rhs.ciphertext) && (tag == rhs.tag);  | 
438  | 0  | }  | 
439  |  |  | 
440  | 0  | void Ciphertext::Serialize(Datasource& ds) const { | 
441  | 0  |     ciphertext.Serialize(ds);  | 
442  | 0  |     if ( tag == std::nullopt ) { | 
443  | 0  |         ds.Put<bool>(true);  | 
444  | 0  |     } else { | 
445  | 0  |         ds.Put<bool>(false);  | 
446  | 0  |         tag->Serialize(ds);  | 
447  | 0  |     }  | 
448  | 0  | }  | 
449  |  |  | 
450  |  | /* BignumPair */  | 
451  |  |  | 
452  |  | BignumPair::BignumPair(Datasource& ds) :  | 
453  |  |     first(ds),  | 
454  |  |     second(ds)  | 
455  | 139k  | { } | 
456  |  |  | 
457  |  | BignumPair::BignumPair(const std::string first, const std::string second) :  | 
458  |  |     first(first),  | 
459  |  |     second(second)  | 
460  | 50.6k  | { } | 
461  |  |  | 
462  |  | BignumPair::BignumPair(nlohmann::json json) :  | 
463  |  |     first(json[0].get<std::string>()),  | 
464  |  |     second(json[1].get<std::string>())  | 
465  | 0  | { } | 
466  |  |  | 
467  |  |  | 
468  | 23.2k  | bool BignumPair::operator==(const BignumPair& rhs) const { | 
469  | 23.2k  |     return  | 
470  | 23.2k  |         (first == rhs.first) &&  | 
471  | 23.2k  |         (second == rhs.second);  | 
472  | 23.2k  | }  | 
473  |  |  | 
474  | 0  | void BignumPair::Serialize(Datasource& ds) const { | 
475  | 0  |     first.Serialize(ds);  | 
476  | 0  |     second.Serialize(ds);  | 
477  | 0  | }  | 
478  |  |  | 
479  | 0  | nlohmann::json BignumPair::ToJSON(void) const { | 
480  | 0  |     return std::vector<nlohmann::json>{first.ToJSON(), second.ToJSON()}; | 
481  | 0  | }  | 
482  |  |  | 
483  |  | /* ECC_KeyPair */  | 
484  |  |  | 
485  |  | ECC_KeyPair::ECC_KeyPair(Datasource& ds) :  | 
486  |  |     priv(ds),  | 
487  |  |     pub(ds)  | 
488  | 0  | { } | 
489  |  |  | 
490  |  | ECC_KeyPair::ECC_KeyPair(ECC_PrivateKey priv, BignumPair pub) :  | 
491  |  |     priv(priv),  | 
492  |  |     pub(pub)  | 
493  | 0  | { } | 
494  |  |  | 
495  |  | ECC_KeyPair::ECC_KeyPair(nlohmann::json json) :  | 
496  |  |     priv(json["priv"]),  | 
497  |  |     pub(json["pub"])  | 
498  | 0  | { } | 
499  |  |  | 
500  | 0  | bool ECC_KeyPair::operator==(const ECC_KeyPair& rhs) const { | 
501  | 0  |     return  | 
502  | 0  |         (priv == rhs.priv) &&  | 
503  | 0  |         (pub == rhs.pub);  | 
504  | 0  | }  | 
505  |  |  | 
506  | 0  | void ECC_KeyPair::Serialize(Datasource& ds) const { | 
507  | 0  |     priv.Serialize(ds);  | 
508  | 0  |     pub.Serialize(ds);  | 
509  | 0  | }  | 
510  |  |  | 
511  | 0  | nlohmann::json ECC_KeyPair::ToJSON(void) const { | 
512  | 0  |     return std::vector<nlohmann::json>{priv.ToJSON(), pub.ToJSON()}; | 
513  | 0  | }  | 
514  |  |  | 
515  |  | /* ECCSI_Signature */  | 
516  |  | ECCSI_Signature::ECCSI_Signature(Datasource& ds) :  | 
517  |  |     signature(ds),  | 
518  |  |     pub(ds),  | 
519  |  |     pvt(ds)  | 
520  | 0  | { } | 
521  |  |  | 
522  |  | ECCSI_Signature::ECCSI_Signature(BignumPair signature, ECC_PublicKey pub, BignumPair pvt) :  | 
523  |  |     signature(signature),  | 
524  |  |     pub(pub),  | 
525  |  |     pvt(pvt)  | 
526  | 0  | { } | 
527  |  |  | 
528  |  | ECCSI_Signature::ECCSI_Signature(nlohmann::json json) :  | 
529  |  |     signature(json["signature"]),  | 
530  |  |     pub(json["pub"]),  | 
531  |  |     pvt(json["pvt"])  | 
532  | 0  | { } | 
533  |  |  | 
534  | 0  | bool ECCSI_Signature::operator==(const ECCSI_Signature& rhs) const { | 
535  | 0  |     return  | 
536  | 0  |         (signature == rhs.signature) &&  | 
537  | 0  |         (pub == rhs.pub) &&  | 
538  | 0  |         (pvt == rhs.pvt);  | 
539  | 0  | }  | 
540  |  |  | 
541  | 0  | void ECCSI_Signature::Serialize(Datasource& ds) const { | 
542  | 0  |     signature.Serialize(ds);  | 
543  | 0  |     pub.Serialize(ds);  | 
544  | 0  |     pvt.Serialize(ds);  | 
545  | 0  | }  | 
546  |  |  | 
547  | 0  | nlohmann::json ECCSI_Signature::ToJSON(void) const { | 
548  | 0  |     return std::vector<nlohmann::json>{signature.ToJSON(), pub.ToJSON()}; | 
549  | 0  | }  | 
550  |  |  | 
551  |  | /* ECDSA_Signature */  | 
552  |  | ECDSA_Signature::ECDSA_Signature(Datasource& ds) :  | 
553  |  |     signature(ds),  | 
554  |  |     pub(ds)  | 
555  | 0  | { } | 
556  |  |  | 
557  |  | ECDSA_Signature::ECDSA_Signature(BignumPair signature, ECC_PublicKey pub) :  | 
558  |  |     signature(signature),  | 
559  |  |     pub(pub)  | 
560  | 0  | { } | 
561  |  |  | 
562  |  | ECDSA_Signature::ECDSA_Signature(nlohmann::json json) :  | 
563  |  |     signature(json["signature"]),  | 
564  |  |     pub(json["pub"])  | 
565  | 0  | { } | 
566  |  |  | 
567  | 0  | bool ECDSA_Signature::operator==(const ECDSA_Signature& rhs) const { | 
568  | 0  |     return  | 
569  | 0  |         (signature == rhs.signature) &&  | 
570  | 0  |         (pub == rhs.pub);  | 
571  | 0  | }  | 
572  |  |  | 
573  | 0  | void ECDSA_Signature::Serialize(Datasource& ds) const { | 
574  | 0  |     signature.Serialize(ds);  | 
575  | 0  |     pub.Serialize(ds);  | 
576  | 0  | }  | 
577  |  |  | 
578  | 0  | nlohmann::json ECDSA_Signature::ToJSON(void) const { | 
579  | 0  |     return std::vector<nlohmann::json>{signature.ToJSON(), pub.ToJSON()}; | 
580  | 0  | }  | 
581  |  |  | 
582  |  | /* MACType */  | 
583  |  |  | 
584  |  | MACType::MACType(Datasource& ds) :  | 
585  |  |     mode(ds.Get<bool>()),  | 
586  |  |     type(ds)  | 
587  | 0  | { } | 
588  |  |  | 
589  |  | MACType::MACType(nlohmann::json json) :  | 
590  |  |     mode(json["mode"].get<bool>()),  | 
591  |  |     type(json["type"])  | 
592  | 0  | { } | 
593  |  |  | 
594  | 0  | nlohmann::json MACType::ToJSON(void) const { | 
595  | 0  |     nlohmann::json j;  | 
596  | 0  |     j["mode"] = mode;  | 
597  | 0  |     j["type"] = type.ToJSON();  | 
598  | 0  |     return j;  | 
599  | 0  | }  | 
600  |  |  | 
601  | 0  | bool MACType::operator==(const MACType& rhs) const { | 
602  | 0  |     return  | 
603  | 0  |         (mode == rhs.mode) &&  | 
604  | 0  |         (type == rhs.type);  | 
605  | 0  | }  | 
606  |  |  | 
607  | 0  | void MACType::Serialize(Datasource& ds) const { | 
608  | 0  |     ds.Put<>(mode);  | 
609  | 0  |     type.Serialize(ds);  | 
610  | 0  | }  | 
611  |  |  | 
612  |  | G2::G2(nlohmann::json json) :  | 
613  |  |     first(json[0]),  | 
614  | 0  |     second(json[1]) { | 
615  | 0  | }  | 
616  |  |  | 
617  | 0  | nlohmann::json G2::ToJSON(void) const { | 
618  | 0  |     return std::vector<nlohmann::json>{ | 
619  | 0  |         first.first.ToJSON(), first.second.ToJSON(),  | 
620  | 0  |         second.first.ToJSON(), second.second.ToJSON()  | 
621  | 0  |     };  | 
622  | 0  | }  | 
623  |  |  | 
624  | 0  | void G2::Serialize(Datasource& ds) const { | 
625  | 0  |     first.Serialize(ds);  | 
626  | 0  |     second.Serialize(ds);  | 
627  | 0  | }  | 
628  |  |  | 
629  | 0  | nlohmann::json Fp12::ToJSON(void) const { | 
630  | 0  |     return std::vector<nlohmann::json>{ | 
631  | 0  |         bn1.ToJSON(),  | 
632  | 0  |         bn2.ToJSON(),  | 
633  | 0  |         bn3.ToJSON(),  | 
634  | 0  |         bn4.ToJSON(),  | 
635  | 0  |         bn5.ToJSON(),  | 
636  | 0  |         bn6.ToJSON(),  | 
637  | 0  |         bn7.ToJSON(),  | 
638  | 0  |         bn8.ToJSON(),  | 
639  | 0  |         bn9.ToJSON(),  | 
640  | 0  |         bn10.ToJSON(),  | 
641  | 0  |         bn11.ToJSON(),  | 
642  | 0  |         bn12.ToJSON(),  | 
643  | 0  |     };  | 
644  | 0  | }  | 
645  |  |  | 
646  |  | Fp12::Fp12(nlohmann::json json) :  | 
647  |  |     bn1(json[0].get<std::string>()),  | 
648  |  |     bn2(json[1].get<std::string>()),  | 
649  |  |     bn3(json[2].get<std::string>()),  | 
650  |  |     bn4(json[3].get<std::string>()),  | 
651  |  |     bn5(json[4].get<std::string>()),  | 
652  |  |     bn6(json[5].get<std::string>()),  | 
653  |  |     bn7(json[6].get<std::string>()),  | 
654  |  |     bn8(json[7].get<std::string>()),  | 
655  |  |     bn9(json[8].get<std::string>()),  | 
656  |  |     bn10(json[9].get<std::string>()),  | 
657  |  |     bn11(json[10].get<std::string>()),  | 
658  |  |     bn12(json[11].get<std::string>())  | 
659  | 0  | { } | 
660  |  |  | 
661  | 0  | void Fp12::Serialize(Datasource& ds) const { | 
662  | 0  |     bn1.Serialize(ds);  | 
663  | 0  |     bn2.Serialize(ds);  | 
664  | 0  |     bn3.Serialize(ds);  | 
665  | 0  |     bn4.Serialize(ds);  | 
666  | 0  |     bn5.Serialize(ds);  | 
667  | 0  |     bn6.Serialize(ds);  | 
668  | 0  |     bn7.Serialize(ds);  | 
669  | 0  |     bn8.Serialize(ds);  | 
670  | 0  |     bn9.Serialize(ds);  | 
671  | 0  |     bn10.Serialize(ds);  | 
672  | 0  |     bn11.Serialize(ds);  | 
673  | 0  |     bn12.Serialize(ds);  | 
674  | 0  | }  | 
675  |  |  | 
676  | 0  | nlohmann::json DSA_Parameters::ToJSON(void) const { | 
677  | 0  |     return std::vector<nlohmann::json>{ | 
678  | 0  |         p.ToJSON(),  | 
679  | 0  |         q.ToJSON(),  | 
680  | 0  |         g.ToJSON(),  | 
681  | 0  |     };  | 
682  | 0  | }  | 
683  |  |  | 
684  |  | DSA_Parameters::DSA_Parameters(nlohmann::json json) :  | 
685  |  |     p(json["p"].get<std::string>()),  | 
686  |  |     q(json["q"].get<std::string>()),  | 
687  |  |     g(json["g"].get<std::string>())  | 
688  | 0  | { } | 
689  |  |  | 
690  | 0  | void DSA_Parameters::Serialize(Datasource& ds) const { | 
691  | 0  |     p.Serialize(ds);  | 
692  | 0  |     q.Serialize(ds);  | 
693  | 0  |     g.Serialize(ds);  | 
694  | 0  | }  | 
695  |  |  | 
696  |  | /* DSA_Signature */  | 
697  |  | DSA_Signature::DSA_Signature(Datasource& ds) :  | 
698  |  |     signature(ds),  | 
699  |  |     pub(ds)  | 
700  | 0  | { } | 
701  |  |  | 
702  |  | DSA_Signature::DSA_Signature(BignumPair signature, Bignum pub) :  | 
703  |  |     signature(signature),  | 
704  |  |     pub(pub)  | 
705  | 0  | { } | 
706  |  |  | 
707  |  | DSA_Signature::DSA_Signature(nlohmann::json json) :  | 
708  |  |     signature(json["signature"]),  | 
709  |  |     pub(json["pub"])  | 
710  | 0  | { } | 
711  |  |  | 
712  | 0  | bool DSA_Signature::operator==(const DSA_Signature& rhs) const { | 
713  | 0  |     return  | 
714  | 0  |         (signature == rhs.signature) &&  | 
715  | 0  |         (pub == rhs.pub);  | 
716  | 0  | }  | 
717  |  |  | 
718  | 0  | void DSA_Signature::Serialize(Datasource& ds) const { | 
719  | 0  |     signature.Serialize(ds);  | 
720  | 0  |     pub.Serialize(ds);  | 
721  | 0  | }  | 
722  |  |  | 
723  | 0  | nlohmann::json DSA_Signature::ToJSON(void) const { | 
724  | 0  |     return std::vector<nlohmann::json>{signature.ToJSON(), pub.ToJSON()}; | 
725  | 0  | }  | 
726  |  |  | 
727  |  | /* BLS_Signature */  | 
728  |  | BLS_Signature::BLS_Signature(Datasource& ds) :  | 
729  |  |     signature(ds),  | 
730  |  |     pub(ds)  | 
731  | 0  | { } | 
732  |  |  | 
733  |  | BLS_Signature::BLS_Signature(G2 signature, ECC_PublicKey pub) :  | 
734  |  |     signature(signature),  | 
735  |  |     pub(pub)  | 
736  | 1.63k  | { } | 
737  |  |  | 
738  |  | BLS_Signature::BLS_Signature(nlohmann::json json) :  | 
739  |  |     signature(json["signature"]),  | 
740  |  |     pub(json["pub"])  | 
741  | 0  | { } | 
742  |  |  | 
743  | 1.10k  | bool BLS_Signature::operator==(const BLS_Signature& rhs) const { | 
744  | 1.10k  |     return  | 
745  | 1.10k  |         (signature == rhs.signature) &&  | 
746  | 1.10k  |         (pub == rhs.pub);  | 
747  | 1.10k  | }  | 
748  |  |  | 
749  | 0  | void BLS_Signature::Serialize(Datasource& ds) const { | 
750  | 0  |     signature.Serialize(ds);  | 
751  | 0  |     pub.Serialize(ds);  | 
752  | 0  | }  | 
753  |  |  | 
754  | 0  | nlohmann::json BLS_Signature::ToJSON(void) const { | 
755  | 0  |     return std::vector<nlohmann::json>{signature.ToJSON(), pub.ToJSON()}; | 
756  | 0  | }  | 
757  |  |  | 
758  |  | /* BLS_BatchSign_Vector */  | 
759  |  |  | 
760  | 0  | BLS_BatchSign_Vector::BLS_BatchSign_Vector(Datasource& ds) { | 
761  | 0  |     const auto num = ds.Get<uint32_t>(0);  | 
762  | 0  |     for (size_t i = 0; i < num; i++) { | 
763  | 0  |         c.push_back( BatchSign_single{{ds}, {ds}} ); | 
764  | 0  |     }  | 
765  | 0  | }  | 
766  |  |  | 
767  | 0  | BLS_BatchSign_Vector::BLS_BatchSign_Vector(nlohmann::json json) { | 
768  | 0  |     for (const auto& j : json) { | 
769  | 0  |         c.push_back( BatchSign_single{ | 
770  | 0  |                 j["priv"],  | 
771  | 0  |                 {j["g1_x"], j["g1_y"]} }); | 
772  | 0  |     }  | 
773  | 0  | }  | 
774  |  |  | 
775  | 0  | void BLS_BatchSign_Vector::Serialize(Datasource& ds) const { | 
776  | 0  |     ds.Put<uint32_t>(c.size());  | 
777  | 0  |     for (const auto& component : c) { | 
778  | 0  |         component.priv.Serialize(ds);  | 
779  | 0  |         component.g1.Serialize(ds);  | 
780  | 0  |     }  | 
781  | 0  | }  | 
782  |  |  | 
783  |  | /* BLS_BatchSignature */  | 
784  |  |  | 
785  |  | BLS_BatchSignature::BLS_BatchSignature(std::vector< std::pair<G1, G2> > msgpub) :  | 
786  |  |     msgpub(msgpub)  | 
787  | 0  | { } | 
788  |  |  | 
789  | 0  | bool BLS_BatchSignature::operator==(const BLS_BatchSignature& rhs) const { | 
790  | 0  |     return  | 
791  | 0  |         (msgpub == rhs.msgpub);  | 
792  | 0  | }  | 
793  |  |  | 
794  | 0  | void BLS_BatchSignature::Serialize(Datasource& ds) const { | 
795  | 0  |     ds.Put<uint32_t>(msgpub.size());  | 
796  | 0  |     for (const auto& component : msgpub) { | 
797  | 0  |         component.first.Serialize(ds);  | 
798  | 0  |         component.second.Serialize(ds);  | 
799  | 0  |     }  | 
800  | 0  | }  | 
801  |  |  | 
802  | 0  | nlohmann::json BLS_BatchSignature::ToJSON(void) const { | 
803  | 0  |     return {}; /* TODO */ | 
804  | 0  | }  | 
805  |  |  | 
806  |  |  | 
807  |  | /* BLS_KeyPair */  | 
808  |  |  | 
809  |  | BLS_KeyPair::BLS_KeyPair(Datasource& ds) :  | 
810  |  |     priv(ds),  | 
811  |  |     pub(ds)  | 
812  | 0  | { } | 
813  |  |  | 
814  |  | BLS_KeyPair::BLS_KeyPair(BLS_PrivateKey priv, BignumPair pub) :  | 
815  |  |     priv(priv),  | 
816  |  |     pub(pub)  | 
817  | 108  | { } | 
818  |  |  | 
819  | 67  | bool BLS_KeyPair::operator==(const BLS_KeyPair& rhs) const { | 
820  | 67  |     return  | 
821  | 67  |         (priv == rhs.priv) &&  | 
822  | 67  |         (pub == rhs.pub);  | 
823  | 67  | }  | 
824  |  |  | 
825  | 0  | void BLS_KeyPair::Serialize(Datasource& ds) const { | 
826  | 0  |     priv.Serialize(ds);  | 
827  | 0  |     pub.Serialize(ds);  | 
828  | 0  | }  | 
829  |  |  | 
830  | 0  | nlohmann::json BLS_KeyPair::ToJSON(void) const { | 
831  | 0  |     return std::vector<nlohmann::json>{priv.ToJSON(), pub.ToJSON()}; | 
832  | 0  | }  | 
833  |  |  | 
834  |  | /* BLS_BatchVerify_Vector */  | 
835  |  |  | 
836  | 1.24k  | BLS_BatchVerify_Vector::BLS_BatchVerify_Vector(Datasource& ds) { | 
837  | 1.24k  |     const auto num = ds.Get<uint32_t>(0);  | 
838  | 19.3k  |     for (size_t i = 0; i < num; i++) { | 
839  | 18.0k  |         c.push_back( BatchVerify_single{{ds}, {ds}} ); | 
840  | 18.0k  |     }  | 
841  | 1.24k  | }  | 
842  |  |  | 
843  | 0  | BLS_BatchVerify_Vector::BLS_BatchVerify_Vector(nlohmann::json json) { | 
844  | 0  |     for (const auto& j : json) { | 
845  | 0  |         c.push_back( BatchVerify_single{ | 
846  | 0  |                 {j["g1_x"], j["g1_y"]}, | 
847  | 0  |                 {j["g2_v"], j["g2_w"], j["g2_x"], j["g2_y"]} }); | 
848  | 0  |     }  | 
849  | 0  | }  | 
850  |  |  | 
851  | 0  | void BLS_BatchVerify_Vector::Serialize(Datasource& ds) const { | 
852  | 0  |     ds.Put<uint32_t>(c.size());  | 
853  | 0  |     for (const auto& component : c) { | 
854  | 0  |         component.g1.Serialize(ds);  | 
855  | 0  |         component.g2.Serialize(ds);  | 
856  | 0  |     }  | 
857  | 0  | }  | 
858  |  |  | 
859  | 0  | nlohmann::json BLS_BatchVerify_Vector::ToJSON(void) const { | 
860  | 0  |     nlohmann::json j = nlohmann::json::array();  | 
861  | 0  |     for (const auto& cur : c) { | 
862  | 0  |         nlohmann::json curj;  | 
863  | 0  |         curj["g1_x"] = cur.g1.first.ToJSON();  | 
864  | 0  |         curj["g1_y"] = cur.g1.second.ToJSON();  | 
865  |  | 
  | 
866  | 0  |         curj["g2_v"] = cur.g2.first.first.ToJSON();  | 
867  | 0  |         curj["g2_w"] = cur.g2.first.second.ToJSON();  | 
868  | 0  |         curj["g2_x"] = cur.g2.second.first.ToJSON();  | 
869  | 0  |         curj["g2_y"] = cur.g2.second.second.ToJSON();  | 
870  |  | 
  | 
871  | 0  |         j.push_back(curj);  | 
872  | 0  |     }  | 
873  | 0  |     return j;  | 
874  | 0  | }  | 
875  |  |  | 
876  |  | /* BLS_G1_Vector */  | 
877  |  |  | 
878  | 475  | BLS_G1_Vector::BLS_G1_Vector(Datasource& ds) { | 
879  | 475  |     const auto num = ds.Get<uint32_t>(0);  | 
880  | 5.36k  |     for (size_t i = 0; i < num; i++) { | 
881  | 4.89k  |         points.push_back( component::G1(ds) );  | 
882  | 4.89k  |     }  | 
883  | 475  | }  | 
884  |  |  | 
885  | 0  | BLS_G1_Vector::BLS_G1_Vector(nlohmann::json json) { | 
886  | 0  |     for (const auto& j : json) { | 
887  | 0  |         points.push_back( component::G1{j["x"], j["y"]} ); | 
888  | 0  |     }  | 
889  | 0  | }  | 
890  |  |  | 
891  | 0  | void BLS_G1_Vector::Serialize(Datasource& ds) const { | 
892  | 0  |     ds.Put<uint32_t>(points.size());  | 
893  | 0  |     for (const auto& signature : points) { | 
894  | 0  |         signature.Serialize(ds);  | 
895  | 0  |     }  | 
896  | 0  | }  | 
897  |  |  | 
898  |  | /* BLS_G1_Scalar_Vector */  | 
899  |  |  | 
900  | 0  | BLS_G1_Scalar_Vector::BLS_G1_Scalar_Vector(Datasource& ds) { | 
901  | 0  |     const auto num = ds.Get<uint32_t>(0);  | 
902  | 0  |     for (size_t i = 0; i < num; i++) { | 
903  | 0  |         points_scalars.push_back({ | 
904  | 0  |                 component::G1(ds),  | 
905  | 0  |                 component::Bignum(ds),  | 
906  | 0  |         });  | 
907  | 0  |     }  | 
908  | 0  | }  | 
909  |  |  | 
910  | 0  | BLS_G1_Scalar_Vector::BLS_G1_Scalar_Vector(nlohmann::json json) { | 
911  | 0  |     for (const auto& j : json) { | 
912  | 0  |         points_scalars.push_back({ | 
913  | 0  |                 component::G1{j["x"], j["y"]}, | 
914  | 0  |                 component::Bignum{j["scalar"]}, | 
915  | 0  |         });  | 
916  | 0  |     }  | 
917  | 0  | }  | 
918  |  |  | 
919  | 0  | void BLS_G1_Scalar_Vector::Serialize(Datasource& ds) const { | 
920  | 0  |     ds.Put<uint32_t>(points_scalars.size());  | 
921  | 0  |     for (const auto& point_scalar : points_scalars) { | 
922  | 0  |         point_scalar.first.Serialize(ds);  | 
923  | 0  |         point_scalar.second.Serialize(ds);  | 
924  | 0  |     }  | 
925  | 0  | }  | 
926  |  |  | 
927  |  | /* BLS_G2_Vector */  | 
928  |  |  | 
929  | 517  | BLS_G2_Vector::BLS_G2_Vector(Datasource& ds) { | 
930  | 517  |     const auto num = ds.Get<uint32_t>(0);  | 
931  | 8.08k  |     for (size_t i = 0; i < num; i++) { | 
932  | 7.56k  |         points.push_back( component::G2(ds) );  | 
933  | 7.56k  |     }  | 
934  | 517  | }  | 
935  |  |  | 
936  | 0  | BLS_G2_Vector::BLS_G2_Vector(nlohmann::json json) { | 
937  | 0  |     for (const auto& j : json) { | 
938  | 0  |         points.push_back( component::G2{j["v"], j["w"], j["x"], j["y"]} ); | 
939  | 0  |     }  | 
940  | 0  | }  | 
941  |  |  | 
942  | 0  | void BLS_G2_Vector::Serialize(Datasource& ds) const { | 
943  | 0  |     ds.Put<uint32_t>(points.size());  | 
944  | 0  |     for (const auto& signature : points) { | 
945  | 0  |         signature.Serialize(ds);  | 
946  | 0  |     }  | 
947  | 0  | }  | 
948  |  |  | 
949  |  | /* SR25519_Signature */  | 
950  |  | SR25519_Signature::SR25519_Signature(Datasource& ds) :  | 
951  |  |     signature(ds),  | 
952  |  |     pub(ds)  | 
953  | 0  | { } | 
954  |  |  | 
955  |  | SR25519_Signature::SR25519_Signature(BignumPair signature, Bignum pub) :  | 
956  |  |     signature(signature),  | 
957  |  |     pub(pub)  | 
958  | 0  | { } | 
959  |  |  | 
960  |  | SR25519_Signature::SR25519_Signature(nlohmann::json json) :  | 
961  |  |     signature(json["signature"]),  | 
962  |  |     pub(json["pub"])  | 
963  | 0  | { } | 
964  |  |  | 
965  | 0  | bool SR25519_Signature::operator==(const SR25519_Signature& rhs) const { | 
966  | 0  |     return  | 
967  | 0  |         (signature == rhs.signature) &&  | 
968  | 0  |         (pub == rhs.pub);  | 
969  | 0  | }  | 
970  |  |  | 
971  | 0  | void SR25519_Signature::Serialize(Datasource& ds) const { | 
972  | 0  |     signature.Serialize(ds);  | 
973  | 0  |     pub.Serialize(ds);  | 
974  | 0  | }  | 
975  |  |  | 
976  | 0  | nlohmann::json SR25519_Signature::ToJSON(void) const { | 
977  | 0  |     return std::vector<nlohmann::json>{signature.ToJSON(), pub.ToJSON()}; | 
978  | 0  | }  | 
979  |  |  | 
980  |  | } /* namespace component */  | 
981  |  |  | 
982  |  | } /* namespace cryptofuzz */  |