Coverage Report

Created: 2023-09-25 06:34

/src/cryptofuzz/include/cryptofuzz/operations.h
Line
Count
Source (jump to first uncovered line)
1
#pragma once
2
3
#include <cryptofuzz/components.h>
4
#include <cryptofuzz/repository.h>
5
#include <fuzzing/datasource/datasource.hpp>
6
#include "../../third_party/json/json.hpp"
7
8
namespace cryptofuzz {
9
namespace operation {
10
11
using fuzzing::datasource::Datasource;
12
13
class Operation {
14
    public:
15
        component::Modifier modifier;
16
17
        Operation(component::Modifier modifier) :
18
            modifier(std::move(modifier))
19
261k
        { }
20
21
        Operation(nlohmann::json modifier) :
22
            modifier(modifier)
23
0
        { }
24
25
        virtual std::string Name(void) const = 0;
26
        virtual std::string ToString(void) const = 0;
27
        virtual nlohmann::json ToJSON(void) const = 0;
28
0
        virtual std::string GetAlgorithmString(void) const {
29
0
            return "(no algorithm)";
30
0
        }
31
};
32
33
class Digest : public Operation {
34
    public:
35
        const component::Cleartext cleartext;
36
        const component::DigestType digestType;
37
38
        Digest(Datasource& ds, component::Modifier modifier) :
39
            Operation(std::move(modifier)),
40
            cleartext(ds),
41
            digestType(ds)
42
5.32k
        { }
43
44
        Digest(nlohmann::json json) :
45
            Operation(json["modifier"]),
46
            cleartext(json["cleartext"]),
47
            digestType(json["digestType"])
48
0
        { }
49
50
51
3.91k
        static size_t MaxOperations(void) { return 20; }
52
        std::string Name(void) const override;
53
        std::string ToString(void) const override;
54
        nlohmann::json ToJSON(void) const override;
55
0
        std::string GetAlgorithmString(void) const override {
56
0
            return repository::DigestToString(digestType.Get());
57
0
        }
58
0
        inline bool operator==(const Digest& rhs) const {
59
0
            return
60
0
                (cleartext == rhs.cleartext) &&
61
0
                (digestType == rhs.digestType) &&
62
0
                (modifier == rhs.modifier);
63
0
        }
64
0
        void Serialize(Datasource& ds) const {
65
0
            cleartext.Serialize(ds);
66
0
            digestType.Serialize(ds);
67
0
        }
68
};
69
70
class HMAC : public Operation {
71
    public:
72
        const component::Cleartext cleartext;
73
        const component::DigestType digestType;
74
        const component::SymmetricCipher cipher;
75
76
        HMAC(Datasource& ds, component::Modifier modifier) :
77
            Operation(std::move(modifier)),
78
            cleartext(ds),
79
            digestType(ds),
80
            cipher(ds)
81
4.32k
        { }
82
        HMAC(nlohmann::json json) :
83
            Operation(json["modifier"]),
84
            cleartext(json["cleartext"]),
85
            digestType(json["digestType"]),
86
            cipher(json["cipher"])
87
0
        { }
88
89
2.51k
        static size_t MaxOperations(void) { return 20; }
90
        std::string Name(void) const override;
91
        std::string ToString(void) const override;
92
        nlohmann::json ToJSON(void) const override;
93
0
        std::string GetAlgorithmString(void) const override {
94
0
            return repository::DigestToString(digestType.Get());
95
0
        }
96
0
        inline bool operator==(const HMAC& rhs) const {
97
0
            return
98
0
                (cleartext == rhs.cleartext) &&
99
0
                (digestType == rhs.digestType) &&
100
0
                (cipher == rhs.cipher) &&
101
0
                (modifier == rhs.modifier);
102
0
        }
103
0
        void Serialize(Datasource& ds) const {
104
0
            cleartext.Serialize(ds);
105
0
            digestType.Serialize(ds);
106
0
            cipher.Serialize(ds);
107
0
        }
108
};
109
110
class UMAC : public Operation {
111
    public:
112
        const component::Cleartext cleartext;
113
        const component::Cleartext key;
114
        const component::Cleartext iv;
115
        uint8_t type;
116
        const uint64_t outSize;
117
118
        UMAC(Datasource& ds, component::Modifier modifier) :
119
            Operation(std::move(modifier)),
120
            cleartext(ds),
121
            key(ds),
122
            iv(ds),
123
            type(ds.Get<uint64_t>() % 4),
124
            outSize(ds.Get<uint64_t>() % 1024)
125
4.66k
        { }
126
        UMAC(nlohmann::json json) :
127
            Operation(json["modifier"]),
128
            cleartext(json["cleartext"]),
129
            key(json["key"]),
130
            iv(json["iv"]),
131
            type(json["type"].get<uint64_t>()),
132
            outSize(json["outSize"].get<uint64_t>())
133
0
        { }
134
135
2.96k
        static size_t MaxOperations(void) { return 20; }
136
        std::string Name(void) const override;
137
        std::string ToString(void) const override;
138
        nlohmann::json ToJSON(void) const override;
139
0
        inline bool operator==(const UMAC& rhs) const {
140
0
            return
141
0
                (cleartext == rhs.cleartext) &&
142
0
                (key == rhs.key) &&
143
0
                (iv == rhs.iv) &&
144
0
                (type == rhs.type) &&
145
0
                (outSize == rhs.outSize) &&
146
0
                (modifier == rhs.modifier);
147
0
        }
148
0
        void Serialize(Datasource& ds) const {
149
0
            cleartext.Serialize(ds);
150
0
            key.Serialize(ds);
151
0
            iv.Serialize(ds);
152
0
            ds.Put<>(type);
153
0
            ds.Put<>(outSize);
154
0
        }
155
};
156
157
class SymmetricEncrypt : public Operation {
158
    public:
159
        const component::Cleartext cleartext;
160
        const component::SymmetricCipher cipher;
161
        const std::optional<component::AAD> aad;
162
163
        const uint64_t ciphertextSize;
164
        const std::optional<uint64_t> tagSize;
165
166
        SymmetricEncrypt(Datasource& ds, component::Modifier modifier) :
167
            Operation(std::move(modifier)),
168
            cleartext(ds),
169
            cipher(ds),
170
            aad(ds.Get<bool>() ? std::nullopt : std::make_optional<component::AAD>(ds)),
171
            ciphertextSize(ds.Get<uint64_t>() % (10*1024*1024)),
172
            tagSize( ds.Get<bool>() ?
173
                    std::nullopt :
174
                    std::make_optional<uint64_t>(ds.Get<uint64_t>() % (10*1024*1024)) )
175
18.5k
        { }
176
        SymmetricEncrypt(nlohmann::json json) :
177
            Operation(json["modifier"]),
178
            cleartext(json["cleartext"]),
179
            cipher(json["cipher"]),
180
            aad(
181
                    json["aad_enabled"].get<bool>() ?
182
                        std::optional<component::AAD>(json["aad"]) :
183
                        std::optional<component::AAD>(std::nullopt)
184
            ),
185
            ciphertextSize(json["ciphertextSize"].get<uint64_t>()),
186
            tagSize(
187
                    json["tagSize_enabled"].get<bool>() ?
188
                        std::optional<uint64_t>(json["tagSize"].get<uint64_t>()) :
189
                        std::optional<uint64_t>(std::nullopt)
190
            )
191
0
        { }
192
193
15.3k
        static size_t MaxOperations(void) { return 20; }
194
        std::string Name(void) const override;
195
        std::string ToString(void) const override;
196
        nlohmann::json ToJSON(void) const override;
197
0
        std::string GetAlgorithmString(void) const override {
198
0
            return repository::CipherToString(cipher.cipherType.Get());
199
0
        }
200
0
        inline bool operator==(const SymmetricEncrypt& rhs) const {
201
0
            return
202
0
                (cleartext == rhs.cleartext) &&
203
0
                (cipher == rhs.cipher) &&
204
0
                (aad == rhs.aad) &&
205
0
                (ciphertextSize == rhs.ciphertextSize) &&
206
0
                (tagSize == rhs.tagSize) &&
207
0
                (modifier == rhs.modifier);
208
0
        }
209
0
        void Serialize(Datasource& ds) const {
210
0
            cleartext.Serialize(ds);
211
0
            cipher.Serialize(ds);
212
0
            if ( aad == std::nullopt ) {
213
0
                ds.Put<bool>(true);
214
0
            } else {
215
0
                ds.Put<bool>(false);
216
0
                aad->Serialize(ds);
217
0
            }
218
0
            ds.Put<>(ciphertextSize);
219
0
            if ( tagSize == std::nullopt ) {
220
0
                ds.Put<bool>(true);
221
0
            } else {
222
0
                ds.Put<bool>(false);
223
0
                ds.Put<>(*tagSize);
224
0
            }
225
0
        }
226
};
227
228
class SymmetricDecrypt : public Operation {
229
    public:
230
        const Buffer ciphertext;
231
        const component::SymmetricCipher cipher;
232
        const std::optional<component::Tag> tag;
233
        const std::optional<component::AAD> aad;
234
235
        const uint64_t cleartextSize;
236
237
        SymmetricDecrypt(Datasource& ds, component::Modifier modifier) :
238
            Operation(std::move(modifier)),
239
            ciphertext(ds),
240
            cipher(ds),
241
            tag(ds.Get<bool>() ? std::nullopt : std::make_optional<component::Tag>(ds)),
242
            aad(ds.Get<bool>() ? std::nullopt : std::make_optional<component::AAD>(ds)),
243
            cleartextSize(ds.Get<uint64_t>() % (10*1024*1024))
244
11.3k
        { }
245
        SymmetricDecrypt(const SymmetricEncrypt& opSymmetricEncrypt, const component::Ciphertext ciphertext, const uint64_t cleartextSize, std::optional<component::AAD> aad, component::Modifier modifier);
246
        SymmetricDecrypt(nlohmann::json json) :
247
            Operation(json["modifier"]),
248
            ciphertext(json["ciphertext"]),
249
            cipher(json["cipher"]),
250
            tag(
251
                    json["tag_enabled"].get<bool>() ?
252
                        std::optional<component::Tag>(json["tag"]) :
253
                        std::optional<component::Tag>(std::nullopt)
254
            ),
255
            aad(
256
                    json["aad_enabled"].get<bool>() ?
257
                        std::optional<component::AAD>(json["aad"]) :
258
                        std::optional<component::AAD>(std::nullopt)
259
            ),
260
            cleartextSize(json["cleartextSize"].get<uint64_t>())
261
0
        { }
262
263
9.18k
        static size_t MaxOperations(void) { return 20; }
264
        std::string Name(void) const override;
265
        std::string ToString(void) const override;
266
        nlohmann::json ToJSON(void) const override;
267
0
        std::string GetAlgorithmString(void) const override {
268
0
            return repository::CipherToString(cipher.cipherType.Get());
269
0
        }
270
0
        inline bool operator==(const SymmetricDecrypt& rhs) const {
271
0
            return
272
0
                (ciphertext == rhs.ciphertext) &&
273
0
                (cipher == rhs.cipher) &&
274
0
                (tag == rhs.tag) &&
275
0
                (aad == rhs.aad) &&
276
0
                (cleartextSize == rhs.cleartextSize) &&
277
0
                (modifier == rhs.modifier);
278
0
        }
279
0
        void Serialize(Datasource& ds) const {
280
0
            ciphertext.Serialize(ds);
281
0
            cipher.Serialize(ds);
282
0
            if ( tag == std::nullopt ) {
283
0
                ds.Put<bool>(true);
284
0
            } else {
285
0
                ds.Put<bool>(false);
286
0
                tag->Serialize(ds);
287
0
            }
288
0
            if ( aad == std::nullopt ) {
289
0
                ds.Put<bool>(true);
290
0
            } else {
291
0
                ds.Put<bool>(false);
292
0
                aad->Serialize(ds);
293
0
            }
294
0
            ds.Put<>(cleartextSize);
295
0
        }
296
};
297
298
class KDF_SCRYPT : public Operation {
299
    public:
300
        const component::Cleartext password;
301
        const component::Cleartext salt;
302
        const uint64_t N;
303
        const uint64_t r;
304
        const uint64_t p;
305
306
        const uint64_t keySize;
307
308
        KDF_SCRYPT(Datasource& ds, component::Modifier modifier) :
309
            Operation(std::move(modifier)),
310
            password(ds),
311
            salt(ds),
312
            N(ds.Get<uint64_t>() % 5),
313
            r(ds.Get<uint64_t>() % 9),
314
            p(ds.Get<uint64_t>() % 5),
315
            keySize(ds.Get<uint64_t>() % 1024)
316
2.69k
        { }
317
        KDF_SCRYPT(nlohmann::json json) :
318
            Operation(json["modifier"]),
319
            password(json["password"]),
320
            salt(json["salt"]),
321
            N(json["N"].get<uint64_t>()),
322
            r(json["r"].get<uint64_t>()),
323
            p(json["p"].get<uint64_t>()),
324
            keySize(json["keySize"].get<uint64_t>())
325
0
        { }
326
327
986
        static size_t MaxOperations(void) { return 20; }
328
        std::string Name(void) const override;
329
        std::string ToString(void) const override;
330
        nlohmann::json ToJSON(void) const override;
331
0
        inline bool operator==(const KDF_SCRYPT& rhs) const {
332
0
            return
333
0
                (password == rhs.password) &&
334
0
                (salt == rhs.salt) &&
335
0
                (N == rhs.N) &&
336
0
                (r == rhs.r) &&
337
0
                (p == rhs.p) &&
338
0
                (keySize == rhs.keySize) &&
339
0
                (modifier == rhs.modifier);
340
0
        }
341
0
        void Serialize(Datasource& ds) const {
342
0
            password.Serialize(ds);
343
0
            salt.Serialize(ds);
344
0
            ds.Put<>(N);
345
0
            ds.Put<>(r);
346
0
            ds.Put<>(p);
347
0
            ds.Put<>(keySize);
348
0
        }
349
};
350
351
class KDF_HKDF : public Operation {
352
    public:
353
        const component::DigestType digestType;
354
        const component::Cleartext password;
355
        const component::Cleartext salt;
356
        const component::Cleartext info;
357
358
        const uint64_t keySize;
359
360
        KDF_HKDF(Datasource& ds, component::Modifier modifier) :
361
            Operation(std::move(modifier)),
362
            digestType(ds),
363
            password(ds),
364
            salt(ds),
365
            info(ds),
366
            keySize(ds.Get<uint64_t>() % 17000)
367
6.29k
        { }
368
        KDF_HKDF(nlohmann::json json) :
369
            Operation(json["modifier"]),
370
            digestType(json["digestType"]),
371
            password(json["password"]),
372
            salt(json["salt"]),
373
            info(json["info"]),
374
            keySize(json["keySize"].get<uint64_t>())
375
0
        { }
376
377
3.80k
        static size_t MaxOperations(void) { return 20; }
378
        std::string Name(void) const override;
379
        std::string ToString(void) const override;
380
        nlohmann::json ToJSON(void) const override;
381
0
        inline bool operator==(const KDF_HKDF& rhs) const {
382
0
            return
383
0
                (digestType == rhs.digestType) &&
384
0
                (password == rhs.password) &&
385
0
                (salt == rhs.salt) &&
386
0
                (info == rhs.info) &&
387
0
                (keySize == rhs.keySize) &&
388
0
                (modifier == rhs.modifier);
389
0
        }
390
0
        void Serialize(Datasource& ds) const {
391
0
            digestType.Serialize(ds);
392
0
            password.Serialize(ds);
393
0
            salt.Serialize(ds);
394
0
            info.Serialize(ds);
395
0
            ds.Put<>(keySize);
396
0
        }
397
};
398
399
class KDF_TLS1_PRF : public Operation {
400
    public:
401
        const component::DigestType digestType;
402
        const component::Cleartext secret;
403
        const component::Cleartext seed;
404
405
        const uint64_t keySize;
406
407
        KDF_TLS1_PRF(Datasource& ds, component::Modifier modifier) :
408
            Operation(std::move(modifier)),
409
            digestType(ds),
410
            secret(ds),
411
            seed(ds),
412
            keySize(ds.Get<uint64_t>() % 1024)
413
2.29k
        { }
414
        KDF_TLS1_PRF(nlohmann::json json) :
415
            Operation(json["modifier"]),
416
            digestType(json["digestType"]),
417
            secret(json["secret"]),
418
            seed(json["seed"]),
419
            keySize(json["keySize"].get<uint64_t>())
420
0
        { }
421
422
699
        static size_t MaxOperations(void) { return 20; }
423
        std::string Name(void) const override;
424
        std::string ToString(void) const override;
425
        nlohmann::json ToJSON(void) const override;
426
0
        inline bool operator==(const KDF_TLS1_PRF& rhs) const {
427
0
            return
428
0
                (digestType == rhs.digestType) &&
429
0
                (secret == rhs.secret) &&
430
0
                (seed == rhs.seed) &&
431
0
                (modifier == rhs.modifier);
432
0
        }
433
0
        void Serialize(Datasource& ds) const {
434
0
            digestType.Serialize(ds);
435
0
            secret.Serialize(ds);
436
0
            seed.Serialize(ds);
437
0
            ds.Put<>(keySize);
438
0
        }
439
};
440
441
class KDF_PBKDF : public Operation {
442
    public:
443
        const component::DigestType digestType;
444
        const component::Cleartext password;
445
        const component::Cleartext salt;
446
        const uint64_t iterations;
447
448
        const uint64_t keySize;
449
450
        KDF_PBKDF(Datasource& ds, component::Modifier modifier) :
451
            Operation(std::move(modifier)),
452
            digestType(ds),
453
            password(ds),
454
            salt(ds),
455
            iterations(ds.Get<uint64_t>() % 5),
456
            keySize(ds.Get<uint64_t>() % 1024)
457
2.87k
        { }
458
        KDF_PBKDF(nlohmann::json json) :
459
            Operation(json["modifier"]),
460
            digestType(json["digestType"]),
461
            password(json["password"]),
462
            salt(json["salt"]),
463
            iterations(json["iterations"].get<uint64_t>()),
464
            keySize(json["keySize"].get<uint64_t>())
465
0
        { }
466
467
626
        static size_t MaxOperations(void) { return 20; }
468
        std::string Name(void) const override;
469
        std::string ToString(void) const override;
470
        nlohmann::json ToJSON(void) const override;
471
0
        inline bool operator==(const KDF_PBKDF& rhs) const {
472
0
            return
473
0
                (digestType == rhs.digestType) &&
474
0
                (password == rhs.password) &&
475
0
                (salt == rhs.salt) &&
476
0
                (iterations == rhs.iterations) &&
477
0
                (keySize == rhs.keySize) &&
478
0
                (modifier == rhs.modifier);
479
0
        }
480
0
        void Serialize(Datasource& ds) const {
481
0
            digestType.Serialize(ds);
482
0
            password.Serialize(ds);
483
0
            salt.Serialize(ds);
484
0
            ds.Put<>(iterations);
485
0
            ds.Put<>(keySize);
486
0
        }
487
};
488
489
class KDF_PBKDF1 : public Operation {
490
    public:
491
        const component::DigestType digestType;
492
        const component::Cleartext password;
493
        const component::Cleartext salt;
494
        const uint64_t iterations;
495
496
        const uint64_t keySize;
497
498
        KDF_PBKDF1(Datasource& ds, component::Modifier modifier) :
499
            Operation(std::move(modifier)),
500
            digestType(ds),
501
            password(ds),
502
            salt(ds),
503
            iterations(ds.Get<uint64_t>() % 5),
504
            keySize(ds.Get<uint64_t>() % 1024)
505
2.70k
        { }
506
        KDF_PBKDF1(nlohmann::json json) :
507
            Operation(json["modifier"]),
508
            digestType(json["digestType"]),
509
            password(json["password"]),
510
            salt(json["salt"]),
511
            iterations(json["iterations"].get<uint64_t>()),
512
            keySize(json["keySize"].get<uint64_t>())
513
0
        { }
514
515
540
        static size_t MaxOperations(void) { return 20; }
516
        std::string Name(void) const override;
517
        std::string ToString(void) const override;
518
        nlohmann::json ToJSON(void) const override;
519
0
        inline bool operator==(const KDF_PBKDF1& rhs) const {
520
0
            return
521
0
                (digestType == rhs.digestType) &&
522
0
                (password == rhs.password) &&
523
0
                (salt == rhs.salt) &&
524
0
                (iterations == rhs.iterations) &&
525
0
                (keySize == rhs.keySize) &&
526
0
                (modifier == rhs.modifier);
527
0
        }
528
0
        void Serialize(Datasource& ds) const {
529
0
            digestType.Serialize(ds);
530
0
            password.Serialize(ds);
531
0
            salt.Serialize(ds);
532
0
            ds.Put<>(iterations);
533
0
            ds.Put<>(keySize);
534
0
        }
535
};
536
537
class KDF_PBKDF2 : public Operation {
538
    public:
539
        const component::DigestType digestType;
540
        const component::Cleartext password;
541
        const component::Cleartext salt;
542
        const uint64_t iterations;
543
544
        const uint64_t keySize;
545
546
        KDF_PBKDF2(Datasource& ds, component::Modifier modifier) :
547
            Operation(std::move(modifier)),
548
            digestType(ds),
549
            password(ds),
550
            salt(ds),
551
            iterations(ds.Get<uint64_t>() % 5),
552
            keySize(ds.Get<uint64_t>() % 1024)
553
3.51k
        { }
554
        KDF_PBKDF2(nlohmann::json json) :
555
            Operation(json["modifier"]),
556
            digestType(json["digestType"]),
557
            password(json["password"]),
558
            salt(json["salt"]),
559
            iterations(json["iterations"].get<uint64_t>()),
560
            keySize(json["keySize"].get<uint64_t>())
561
0
        { }
562
563
1.73k
        static size_t MaxOperations(void) { return 20; }
564
        std::string Name(void) const override;
565
        std::string ToString(void) const override;
566
        nlohmann::json ToJSON(void) const override;
567
0
        inline bool operator==(const KDF_PBKDF2& rhs) const {
568
0
            return
569
0
                (digestType == rhs.digestType) &&
570
0
                (password == rhs.password) &&
571
0
                (salt == rhs.salt) &&
572
0
                (iterations == rhs.iterations) &&
573
0
                (keySize == rhs.keySize) &&
574
0
                (modifier == rhs.modifier);
575
0
        }
576
0
        void Serialize(Datasource& ds) const {
577
0
            digestType.Serialize(ds);
578
0
            password.Serialize(ds);
579
0
            salt.Serialize(ds);
580
0
            ds.Put<>(iterations);
581
0
            ds.Put<>(keySize);
582
0
        }
583
};
584
585
class KDF_ARGON2 : public Operation {
586
    public:
587
        const component::Cleartext password;
588
        const component::Cleartext salt;
589
        const uint8_t type;
590
        const uint8_t threads;
591
        const uint32_t memory;
592
        const uint32_t iterations;
593
        const uint32_t keySize;
594
595
        KDF_ARGON2(Datasource& ds, component::Modifier modifier) :
596
            Operation(std::move(modifier)),
597
            password(ds),
598
            salt(ds),
599
            type(ds.Get<uint8_t>()),
600
            threads(ds.Get<uint8_t>()),
601
            memory(ds.Get<uint32_t>() % (64*1024)),
602
            iterations(ds.Get<uint32_t>() % 3),
603
            keySize(ds.Get<uint32_t>() % 1024)
604
2.67k
        { }
605
        KDF_ARGON2(nlohmann::json json) :
606
            Operation(json["modifier"]),
607
            password(json["password"]),
608
            salt(json["salt"]),
609
            type(json["type"].get<uint8_t>()),
610
            threads(json["threads"].get<uint8_t>()),
611
            memory(json["memory"].get<uint32_t>()),
612
            iterations(json["iterations"].get<uint32_t>()),
613
            keySize(json["keySize"].get<uint32_t>())
614
0
        { }
615
616
370
        static size_t MaxOperations(void) { return 3; }
617
        std::string Name(void) const override;
618
        std::string ToString(void) const override;
619
        nlohmann::json ToJSON(void) const override;
620
0
        inline bool operator==(const KDF_ARGON2& rhs) const {
621
0
            return
622
0
                (password == rhs.password) &&
623
0
                (salt == rhs.salt) &&
624
0
                (type == rhs.type) &&
625
0
                (threads == rhs.threads) &&
626
0
                (memory == rhs.memory) &&
627
0
                (iterations == rhs.iterations) &&
628
0
                (keySize == rhs.keySize) &&
629
0
                (modifier == rhs.modifier);
630
0
        }
631
0
        void Serialize(Datasource& ds) const {
632
0
            password.Serialize(ds);
633
0
            salt.Serialize(ds);
634
0
            ds.Put<>(type);
635
0
            ds.Put<>(threads);
636
0
            ds.Put<>(memory);
637
0
            ds.Put<>(iterations);
638
0
            ds.Put<>(keySize);
639
0
        }
640
};
641
642
class KDF_SSH : public Operation {
643
    public:
644
        const component::DigestType digestType;
645
        const component::Cleartext key;
646
        const component::Cleartext xcghash;
647
        const component::Cleartext session_id;
648
        const component::Cleartext type;
649
        const uint64_t keySize;
650
651
        KDF_SSH(Datasource& ds, component::Modifier modifier) :
652
            Operation(std::move(modifier)),
653
            digestType(ds),
654
            key(ds),
655
            xcghash(ds),
656
            session_id(ds),
657
            type(ds),
658
            keySize(ds.Get<uint64_t>() % 1024)
659
2.96k
        { }
660
        KDF_SSH(nlohmann::json json) :
661
            Operation(json["modifier"]),
662
            digestType(json["digestType"]),
663
            key(json["key"]),
664
            xcghash(json["xcghash"]),
665
            session_id(json["session_id"]),
666
            type(json["type"]),
667
            keySize(json["keySize"].get<uint64_t>())
668
0
        { }
669
670
756
        static size_t MaxOperations(void) { return 20; }
671
        std::string Name(void) const override;
672
        std::string ToString(void) const override;
673
        nlohmann::json ToJSON(void) const override;
674
0
        inline bool operator==(const KDF_SSH& rhs) const {
675
0
            return
676
0
                (digestType == rhs.digestType) &&
677
0
                (key == rhs.key) &&
678
0
                (xcghash == rhs.xcghash) &&
679
0
                (session_id == rhs.session_id) &&
680
0
                (type == rhs.type) &&
681
0
                (keySize == rhs.keySize) &&
682
0
                (modifier == rhs.modifier);
683
0
        }
684
0
        void Serialize(Datasource& ds) const {
685
0
            digestType.Serialize(ds);
686
0
            key.Serialize(ds);
687
0
            xcghash.Serialize(ds);
688
0
            session_id.Serialize(ds);
689
0
            type.Serialize(ds);
690
0
            ds.Put<>(keySize);
691
0
        }
692
};
693
694
class KDF_X963 : public Operation {
695
    public:
696
        const component::DigestType digestType;
697
        const component::Cleartext secret;
698
        const component::Cleartext info;
699
        const uint64_t keySize;
700
701
        KDF_X963(Datasource& ds, component::Modifier modifier) :
702
            Operation(std::move(modifier)),
703
            digestType(ds),
704
            secret(ds),
705
            info(ds),
706
            keySize(ds.Get<uint64_t>() % 1024)
707
2.59k
        { }
708
        KDF_X963(nlohmann::json json) :
709
            Operation(json["modifier"]),
710
            digestType(json["digestType"]),
711
            secret(json["secret"]),
712
            info(json["info"]),
713
            keySize(json["keySize"].get<uint64_t>())
714
0
        { }
715
716
732
        static size_t MaxOperations(void) { return 20; }
717
        std::string Name(void) const override;
718
        std::string ToString(void) const override;
719
        nlohmann::json ToJSON(void) const override;
720
0
        inline bool operator==(const KDF_X963& rhs) const {
721
0
            return
722
0
                (digestType == rhs.digestType) &&
723
0
                (secret == rhs.secret) &&
724
0
                (info == rhs.info) &&
725
0
                (keySize == rhs.keySize) &&
726
0
                (modifier == rhs.modifier);
727
0
        }
728
0
        void Serialize(Datasource& ds) const {
729
0
            digestType.Serialize(ds);
730
0
            secret.Serialize(ds);
731
0
            info.Serialize(ds);
732
0
            ds.Put<>(keySize);
733
0
        }
734
};
735
736
class KDF_BCRYPT : public Operation {
737
    public:
738
        const component::DigestType digestType;
739
        const component::Cleartext secret;
740
        const component::Cleartext salt;
741
        const uint32_t iterations;
742
        const uint64_t keySize;
743
744
        KDF_BCRYPT(Datasource& ds, component::Modifier modifier) :
745
            Operation(std::move(modifier)),
746
            digestType(ds),
747
            secret(ds),
748
            salt(ds),
749
            iterations(ds.Get<uint32_t>() % 3),
750
            keySize(ds.Get<uint64_t>() % 1024)
751
2.45k
        { }
752
        KDF_BCRYPT(nlohmann::json json) :
753
            Operation(json["modifier"]),
754
            digestType(json["digestType"]),
755
            secret(json["secret"]),
756
            salt(json["salt"]),
757
            iterations(json["iterations"].get<uint32_t>()),
758
            keySize(json["keySize"].get<uint64_t>())
759
0
        { }
760
761
89
        static size_t MaxOperations(void) { return 2; }
762
        std::string Name(void) const override;
763
        std::string ToString(void) const override;
764
        nlohmann::json ToJSON(void) const override;
765
0
        inline bool operator==(const KDF_BCRYPT& rhs) const {
766
0
            return
767
0
                (digestType == rhs.digestType) &&
768
0
                (secret == rhs.secret) &&
769
0
                (salt == rhs.salt) &&
770
0
                (iterations == rhs.iterations) &&
771
0
                (keySize == rhs.keySize) &&
772
0
                (modifier == rhs.modifier);
773
0
        }
774
};
775
776
class KDF_SP_800_108 : public Operation {
777
    public:
778
        const component::MACType mech;
779
        const component::Cleartext secret;
780
        const component::Cleartext salt;
781
        const component::Cleartext label;
782
        const uint8_t mode;
783
        const uint64_t keySize;
784
785
        KDF_SP_800_108(Datasource& ds, component::Modifier modifier) :
786
            Operation(std::move(modifier)),
787
            mech(ds),
788
            secret(ds),
789
            salt(ds),
790
            label(ds),
791
            mode(ds.Get<uint8_t>()),
792
            keySize(ds.Get<uint64_t>() % 17000)
793
3.71k
        { }
794
        KDF_SP_800_108(nlohmann::json json) :
795
            Operation(json["modifier"]),
796
            mech(json["mech"]),
797
            secret(json["secret"]),
798
            salt(json["salt"]),
799
            label(json["label"]),
800
            mode(json["mode"].get<uint8_t>()),
801
            keySize(json["keySize"].get<uint64_t>())
802
0
        { }
803
804
1.67k
        static size_t MaxOperations(void) { return 20; }
805
        std::string Name(void) const override;
806
        std::string ToString(void) const override;
807
        nlohmann::json ToJSON(void) const override;
808
0
        inline bool operator==(const KDF_SP_800_108& rhs) const {
809
0
            return
810
0
                (mech == rhs.mech) &&
811
0
                (secret == rhs.secret) &&
812
0
                (salt == rhs.salt) &&
813
0
                (label == rhs.label) &&
814
0
                (mode == rhs.mode) &&
815
0
                (keySize == rhs.keySize) &&
816
0
                (modifier == rhs.modifier);
817
0
        }
818
0
        void Serialize(Datasource& ds) const {
819
0
            mech.Serialize(ds);
820
0
            secret.Serialize(ds);
821
0
            salt.Serialize(ds);
822
0
            label.Serialize(ds);
823
0
            ds.Put<>(mode);
824
0
            ds.Put<>(keySize);
825
0
        }
826
};
827
828
class CMAC : public Operation {
829
    public:
830
        const component::Cleartext cleartext;
831
        const component::SymmetricCipher cipher;
832
833
        CMAC(Datasource& ds, component::Modifier modifier) :
834
            Operation(std::move(modifier)),
835
            cleartext(ds),
836
            cipher(ds)
837
5.32k
        { }
838
        CMAC(nlohmann::json json) :
839
            Operation(json["modifier"]),
840
            cleartext(json["cleartext"]),
841
            cipher(json["cipher"])
842
0
        { }
843
844
3.46k
        static size_t MaxOperations(void) { return 20; }
845
        std::string Name(void) const override;
846
        std::string ToString(void) const override;
847
        nlohmann::json ToJSON(void) const override;
848
0
        inline bool operator==(const CMAC& rhs) const {
849
0
            return
850
0
                (cleartext == rhs.cleartext) &&
851
0
                (cipher == rhs.cipher) &&
852
0
                (modifier == rhs.modifier);
853
0
        }
854
0
        void Serialize(Datasource& ds) const {
855
0
            cleartext.Serialize(ds);
856
0
            cipher.Serialize(ds);
857
0
        }
858
};
859
860
class ECC_PrivateToPublic : public Operation {
861
    public:
862
        const component::CurveType curveType;
863
        const component::ECC_PrivateKey priv;
864
865
        ECC_PrivateToPublic(Datasource& ds, component::Modifier modifier) :
866
            Operation(std::move(modifier)),
867
            curveType(ds),
868
            priv(ds)
869
2.18k
        { }
870
        ECC_PrivateToPublic(nlohmann::json json) :
871
            Operation(json["modifier"]),
872
            curveType(json["curveType"]),
873
            priv(json["priv"])
874
0
        { }
875
876
1.06k
        static size_t MaxOperations(void) { return 5; }
877
        std::string Name(void) const override;
878
        std::string ToString(void) const override;
879
        nlohmann::json ToJSON(void) const override;
880
0
        inline bool operator==(const ECC_PrivateToPublic& rhs) const {
881
0
            return
882
0
                (curveType == rhs.curveType) &&
883
0
                (priv == rhs.priv) &&
884
0
                (modifier == rhs.modifier);
885
0
        }
886
0
        void Serialize(Datasource& ds) const {
887
0
            curveType.Serialize(ds);
888
0
            priv.Serialize(ds);
889
0
        }
890
};
891
892
class ECC_ValidatePubkey : public Operation {
893
    public:
894
        const component::CurveType curveType;
895
        const component::ECC_PublicKey pub;
896
897
        ECC_ValidatePubkey(Datasource& ds, component::Modifier modifier) :
898
            Operation(std::move(modifier)),
899
            curveType(ds),
900
            pub(ds)
901
2.54k
        { }
902
        ECC_ValidatePubkey(nlohmann::json json) :
903
            Operation(json["modifier"]),
904
            curveType(json["curveType"]),
905
            pub(json["pub_x"], json["pub_y"])
906
0
        { }
907
908
1.08k
        static size_t MaxOperations(void) { return 5; }
909
        std::string Name(void) const override;
910
        std::string ToString(void) const override;
911
        nlohmann::json ToJSON(void) const override;
912
0
        inline bool operator==(const ECC_ValidatePubkey& rhs) const {
913
0
            return
914
0
                (curveType == rhs.curveType) &&
915
0
                (pub == rhs.pub) &&
916
0
                (modifier == rhs.modifier);
917
0
        }
918
0
        void Serialize(Datasource& ds) const {
919
0
            curveType.Serialize(ds);
920
0
            pub.Serialize(ds);
921
0
        }
922
};
923
924
class ECC_GenerateKeyPair : public Operation {
925
    public:
926
        const component::CurveType curveType;
927
928
        ECC_GenerateKeyPair(Datasource& ds, component::Modifier modifier) :
929
            Operation(std::move(modifier)),
930
            curveType(ds)
931
2.05k
        { }
932
933
        ECC_GenerateKeyPair(nlohmann::json json) :
934
            Operation(json["modifier"]),
935
            curveType(json["curveType"])
936
0
        { }
937
938
908
        static size_t MaxOperations(void) { return 5; }
939
        std::string Name(void) const override;
940
        std::string ToString(void) const override;
941
        nlohmann::json ToJSON(void) const override;
942
0
        inline bool operator==(const ECC_GenerateKeyPair& rhs) const {
943
0
            return
944
0
                (curveType == rhs.curveType) &&
945
0
                (modifier == rhs.modifier);
946
0
        }
947
0
        void Serialize(Datasource& ds) const {
948
0
            curveType.Serialize(ds);
949
0
        }
950
};
951
952
class ECCSI_Sign : public Operation {
953
    public:
954
        const component::CurveType curveType;
955
        const component::ECC_PrivateKey priv;
956
        const component::Cleartext cleartext;
957
        const component::Cleartext id;
958
        const component::DigestType digestType;
959
960
        ECCSI_Sign(Datasource& ds, component::Modifier modifier) :
961
            Operation(std::move(modifier)),
962
            curveType(ds),
963
            priv(ds),
964
            cleartext(ds),
965
            id(ds),
966
            digestType(ds)
967
2.26k
        { }
968
        ECCSI_Sign(nlohmann::json json) :
969
            Operation(json["modifier"]),
970
            curveType(json["curveType"]),
971
            priv(json["priv"]),
972
            cleartext(json["cleartext"]),
973
            id(json["id"]),
974
            digestType(json["digestType"])
975
0
        { }
976
977
169
        static size_t MaxOperations(void) { return 5; }
978
        std::string Name(void) const override;
979
        std::string ToString(void) const override;
980
        nlohmann::json ToJSON(void) const override;
981
0
        inline bool operator==(const ECCSI_Sign& rhs) const {
982
0
            return
983
0
                (curveType == rhs.curveType) &&
984
0
                (priv == rhs.priv) &&
985
0
                (cleartext == rhs.cleartext) &&
986
0
                (id == rhs.id) &&
987
0
                (digestType == rhs.digestType ) &&
988
0
                (modifier == rhs.modifier);
989
0
        }
990
0
        void Serialize(Datasource& ds) const {
991
0
            curveType.Serialize(ds);
992
0
            priv.Serialize(ds);
993
0
            cleartext.Serialize(ds);
994
0
            id.Serialize(ds);
995
0
            digestType.Serialize(ds);
996
0
        }
997
};
998
999
class ECDSA_Sign : public Operation {
1000
    public:
1001
        const component::CurveType curveType;
1002
        const component::ECC_PrivateKey priv;
1003
        const component::Bignum nonce;
1004
        const component::Cleartext cleartext;
1005
        const uint8_t nonceSource;
1006
        const component::DigestType digestType;
1007
1008
        ECDSA_Sign(Datasource& ds, component::Modifier modifier) :
1009
            Operation(std::move(modifier)),
1010
            curveType(ds),
1011
            priv(ds),
1012
            nonce(ds),
1013
            cleartext(ds),
1014
            nonceSource(ds.Get<uint8_t>()),
1015
            digestType(ds)
1016
3.17k
        { }
1017
        ECDSA_Sign(nlohmann::json json) :
1018
            Operation(json["modifier"]),
1019
            curveType(json["curveType"]),
1020
            priv(json["priv"]),
1021
            nonce(json["nonce"]),
1022
            cleartext(json["cleartext"]),
1023
            nonceSource(json["nonceSource"].get<uint8_t>()),
1024
            digestType(json["digestType"])
1025
0
        { }
1026
1027
1.27k
        static size_t MaxOperations(void) { return 5; }
1028
        std::string Name(void) const override;
1029
        std::string ToString(void) const override;
1030
        nlohmann::json ToJSON(void) const override;
1031
0
        inline bool operator==(const ECDSA_Sign& rhs) const {
1032
0
            return
1033
0
                (curveType == rhs.curveType) &&
1034
0
                (priv == rhs.priv) &&
1035
0
                (nonce == rhs.nonce) &&
1036
0
                (cleartext == rhs.cleartext) &&
1037
0
                (nonceSource == rhs.nonceSource ) &&
1038
0
                (digestType == rhs.digestType ) &&
1039
0
                (modifier == rhs.modifier);
1040
0
        }
1041
0
        void Serialize(Datasource& ds) const {
1042
0
            curveType.Serialize(ds);
1043
0
            priv.Serialize(ds);
1044
0
            nonce.Serialize(ds);
1045
0
            cleartext.Serialize(ds);
1046
0
            ds.Put<>(nonceSource);
1047
0
            digestType.Serialize(ds);
1048
0
        }
1049
1.01k
        bool UseRandomNonce(void) const {
1050
1.01k
            return nonceSource == 0;
1051
1.01k
        }
1052
682
        bool UseRFC6979Nonce(void) const {
1053
682
            return nonceSource == 1;
1054
682
        }
1055
889
        bool UseSpecifiedNonce(void) const {
1056
889
            return nonceSource == 2;
1057
889
        }
1058
};
1059
1060
class ECGDSA_Sign : public Operation {
1061
    public:
1062
        const component::CurveType curveType;
1063
        const component::ECC_PrivateKey priv;
1064
        const component::Bignum nonce;
1065
        const component::Cleartext cleartext;
1066
        const uint8_t nonceSource;
1067
        const component::DigestType digestType;
1068
1069
        ECGDSA_Sign(Datasource& ds, component::Modifier modifier) :
1070
            Operation(std::move(modifier)),
1071
            curveType(ds),
1072
            priv(ds),
1073
            nonce(ds),
1074
            cleartext(ds),
1075
            nonceSource(ds.Get<uint8_t>()),
1076
            digestType(ds)
1077
2.40k
        { }
1078
        ECGDSA_Sign(nlohmann::json json) :
1079
            Operation(json["modifier"]),
1080
            curveType(json["curveType"]),
1081
            priv(json["priv"]),
1082
            nonce(json["nonce"]),
1083
            cleartext(json["cleartext"]),
1084
            nonceSource(json["nonceSource"].get<uint8_t>()),
1085
            digestType(json["digestType"])
1086
0
        { }
1087
1088
388
        static size_t MaxOperations(void) { return 5; }
1089
        std::string Name(void) const override;
1090
        std::string ToString(void) const override;
1091
        nlohmann::json ToJSON(void) const override;
1092
0
        inline bool operator==(const ECGDSA_Sign& rhs) const {
1093
0
            return
1094
0
                (curveType == rhs.curveType) &&
1095
0
                (priv == rhs.priv) &&
1096
0
                (nonce == rhs.nonce) &&
1097
0
                (cleartext == rhs.cleartext) &&
1098
0
                (nonceSource == rhs.nonceSource ) &&
1099
0
                (digestType == rhs.digestType ) &&
1100
0
                (modifier == rhs.modifier);
1101
0
        }
1102
0
        void Serialize(Datasource& ds) const {
1103
0
            curveType.Serialize(ds);
1104
0
            priv.Serialize(ds);
1105
0
            nonce.Serialize(ds);
1106
0
            cleartext.Serialize(ds);
1107
0
            ds.Put<>(nonceSource);
1108
0
            digestType.Serialize(ds);
1109
0
        }
1110
286
        bool UseRandomNonce(void) const {
1111
286
            return nonceSource == 0;
1112
286
        }
1113
0
        bool UseRFC6979Nonce(void) const {
1114
0
            return nonceSource == 1;
1115
0
        }
1116
73
        bool UseSpecifiedNonce(void) const {
1117
73
            return nonceSource == 2;
1118
73
        }
1119
};
1120
1121
class ECRDSA_Sign : public Operation {
1122
    public:
1123
        const component::CurveType curveType;
1124
        const component::ECC_PrivateKey priv;
1125
        const component::Bignum nonce;
1126
        const component::Cleartext cleartext;
1127
        const uint8_t nonceSource;
1128
        const component::DigestType digestType;
1129
1130
        ECRDSA_Sign(Datasource& ds, component::Modifier modifier) :
1131
            Operation(std::move(modifier)),
1132
            curveType(ds),
1133
            priv(ds),
1134
            nonce(ds),
1135
            cleartext(ds),
1136
            nonceSource(ds.Get<uint8_t>()),
1137
            digestType(ds)
1138
2.26k
        { }
1139
        ECRDSA_Sign(nlohmann::json json) :
1140
            Operation(json["modifier"]),
1141
            curveType(json["curveType"]),
1142
            priv(json["priv"]),
1143
            nonce(json["nonce"]),
1144
            cleartext(json["cleartext"]),
1145
            nonceSource(json["nonceSource"].get<uint8_t>()),
1146
            digestType(json["digestType"])
1147
0
        { }
1148
1149
149
        static size_t MaxOperations(void) { return 5; }
1150
        std::string Name(void) const override;
1151
        std::string ToString(void) const override;
1152
        nlohmann::json ToJSON(void) const override;
1153
0
        inline bool operator==(const ECRDSA_Sign& rhs) const {
1154
0
            return
1155
0
                (curveType == rhs.curveType) &&
1156
0
                (priv == rhs.priv) &&
1157
0
                (nonce == rhs.nonce) &&
1158
0
                (cleartext == rhs.cleartext) &&
1159
0
                (nonceSource == rhs.nonceSource ) &&
1160
0
                (digestType == rhs.digestType ) &&
1161
0
                (modifier == rhs.modifier);
1162
0
        }
1163
0
        void Serialize(Datasource& ds) const {
1164
0
            curveType.Serialize(ds);
1165
0
            priv.Serialize(ds);
1166
0
            nonce.Serialize(ds);
1167
0
            cleartext.Serialize(ds);
1168
0
            ds.Put<>(nonceSource);
1169
0
            digestType.Serialize(ds);
1170
0
        }
1171
0
        bool UseRandomNonce(void) const {
1172
0
            return nonceSource == 0;
1173
0
        }
1174
0
        bool UseRFC6979Nonce(void) const {
1175
0
            return nonceSource == 1;
1176
0
        }
1177
0
        bool UseSpecifiedNonce(void) const {
1178
0
            return nonceSource == 2;
1179
0
        }
1180
};
1181
1182
class Schnorr_Sign : public Operation {
1183
    public:
1184
        const component::CurveType curveType;
1185
        const component::ECC_PrivateKey priv;
1186
        const component::Bignum nonce;
1187
        const component::Cleartext cleartext;
1188
        const uint8_t nonceSource;
1189
        const component::DigestType digestType;
1190
1191
        Schnorr_Sign(Datasource& ds, component::Modifier modifier) :
1192
            Operation(std::move(modifier)),
1193
            curveType(ds),
1194
            priv(ds),
1195
            nonce(ds),
1196
            cleartext(ds),
1197
            nonceSource(ds.Get<uint8_t>()),
1198
            digestType(ds)
1199
2.47k
        { }
1200
        Schnorr_Sign(nlohmann::json json) :
1201
            Operation(json["modifier"]),
1202
            curveType(json["curveType"]),
1203
            priv(json["priv"]),
1204
            nonce(json["nonce"]),
1205
            cleartext(json["cleartext"]),
1206
            nonceSource(json["nonceSource"].get<uint8_t>()),
1207
            digestType(json["digestType"])
1208
0
        { }
1209
1210
164
        static size_t MaxOperations(void) { return 5; }
1211
        std::string Name(void) const override;
1212
        std::string ToString(void) const override;
1213
        nlohmann::json ToJSON(void) const override;
1214
0
        inline bool operator==(const Schnorr_Sign& rhs) const {
1215
0
            return
1216
0
                (curveType == rhs.curveType) &&
1217
0
                (priv == rhs.priv) &&
1218
0
                (nonce == rhs.nonce) &&
1219
0
                (cleartext == rhs.cleartext) &&
1220
0
                (nonceSource == rhs.nonceSource ) &&
1221
0
                (digestType == rhs.digestType ) &&
1222
0
                (modifier == rhs.modifier);
1223
0
        }
1224
0
        void Serialize(Datasource& ds) const {
1225
0
            curveType.Serialize(ds);
1226
0
            priv.Serialize(ds);
1227
0
            nonce.Serialize(ds);
1228
0
            cleartext.Serialize(ds);
1229
0
            ds.Put<>(nonceSource);
1230
0
            digestType.Serialize(ds);
1231
0
        }
1232
0
        bool UseRandomNonce(void) const {
1233
0
            return nonceSource == 0;
1234
0
        }
1235
0
        bool UseBIP340Nonce(void) const {
1236
0
            return nonceSource == 1;
1237
0
        }
1238
0
        bool UseSpecifiedNonce(void) const {
1239
0
            return nonceSource == 2;
1240
0
        }
1241
};
1242
1243
class ECCSI_Verify : public Operation {
1244
    public:
1245
        const component::CurveType curveType;
1246
        const component::Cleartext cleartext;
1247
        const component::Cleartext id;
1248
        const component::ECCSI_Signature signature;
1249
        const component::DigestType digestType;
1250
1251
        ECCSI_Verify(Datasource& ds, component::Modifier modifier) :
1252
            Operation(std::move(modifier)),
1253
            curveType(ds),
1254
            cleartext(ds),
1255
            id(ds),
1256
            signature(ds),
1257
            digestType(ds)
1258
2.90k
        { }
1259
        ECCSI_Verify(const ECCSI_Sign& opECCSI_Sign, const component::ECCSI_Signature signature, component::Modifier modifier);
1260
        ECCSI_Verify(nlohmann::json json) :
1261
            Operation(json["modifier"]),
1262
            curveType(json["curveType"]),
1263
            cleartext(json["cleartext"]),
1264
            id(json["id"]),
1265
            signature(json["signature"]),
1266
            digestType(json["digestType"])
1267
0
        { }
1268
1269
156
        static size_t MaxOperations(void) { return 5; }
1270
        std::string Name(void) const override;
1271
        std::string ToString(void) const override;
1272
        nlohmann::json ToJSON(void) const override;
1273
0
        inline bool operator==(const ECCSI_Verify& rhs) const {
1274
0
            return
1275
0
                (curveType == rhs.curveType) &&
1276
0
                (cleartext == rhs.cleartext) &&
1277
0
                (id == rhs.id) &&
1278
0
                (signature == rhs.signature) &&
1279
0
                (digestType == rhs.digestType) &&
1280
0
                (modifier == rhs.modifier);
1281
0
        }
1282
0
        void Serialize(Datasource& ds) const {
1283
0
            curveType.Serialize(ds);
1284
0
            cleartext.Serialize(ds);
1285
0
            id.Serialize(ds);
1286
0
            signature.Serialize(ds);
1287
0
            digestType.Serialize(ds);
1288
0
        }
1289
};
1290
1291
class ECDSA_Verify : public Operation {
1292
    public:
1293
        const component::CurveType curveType;
1294
        const component::Cleartext cleartext;
1295
        const component::ECDSA_Signature signature;
1296
        const component::DigestType digestType;
1297
1298
        ECDSA_Verify(Datasource& ds, component::Modifier modifier) :
1299
            Operation(std::move(modifier)),
1300
            curveType(ds),
1301
            cleartext(ds),
1302
            signature(ds),
1303
            digestType(ds)
1304
2.40k
        { }
1305
        ECDSA_Verify(const ECDSA_Sign& opECDSA_Sign, const component::ECDSA_Signature signature, component::Modifier modifier);
1306
        ECDSA_Verify(nlohmann::json json) :
1307
            Operation(json["modifier"]),
1308
            curveType(json["curveType"]),
1309
            cleartext(json["cleartext"]),
1310
            signature(json["signature"]),
1311
            digestType(json["digestType"])
1312
0
        { }
1313
1314
631
        static size_t MaxOperations(void) { return 5; }
1315
        std::string Name(void) const override;
1316
        std::string ToString(void) const override;
1317
        nlohmann::json ToJSON(void) const override;
1318
0
        inline bool operator==(const ECDSA_Verify& rhs) const {
1319
0
            return
1320
0
                (curveType == rhs.curveType) &&
1321
0
                (cleartext == rhs.cleartext) &&
1322
0
                (signature == rhs.signature) &&
1323
0
                (digestType == rhs.digestType) &&
1324
0
                (modifier == rhs.modifier);
1325
0
        }
1326
0
        void Serialize(Datasource& ds) const {
1327
0
            curveType.Serialize(ds);
1328
0
            cleartext.Serialize(ds);
1329
0
            signature.Serialize(ds);
1330
0
            digestType.Serialize(ds);
1331
0
        }
1332
};
1333
1334
class ECGDSA_Verify : public Operation {
1335
    public:
1336
        const component::CurveType curveType;
1337
        const component::Cleartext cleartext;
1338
        const component::ECGDSA_Signature signature;
1339
        const component::DigestType digestType;
1340
1341
        ECGDSA_Verify(Datasource& ds, component::Modifier modifier) :
1342
            Operation(std::move(modifier)),
1343
            curveType(ds),
1344
            cleartext(ds),
1345
            signature(ds),
1346
            digestType(ds)
1347
2.63k
        { }
1348
        ECGDSA_Verify(nlohmann::json json) :
1349
            Operation(json["modifier"]),
1350
            curveType(json["curveType"]),
1351
            cleartext(json["cleartext"]),
1352
            signature(json["signature"]),
1353
            digestType(json["digestType"])
1354
0
        { }
1355
1356
402
        static size_t MaxOperations(void) { return 5; }
1357
        std::string Name(void) const override;
1358
        std::string ToString(void) const override;
1359
        nlohmann::json ToJSON(void) const override;
1360
0
        inline bool operator==(const ECGDSA_Verify& rhs) const {
1361
0
            return
1362
0
                (curveType == rhs.curveType) &&
1363
0
                (cleartext == rhs.cleartext) &&
1364
0
                (signature == rhs.signature) &&
1365
0
                (digestType == rhs.digestType) &&
1366
0
                (modifier == rhs.modifier);
1367
0
        }
1368
0
        void Serialize(Datasource& ds) const {
1369
0
            curveType.Serialize(ds);
1370
0
            cleartext.Serialize(ds);
1371
0
            signature.Serialize(ds);
1372
0
            digestType.Serialize(ds);
1373
0
        }
1374
};
1375
1376
class ECRDSA_Verify : public Operation {
1377
    public:
1378
        const component::CurveType curveType;
1379
        const component::Cleartext cleartext;
1380
        const component::ECRDSA_Signature signature;
1381
        const component::DigestType digestType;
1382
1383
        ECRDSA_Verify(Datasource& ds, component::Modifier modifier) :
1384
            Operation(std::move(modifier)),
1385
            curveType(ds),
1386
            cleartext(ds),
1387
            signature(ds),
1388
            digestType(ds)
1389
2.27k
        { }
1390
        ECRDSA_Verify(nlohmann::json json) :
1391
            Operation(json["modifier"]),
1392
            curveType(json["curveType"]),
1393
            cleartext(json["cleartext"]),
1394
            signature(json["signature"]),
1395
            digestType(json["digestType"])
1396
0
        { }
1397
1398
147
        static size_t MaxOperations(void) { return 5; }
1399
        std::string Name(void) const override;
1400
        std::string ToString(void) const override;
1401
        nlohmann::json ToJSON(void) const override;
1402
0
        inline bool operator==(const ECRDSA_Verify& rhs) const {
1403
0
            return
1404
0
                (curveType == rhs.curveType) &&
1405
0
                (cleartext == rhs.cleartext) &&
1406
0
                (signature == rhs.signature) &&
1407
0
                (digestType == rhs.digestType) &&
1408
0
                (modifier == rhs.modifier);
1409
0
        }
1410
0
        void Serialize(Datasource& ds) const {
1411
0
            curveType.Serialize(ds);
1412
0
            cleartext.Serialize(ds);
1413
0
            signature.Serialize(ds);
1414
0
            digestType.Serialize(ds);
1415
0
        }
1416
};
1417
1418
class ECDSA_Recover : public Operation {
1419
    public:
1420
        const component::CurveType curveType;
1421
        const component::Cleartext cleartext;
1422
        const component::BignumPair signature;
1423
        const component::DigestType digestType;
1424
        const uint8_t id;
1425
1426
        ECDSA_Recover(Datasource& ds, component::Modifier modifier) :
1427
            Operation(std::move(modifier)),
1428
            curveType(ds),
1429
            cleartext(ds),
1430
            signature(ds),
1431
            digestType(ds),
1432
            id(ds.Get<uint8_t>())
1433
3.10k
        { }
1434
        ECDSA_Recover(nlohmann::json json) :
1435
            Operation(json["modifier"]),
1436
            curveType(json["curveType"]),
1437
            cleartext(json["cleartext"]),
1438
            signature(json["signature"]),
1439
            digestType(json["digestType"]),
1440
            id(json["id"].get<uint8_t>())
1441
0
        { }
1442
1443
928
        static size_t MaxOperations(void) { return 5; }
1444
        std::string Name(void) const override;
1445
        std::string ToString(void) const override;
1446
        nlohmann::json ToJSON(void) const override;
1447
0
        inline bool operator==(const ECDSA_Recover& rhs) const {
1448
0
            return
1449
0
                (curveType == rhs.curveType) &&
1450
0
                (cleartext == rhs.cleartext) &&
1451
0
                (signature == rhs.signature) &&
1452
0
                (digestType == rhs.digestType) &&
1453
0
                (id == rhs.id) &&
1454
0
                (modifier == rhs.modifier);
1455
0
        }
1456
0
        void Serialize(Datasource& ds) const {
1457
0
            curveType.Serialize(ds);
1458
0
            cleartext.Serialize(ds);
1459
0
            signature.Serialize(ds);
1460
0
            digestType.Serialize(ds);
1461
0
            ds.Put<>(id);
1462
0
        }
1463
};
1464
1465
class DSA_GenerateParameters : public Operation {
1466
    public:
1467
        DSA_GenerateParameters(Datasource& ds, component::Modifier modifier) :
1468
            Operation(std::move(modifier))
1469
1.62k
        { (void)ds; }
1470
        DSA_GenerateParameters(nlohmann::json json) :
1471
            Operation(json["modifier"])
1472
0
        { }
1473
        DSA_GenerateParameters(component::Modifier modifier) :
1474
            Operation(std::move(modifier))
1475
0
        { }
1476
1477
134
        static size_t MaxOperations(void) { return 5; }
1478
        std::string Name(void) const override;
1479
        std::string ToString(void) const override;
1480
        nlohmann::json ToJSON(void) const override;
1481
0
        inline bool operator==(const DSA_GenerateParameters& rhs) const {
1482
0
            return
1483
0
                (modifier == rhs.modifier);
1484
0
        }
1485
0
        void Serialize(Datasource& ds) const {
1486
0
            (void)ds;
1487
0
        }
1488
};
1489
1490
class DSA_PrivateToPublic : public Operation {
1491
    public:
1492
        const component::Bignum g;
1493
        const component::Bignum p;
1494
        const component::Bignum priv;
1495
1496
        DSA_PrivateToPublic(Datasource& ds, component::Modifier modifier) :
1497
            Operation(std::move(modifier)),
1498
            g(ds),
1499
            p(ds),
1500
            priv(ds)
1501
2.84k
        { }
1502
        DSA_PrivateToPublic(nlohmann::json json) :
1503
            Operation(json["modifier"]),
1504
            g(json["g"]),
1505
            p(json["p"]),
1506
            priv(json["priv"])
1507
0
        { }
1508
        DSA_PrivateToPublic(
1509
                component::Modifier modifier,
1510
                component::Bignum g,
1511
                component::Bignum p,
1512
                component::Bignum priv) :
1513
            Operation(std::move(modifier)),
1514
            g(g),
1515
            p(p),
1516
            priv(priv)
1517
0
        { }
1518
1519
138
        static size_t MaxOperations(void) { return 5; }
1520
        std::string Name(void) const override;
1521
        std::string ToString(void) const override;
1522
        nlohmann::json ToJSON(void) const override;
1523
0
        inline bool operator==(const DSA_PrivateToPublic& rhs) const {
1524
0
            return
1525
0
                (g == rhs.g) &&
1526
0
                (p == rhs.p) &&
1527
0
                (priv == rhs.priv) &&
1528
0
                (modifier == rhs.modifier);
1529
0
        }
1530
0
        void Serialize(Datasource& ds) const {
1531
0
            priv.Serialize(ds);
1532
0
        }
1533
};
1534
1535
class DSA_GenerateKeyPair : public Operation {
1536
    public:
1537
        const component::Bignum p;
1538
        const component::Bignum q;
1539
        const component::Bignum g;
1540
1541
        DSA_GenerateKeyPair(Datasource& ds, component::Modifier modifier) :
1542
            Operation(std::move(modifier)),
1543
            p(ds),
1544
            q(ds),
1545
            g(ds)
1546
2.53k
        { }
1547
        DSA_GenerateKeyPair(nlohmann::json json) :
1548
            Operation(json["modifier"]),
1549
            p(json["p"]),
1550
            q(json["q"]),
1551
            g(json["g"])
1552
0
        { }
1553
        DSA_GenerateKeyPair(
1554
                component::Modifier modifier,
1555
                component::Bignum p,
1556
                component::Bignum q,
1557
                component::Bignum g) :
1558
            Operation(std::move(modifier)),
1559
            p(p),
1560
            q(q),
1561
            g(g)
1562
0
        { }
1563
1564
234
        static size_t MaxOperations(void) { return 5; }
1565
        std::string Name(void) const override;
1566
        std::string ToString(void) const override;
1567
        nlohmann::json ToJSON(void) const override;
1568
0
        inline bool operator==(const DSA_GenerateKeyPair& rhs) const {
1569
0
            return
1570
0
                (p == rhs.p) &&
1571
0
                (q == rhs.q) &&
1572
0
                (g == rhs.g) &&
1573
0
                (modifier == rhs.modifier);
1574
0
        }
1575
0
        void Serialize(Datasource& ds) const {
1576
0
            p.Serialize(ds);
1577
0
            q.Serialize(ds);
1578
0
            g.Serialize(ds);
1579
0
        }
1580
};
1581
1582
class DSA_Sign : public Operation {
1583
    public:
1584
        const component::DSA_Parameters parameters;
1585
        const component::Bignum priv;
1586
        const component::Cleartext cleartext;
1587
1588
        DSA_Sign(Datasource& ds, component::Modifier modifier) :
1589
            Operation(std::move(modifier)),
1590
            parameters(ds),
1591
            priv(ds),
1592
            cleartext(ds)
1593
2.75k
        { }
1594
        DSA_Sign(nlohmann::json json) :
1595
            Operation(json["modifier"]),
1596
            parameters(json["parameters"]),
1597
            priv(json["priv"]),
1598
            cleartext(json["cleartext"])
1599
0
        { }
1600
        DSA_Sign(
1601
                component::Modifier modifier,
1602
                component::DSA_Parameters parameters,
1603
                component::Bignum priv,
1604
                component::Cleartext cleartext) :
1605
            Operation(std::move(modifier)),
1606
            parameters(parameters),
1607
            priv(priv),
1608
            cleartext(cleartext)
1609
0
        { }
1610
1611
218
        static size_t MaxOperations(void) { return 5; }
1612
        std::string Name(void) const override;
1613
        std::string ToString(void) const override;
1614
        nlohmann::json ToJSON(void) const override;
1615
0
        inline bool operator==(const DSA_Sign& rhs) const {
1616
0
            return
1617
0
                (parameters == rhs.parameters) &&
1618
0
                (priv == rhs.priv) &&
1619
0
                (cleartext == rhs.cleartext) &&
1620
0
                (modifier == rhs.modifier);
1621
0
        }
1622
0
        void Serialize(Datasource& ds) const {
1623
0
            parameters.Serialize(ds);
1624
0
            priv.Serialize(ds);
1625
0
            cleartext.Serialize(ds);
1626
0
        }
1627
};
1628
1629
class DSA_Verify : public Operation {
1630
    public:
1631
        const component::DSA_Parameters parameters;
1632
        const component::Bignum pub;
1633
        const component::BignumPair signature;
1634
        const component::Cleartext cleartext;
1635
1636
        DSA_Verify(Datasource& ds, component::Modifier modifier) :
1637
            Operation(std::move(modifier)),
1638
            parameters(ds),
1639
            pub(ds),
1640
            signature(ds),
1641
            cleartext(ds)
1642
2.83k
        { }
1643
        DSA_Verify(nlohmann::json json) :
1644
            Operation(json["modifier"]),
1645
            parameters(json["parameters"]),
1646
            pub(json["pub"]),
1647
            signature(json["signature"]),
1648
            cleartext(json["cleartext"])
1649
0
        { }
1650
        DSA_Verify(
1651
                component::Modifier modifier,
1652
                component::DSA_Parameters parameters,
1653
                component::Bignum pub,
1654
                component::BignumPair signature,
1655
                component::Cleartext cleartext) :
1656
            Operation(std::move(modifier)),
1657
            parameters(parameters),
1658
            pub(pub),
1659
            signature(signature),
1660
            cleartext(cleartext)
1661
0
        { }
1662
1663
542
        static size_t MaxOperations(void) { return 5; }
1664
        std::string Name(void) const override;
1665
        std::string ToString(void) const override;
1666
        nlohmann::json ToJSON(void) const override;
1667
0
        inline bool operator==(const DSA_Verify& rhs) const {
1668
0
            return
1669
0
                (parameters == rhs.parameters) &&
1670
0
                (pub == rhs.pub) &&
1671
0
                (signature == rhs.signature) &&
1672
0
                (cleartext == rhs.cleartext) &&
1673
0
                (modifier == rhs.modifier);
1674
0
        }
1675
0
        void Serialize(Datasource& ds) const {
1676
0
            parameters.Serialize(ds);
1677
0
            pub.Serialize(ds);
1678
0
            signature.Serialize(ds);
1679
0
            cleartext.Serialize(ds);
1680
0
        }
1681
};
1682
1683
class Schnorr_Verify : public Operation {
1684
    public:
1685
        const component::CurveType curveType;
1686
        const component::Cleartext cleartext;
1687
        const component::ECDSA_Signature signature;
1688
        const component::DigestType digestType;
1689
1690
        Schnorr_Verify(Datasource& ds, component::Modifier modifier) :
1691
            Operation(std::move(modifier)),
1692
            curveType(ds),
1693
            cleartext(ds),
1694
            signature(ds),
1695
            digestType(ds)
1696
2.50k
        { }
1697
        Schnorr_Verify(nlohmann::json json) :
1698
            Operation(json["modifier"]),
1699
            curveType(json["curveType"]),
1700
            cleartext(json["cleartext"]),
1701
            signature(json["signature"]),
1702
            digestType(json["digestType"])
1703
0
        { }
1704
1705
139
        static size_t MaxOperations(void) { return 5; }
1706
        std::string Name(void) const override;
1707
        std::string ToString(void) const override;
1708
        nlohmann::json ToJSON(void) const override;
1709
0
        inline bool operator==(const Schnorr_Verify& rhs) const {
1710
0
            return
1711
0
                (curveType == rhs.curveType) &&
1712
0
                (cleartext == rhs.cleartext) &&
1713
0
                (signature == rhs.signature) &&
1714
0
                (digestType == rhs.digestType) &&
1715
0
                (modifier == rhs.modifier);
1716
0
        }
1717
0
        void Serialize(Datasource& ds) const {
1718
0
            curveType.Serialize(ds);
1719
0
            cleartext.Serialize(ds);
1720
0
            signature.Serialize(ds);
1721
0
            digestType.Serialize(ds);
1722
0
        }
1723
};
1724
1725
class ECDH_Derive : public Operation {
1726
    public:
1727
        const component::CurveType curveType;
1728
        const component::ECC_PrivateKey priv;
1729
        const component::ECC_PublicKey pub;
1730
1731
        ECDH_Derive(Datasource& ds, component::Modifier modifier) :
1732
            Operation(std::move(modifier)),
1733
            curveType(ds),
1734
            priv(ds),
1735
            pub(ds)
1736
2.30k
        { }
1737
        ECDH_Derive(nlohmann::json json) :
1738
            Operation(json["modifier"]),
1739
            curveType(json["curveType"]),
1740
            priv(json["priv"]),
1741
            pub(json["pub_x"], json["pub_y"])
1742
0
        { }
1743
        ECDH_Derive(
1744
                component::Modifier modifier,
1745
                component::CurveType curveType,
1746
                component::ECC_PrivateKey priv,
1747
                component::ECC_PublicKey pub) :
1748
            Operation(std::move(modifier)),
1749
            curveType(curveType),
1750
            priv(priv),
1751
            pub(pub)
1752
0
        { }
1753
1754
1755
146
        static size_t MaxOperations(void) { return 5; }
1756
        std::string Name(void) const override;
1757
        std::string ToString(void) const override;
1758
        nlohmann::json ToJSON(void) const override;
1759
0
        inline bool operator==(const ECDH_Derive& rhs) const {
1760
0
            return
1761
0
                (curveType == rhs.curveType) &&
1762
0
                (priv == rhs.priv) &&
1763
0
                (pub == rhs.pub) &&
1764
0
                (modifier == rhs.modifier);
1765
0
        }
1766
0
        void Serialize(Datasource& ds) const {
1767
0
            curveType.Serialize(ds);
1768
0
            priv.Serialize(ds);
1769
0
            pub.Serialize(ds);
1770
0
        }
1771
};
1772
1773
class ECIES_Encrypt : public Operation {
1774
    public:
1775
        const component::Cleartext cleartext;
1776
        const component::CurveType curveType;
1777
        const component::ECC_PrivateKey priv;
1778
        const component::ECC_PublicKey pub;
1779
        const component::SymmetricCipherType cipherType;
1780
        const std::optional<component::SymmetricIV> iv;
1781
        /* TODO kdf type */
1782
        /* TODO mac type */
1783
1784
        ECIES_Encrypt(Datasource& ds, component::Modifier modifier) :
1785
            Operation(std::move(modifier)),
1786
            cleartext(ds),
1787
            curveType(ds),
1788
            priv(ds),
1789
            pub(ds),
1790
            cipherType(ds),
1791
            iv(ds.Get<bool>() ? std::nullopt : std::make_optional<component::SymmetricIV>(ds))
1792
2.72k
        { }
1793
        ECIES_Encrypt(nlohmann::json json) :
1794
            Operation(json["modifier"]),
1795
            cleartext(json["cleartext"]),
1796
            curveType(json["curveType"]),
1797
            priv(json["priv"]),
1798
            pub(json["pub_x"], json["pub_y"]),
1799
            cipherType(json["cipherType"]),
1800
            iv(
1801
                    json["iv_enabled"].get<bool>() ?
1802
                        std::optional<component::SymmetricIV>(json["iv"]) :
1803
                        std::optional<component::SymmetricIV>(std::nullopt)
1804
            )
1805
0
        { }
1806
1807
189
        static size_t MaxOperations(void) { return 5; }
1808
        std::string Name(void) const override;
1809
        std::string ToString(void) const override;
1810
        nlohmann::json ToJSON(void) const override;
1811
0
        inline bool operator==(const ECIES_Encrypt& rhs) const {
1812
0
            return
1813
0
                (cleartext == rhs.cleartext) &&
1814
0
                (curveType == rhs.curveType) &&
1815
0
                (priv == rhs.priv) &&
1816
0
                (pub == rhs.pub) &&
1817
0
                (cipherType == rhs.cipherType) &&
1818
0
                (iv == rhs.iv) &&
1819
0
                (modifier == rhs.modifier);
1820
0
        }
1821
0
        void Serialize(Datasource& ds) const {
1822
0
            cleartext.Serialize(ds);
1823
0
            curveType.Serialize(ds);
1824
0
            priv.Serialize(ds);
1825
0
            pub.Serialize(ds);
1826
0
            cipherType.Serialize(ds);
1827
0
            if ( iv == std::nullopt ) {
1828
0
                ds.Put<bool>(true);
1829
0
            } else {
1830
0
                ds.Put<bool>(false);
1831
0
                iv->Serialize(ds);
1832
0
            }
1833
0
        }
1834
};
1835
1836
class ECIES_Decrypt : public Operation {
1837
    public:
1838
        const Buffer ciphertext;
1839
        const component::CurveType curveType;
1840
        const component::ECC_PrivateKey priv;
1841
        const component::ECC_PublicKey pub;
1842
        const component::SymmetricCipherType cipherType;
1843
        const std::optional<component::SymmetricIV> iv;
1844
        /* TODO kdf type */
1845
        /* TODO mac type */
1846
1847
        ECIES_Decrypt(Datasource& ds, component::Modifier modifier) :
1848
            Operation(std::move(modifier)),
1849
            ciphertext(ds),
1850
            curveType(ds),
1851
            priv(ds),
1852
            pub(ds),
1853
            cipherType(ds),
1854
            iv(ds.Get<bool>() ? std::nullopt : std::make_optional<component::SymmetricIV>(ds))
1855
3.09k
        { }
1856
        ECIES_Decrypt(nlohmann::json json) :
1857
            Operation(json["modifier"]),
1858
            ciphertext(json["ciphertext"]),
1859
            curveType(json["curveType"]),
1860
            priv(json["priv"]),
1861
            pub(json["pub_x"], json["pub_y"]),
1862
            cipherType(json["cipherType"]),
1863
            iv(
1864
                    json["iv_enabled"].get<bool>() ?
1865
                        std::optional<component::SymmetricIV>(json["iv"]) :
1866
                        std::optional<component::SymmetricIV>(std::nullopt)
1867
            )
1868
0
        { }
1869
1870
170
        static size_t MaxOperations(void) { return 5; }
1871
        std::string Name(void) const override;
1872
        std::string ToString(void) const override;
1873
        nlohmann::json ToJSON(void) const override;
1874
0
        inline bool operator==(const ECIES_Decrypt& rhs) const {
1875
0
            return
1876
0
                (ciphertext == rhs.ciphertext) &&
1877
0
                (curveType == rhs.curveType) &&
1878
0
                (priv == rhs.priv) &&
1879
0
                (pub == rhs.pub) &&
1880
0
                (cipherType == rhs.cipherType) &&
1881
0
                (iv == rhs.iv) &&
1882
0
                (modifier == rhs.modifier);
1883
0
        }
1884
0
        void Serialize(Datasource& ds) const {
1885
0
            ciphertext.Serialize(ds);
1886
0
            curveType.Serialize(ds);
1887
0
            priv.Serialize(ds);
1888
0
            pub.Serialize(ds);
1889
0
            cipherType.Serialize(ds);
1890
0
            if ( iv == std::nullopt ) {
1891
0
                ds.Put<bool>(true);
1892
0
            } else {
1893
0
                ds.Put<bool>(false);
1894
0
                iv->Serialize(ds);
1895
0
            }
1896
0
        }
1897
};
1898
1899
class ECC_Point_Add : public Operation {
1900
    public:
1901
        const component::CurveType curveType;
1902
        const component::ECC_Point a, b;
1903
1904
        ECC_Point_Add(Datasource& ds, component::Modifier modifier) :
1905
            Operation(std::move(modifier)),
1906
            curveType(ds),
1907
            a(ds),
1908
            b(ds)
1909
2.09k
        { }
1910
        ECC_Point_Add(nlohmann::json json) :
1911
            Operation(json["modifier"]),
1912
            curveType(json["curveType"]),
1913
            a(json["a_x"], json["a_y"]),
1914
            b(json["b_x"], json["b_y"])
1915
0
        { }
1916
1917
261
        static size_t MaxOperations(void) { return 5; }
1918
        std::string Name(void) const override;
1919
        std::string ToString(void) const override;
1920
        nlohmann::json ToJSON(void) const override;
1921
0
        inline bool operator==(const ECC_Point_Add& rhs) const {
1922
0
            return
1923
0
                (curveType == rhs.curveType) &&
1924
0
                (a == rhs.a) &&
1925
0
                (b == rhs.b) &&
1926
0
                (modifier == rhs.modifier);
1927
0
        }
1928
0
        void Serialize(Datasource& ds) const {
1929
0
            curveType.Serialize(ds);
1930
0
            a.Serialize(ds);
1931
0
            b.Serialize(ds);
1932
0
        }
1933
};
1934
1935
class ECC_Point_Sub : public Operation {
1936
    public:
1937
        const component::CurveType curveType;
1938
        const component::ECC_Point a, b;
1939
1940
        ECC_Point_Sub(Datasource& ds, component::Modifier modifier) :
1941
            Operation(std::move(modifier)),
1942
            curveType(ds),
1943
            a(ds),
1944
            b(ds)
1945
2.35k
        { }
1946
        ECC_Point_Sub(nlohmann::json json) :
1947
            Operation(json["modifier"]),
1948
            curveType(json["curveType"]),
1949
            a(json["a_x"], json["a_y"]),
1950
            b(json["b_x"], json["b_y"])
1951
0
        { }
1952
1953
297
        static size_t MaxOperations(void) { return 5; }
1954
        std::string Name(void) const override;
1955
        std::string ToString(void) const override;
1956
        nlohmann::json ToJSON(void) const override;
1957
0
        inline bool operator==(const ECC_Point_Sub& rhs) const {
1958
0
            return
1959
0
                (curveType == rhs.curveType) &&
1960
0
                (a == rhs.a) &&
1961
0
                (b == rhs.b) &&
1962
0
                (modifier == rhs.modifier);
1963
0
        }
1964
0
        void Serialize(Datasource& ds) const {
1965
0
            curveType.Serialize(ds);
1966
0
            a.Serialize(ds);
1967
0
            b.Serialize(ds);
1968
0
        }
1969
};
1970
1971
class ECC_Point_Mul : public Operation {
1972
    public:
1973
        const component::CurveType curveType;
1974
        const component::ECC_Point a;
1975
        const component::Bignum b;
1976
1977
        ECC_Point_Mul(Datasource& ds, component::Modifier modifier) :
1978
            Operation(std::move(modifier)),
1979
            curveType(ds),
1980
            a(ds),
1981
            b(ds)
1982
2.60k
        { }
1983
        ECC_Point_Mul(nlohmann::json json) :
1984
            Operation(json["modifier"]),
1985
            curveType(json["curveType"]),
1986
            a(json["a_x"], json["a_y"]),
1987
            b(json["b"])
1988
0
        { }
1989
1990
377
        static size_t MaxOperations(void) { return 5; }
1991
        std::string Name(void) const override;
1992
        std::string ToString(void) const override;
1993
        nlohmann::json ToJSON(void) const override;
1994
0
        inline bool operator==(const ECC_Point_Mul& rhs) const {
1995
0
            return
1996
0
                (curveType == rhs.curveType) &&
1997
0
                (a == rhs.a) &&
1998
0
                (b == rhs.b) &&
1999
0
                (modifier == rhs.modifier);
2000
0
        }
2001
0
        void Serialize(Datasource& ds) const {
2002
0
            curveType.Serialize(ds);
2003
0
            a.Serialize(ds);
2004
0
            b.Serialize(ds);
2005
0
        }
2006
};
2007
2008
class ECC_Point_Neg : public Operation {
2009
    public:
2010
        const component::CurveType curveType;
2011
        const component::ECC_Point a;
2012
2013
        ECC_Point_Neg(Datasource& ds, component::Modifier modifier) :
2014
            Operation(std::move(modifier)),
2015
            curveType(ds),
2016
            a(ds)
2017
1.83k
        { }
2018
        ECC_Point_Neg(nlohmann::json json) :
2019
            Operation(json["modifier"]),
2020
            curveType(json["curveType"]),
2021
            a(json["a_x"], json["a_y"])
2022
0
        { }
2023
2024
222
        static size_t MaxOperations(void) { return 5; }
2025
        std::string Name(void) const override;
2026
        std::string ToString(void) const override;
2027
        nlohmann::json ToJSON(void) const override;
2028
0
        inline bool operator==(const ECC_Point_Neg& rhs) const {
2029
0
            return
2030
0
                (curveType == rhs.curveType) &&
2031
0
                (a == rhs.a) &&
2032
0
                (modifier == rhs.modifier);
2033
0
        }
2034
0
        void Serialize(Datasource& ds) const {
2035
0
            curveType.Serialize(ds);
2036
0
            a.Serialize(ds);
2037
0
        }
2038
};
2039
2040
class ECC_Point_Dbl : public Operation {
2041
    public:
2042
        const component::CurveType curveType;
2043
        const component::ECC_Point a;
2044
2045
        ECC_Point_Dbl(Datasource& ds, component::Modifier modifier) :
2046
            Operation(std::move(modifier)),
2047
            curveType(ds),
2048
            a(ds)
2049
2.01k
        { }
2050
        ECC_Point_Dbl(nlohmann::json json) :
2051
            Operation(json["modifier"]),
2052
            curveType(json["curveType"]),
2053
            a(json["a_x"], json["a_y"])
2054
0
        { }
2055
2056
240
        static size_t MaxOperations(void) { return 5; }
2057
        std::string Name(void) const override;
2058
        std::string ToString(void) const override;
2059
        nlohmann::json ToJSON(void) const override;
2060
0
        inline bool operator==(const ECC_Point_Dbl& rhs) const {
2061
0
            return
2062
0
                (curveType == rhs.curveType) &&
2063
0
                (a == rhs.a) &&
2064
0
                (modifier == rhs.modifier);
2065
0
        }
2066
0
        void Serialize(Datasource& ds) const {
2067
0
            curveType.Serialize(ds);
2068
0
            a.Serialize(ds);
2069
0
        }
2070
};
2071
2072
class ECC_Point_Cmp : public Operation {
2073
    public:
2074
        const component::CurveType curveType;
2075
        const component::ECC_Point a, b;
2076
2077
        ECC_Point_Cmp(Datasource& ds, component::Modifier modifier) :
2078
            Operation(std::move(modifier)),
2079
            curveType(ds),
2080
            a(ds),
2081
            b(ds)
2082
2.04k
        { }
2083
        ECC_Point_Cmp(nlohmann::json json) :
2084
            Operation(json["modifier"]),
2085
            curveType(json["curveType"]),
2086
            a(json["a_x"], json["a_y"]),
2087
            b(json["b_x"], json["b_y"])
2088
0
        { }
2089
2090
240
        static size_t MaxOperations(void) { return 5; }
2091
        std::string Name(void) const override;
2092
        std::string ToString(void) const override;
2093
        nlohmann::json ToJSON(void) const override;
2094
0
        inline bool operator==(const ECC_Point_Cmp& rhs) const {
2095
0
            return
2096
0
                (curveType == rhs.curveType) &&
2097
0
                (a == rhs.a) &&
2098
0
                (b == rhs.b) &&
2099
0
                (modifier == rhs.modifier);
2100
0
        }
2101
0
        void Serialize(Datasource& ds) const {
2102
0
            curveType.Serialize(ds);
2103
0
            a.Serialize(ds);
2104
0
            b.Serialize(ds);
2105
0
        }
2106
};
2107
2108
class DH_GenerateKeyPair : public Operation {
2109
    public:
2110
        const component::Bignum prime;
2111
        const component::Bignum base;
2112
2113
        DH_GenerateKeyPair(Datasource& ds, component::Modifier modifier) :
2114
            Operation(std::move(modifier)),
2115
            prime(ds),
2116
            base(ds)
2117
2.49k
        { }
2118
        DH_GenerateKeyPair(nlohmann::json json) :
2119
            Operation(json["modifier"]),
2120
            prime(json["prime"]),
2121
            base(json["base"])
2122
0
        { }
2123
        DH_GenerateKeyPair(
2124
                component::Modifier modifier,
2125
                component::Bignum prime,
2126
                component::Bignum base) :
2127
            Operation(std::move(modifier)),
2128
            prime(prime),
2129
            base(base)
2130
0
        { }
2131
2132
198
        static size_t MaxOperations(void) { return 5; }
2133
        std::string Name(void) const override;
2134
        std::string ToString(void) const override;
2135
        nlohmann::json ToJSON(void) const override;
2136
0
        inline bool operator==(const DH_GenerateKeyPair& rhs) const {
2137
0
            return
2138
0
                (prime == rhs.prime) &&
2139
0
                (base  == rhs.base) &&
2140
0
                (modifier == rhs.modifier);
2141
0
        }
2142
0
        void Serialize(Datasource& ds) const {
2143
0
            prime.Serialize(ds);
2144
0
            base.Serialize(ds);
2145
0
        }
2146
};
2147
2148
class DH_Derive : public Operation {
2149
    public:
2150
        const component::Bignum prime;
2151
        const component::Bignum base;
2152
        const component::Bignum pub;
2153
        const component::Bignum priv;
2154
2155
        DH_Derive(Datasource& ds, component::Modifier modifier) :
2156
            Operation(std::move(modifier)),
2157
            prime(ds),
2158
            base(ds),
2159
            pub(ds),
2160
            priv(ds)
2161
3.43k
        { }
2162
        DH_Derive(nlohmann::json json) :
2163
            Operation(json["modifier"]),
2164
            prime(json["prime"]),
2165
            base(json["base"]),
2166
            pub(json["pub"]),
2167
            priv(json["priv"])
2168
0
        { }
2169
        DH_Derive(
2170
                component::Modifier modifier,
2171
                component::Bignum prime,
2172
                component::Bignum base,
2173
                component::Bignum pub,
2174
                component::Bignum priv) :
2175
            Operation(std::move(modifier)),
2176
            prime(prime),
2177
            base(base),
2178
            pub(pub),
2179
            priv(priv)
2180
0
        { }
2181
2182
522
        static size_t MaxOperations(void) { return 5; }
2183
        std::string Name(void) const override;
2184
        std::string ToString(void) const override;
2185
        nlohmann::json ToJSON(void) const override;
2186
0
        inline bool operator==(const DH_Derive& rhs) const {
2187
0
            return
2188
0
                (prime == rhs.prime) &&
2189
0
                (base  == rhs.base) &&
2190
0
                (pub == rhs.pub) &&
2191
0
                (priv == rhs.priv) &&
2192
0
                (modifier == rhs.modifier);
2193
0
        }
2194
0
        void Serialize(Datasource& ds) const {
2195
0
            prime.Serialize(ds);
2196
0
            base.Serialize(ds);
2197
0
            pub.Serialize(ds);
2198
0
            priv.Serialize(ds);
2199
0
        }
2200
};
2201
2202
class BignumCalc : public Operation {
2203
    public:
2204
        const component::CalcOp calcOp;
2205
        const component::Bignum bn0;
2206
        const component::Bignum bn1;
2207
        const component::Bignum bn2;
2208
        const component::Bignum bn3;
2209
        std::optional<component::Bignum> modulo;
2210
2211
        BignumCalc(Datasource& ds, component::Modifier modifier) :
2212
            Operation(std::move(modifier)),
2213
            calcOp(ds),
2214
            bn0(ds),
2215
            bn1(ds),
2216
            bn2(ds),
2217
            bn3(ds)
2218
16.9k
        { }
2219
        BignumCalc(nlohmann::json json) :
2220
            Operation(json["modifier"]),
2221
            calcOp(json["calcOp"]),
2222
            bn0(json["bn1"]),
2223
            bn1(json["bn2"]),
2224
            bn2(json["bn3"]),
2225
            bn3(json["bn4"])
2226
0
        { }
2227
        BignumCalc(
2228
                component::Modifier modifier,
2229
                component::CurveType calcOp,
2230
                component::Bignum bn0,
2231
                component::Bignum bn1,
2232
                component::Bignum bn2,
2233
                component::Bignum bn3) :
2234
            Operation(std::move(modifier)),
2235
            calcOp(calcOp),
2236
            bn0(bn0),
2237
            bn1(bn1),
2238
            bn2(bn2),
2239
            bn3(bn3)
2240
0
        { }
2241
2242
2243
9.97k
        static size_t MaxOperations(void) { return 5; }
2244
        std::string Name(void) const override;
2245
        std::string ToString(void) const override;
2246
        nlohmann::json ToJSON(void) const override;
2247
0
        inline bool operator==(const BignumCalc& rhs) const {
2248
0
            return
2249
0
                (calcOp == rhs.calcOp) &&
2250
0
                (bn0 == rhs.bn0) &&
2251
0
                (bn1 == rhs.bn1) &&
2252
0
                (bn2 == rhs.bn2) &&
2253
0
                (bn3 == rhs.bn3) &&
2254
0
                (modifier == rhs.modifier);
2255
0
        }
2256
0
        void Serialize(Datasource& ds) const {
2257
0
            calcOp.Serialize(ds);
2258
0
            bn0.Serialize(ds);
2259
0
            bn1.Serialize(ds);
2260
0
            bn2.Serialize(ds);
2261
0
            bn3.Serialize(ds);
2262
0
        }
2263
        void SetModulo(component::Bignum& modulo);
2264
};
2265
2266
class BignumCalc_Fp2 : public Operation {
2267
    public:
2268
        const component::CalcOp calcOp;
2269
        const component::Fp2 bn0;
2270
        const component::Fp2 bn1;
2271
        const component::Fp2 bn2;
2272
        const component::Fp2 bn3;
2273
        std::optional<component::Fp2> modulo;
2274
2275
        BignumCalc_Fp2(Datasource& ds, component::Modifier modifier) :
2276
            Operation(std::move(modifier)),
2277
            calcOp(ds),
2278
            bn0(ds),
2279
            bn1(ds),
2280
            bn2(ds),
2281
            bn3(ds)
2282
1.85k
        { }
2283
        BignumCalc_Fp2(nlohmann::json json) :
2284
            Operation(json["modifier"]),
2285
            calcOp(json["calcOp"]),
2286
            bn0(json["bn1"]),
2287
            bn1(json["bn2"]),
2288
            bn2(json["bn3"]),
2289
            bn3(json["bn4"])
2290
0
        { }
2291
        BignumCalc_Fp2(
2292
                component::Modifier modifier,
2293
                component::CurveType calcOp,
2294
                component::Fp2 bn0,
2295
                component::Fp2 bn1,
2296
                component::Fp2 bn2,
2297
                component::Fp2 bn3) :
2298
            Operation(std::move(modifier)),
2299
            calcOp(calcOp),
2300
            bn0(bn0),
2301
            bn1(bn1),
2302
            bn2(bn2),
2303
            bn3(bn3)
2304
0
        { }
2305
2306
2307
198
        static size_t MaxOperations(void) { return 5; }
2308
        std::string Name(void) const override;
2309
        std::string ToString(void) const override;
2310
        nlohmann::json ToJSON(void) const override;
2311
0
        inline bool operator==(const BignumCalc_Fp2& rhs) const {
2312
0
            return
2313
0
                (calcOp == rhs.calcOp) &&
2314
0
                (bn0 == rhs.bn0) &&
2315
0
                (bn1 == rhs.bn1) &&
2316
0
                (bn2 == rhs.bn2) &&
2317
0
                (bn3 == rhs.bn3) &&
2318
0
                (modifier == rhs.modifier);
2319
0
        }
2320
0
        void Serialize(Datasource& ds) const {
2321
0
            calcOp.Serialize(ds);
2322
0
            bn0.Serialize(ds);
2323
0
            bn1.Serialize(ds);
2324
0
            bn2.Serialize(ds);
2325
0
            bn3.Serialize(ds);
2326
0
        }
2327
        void SetModulo(component::Fp2& modulo);
2328
};
2329
2330
class BignumCalc_Fp12 : public Operation {
2331
    public:
2332
        const component::CalcOp calcOp;
2333
        const component::Fp12 bn0;
2334
        const component::Fp12 bn1;
2335
        const component::Fp12 bn2;
2336
        const component::Fp12 bn3;
2337
        std::optional<component::Fp12> modulo;
2338
2339
        BignumCalc_Fp12(Datasource& ds, component::Modifier modifier) :
2340
            Operation(std::move(modifier)),
2341
            calcOp(ds),
2342
            bn0(ds),
2343
            bn1(ds),
2344
            bn2(ds),
2345
            bn3(ds)
2346
2.64k
        { }
2347
        BignumCalc_Fp12(nlohmann::json json) :
2348
            Operation(json["modifier"]),
2349
            calcOp(json["calcOp"]),
2350
            bn0(json["bn1"]),
2351
            bn1(json["bn2"]),
2352
            bn2(json["bn3"]),
2353
            bn3(json["bn4"])
2354
0
        { }
2355
        BignumCalc_Fp12(
2356
                component::Modifier modifier,
2357
                component::CurveType calcOp,
2358
                component::Fp12 bn0,
2359
                component::Fp12 bn1,
2360
                component::Fp12 bn2,
2361
                component::Fp12 bn3) :
2362
            Operation(std::move(modifier)),
2363
            calcOp(calcOp),
2364
            bn0(bn0),
2365
            bn1(bn1),
2366
            bn2(bn2),
2367
            bn3(bn3)
2368
0
        { }
2369
2370
2371
487
        static size_t MaxOperations(void) { return 5; }
2372
        std::string Name(void) const override;
2373
        std::string ToString(void) const override;
2374
        nlohmann::json ToJSON(void) const override;
2375
0
        inline bool operator==(const BignumCalc_Fp12& rhs) const {
2376
0
            return
2377
0
                (calcOp == rhs.calcOp) &&
2378
0
                (bn0 == rhs.bn0) &&
2379
0
                (bn1 == rhs.bn1) &&
2380
0
                (bn2 == rhs.bn2) &&
2381
0
                (bn3 == rhs.bn3) &&
2382
0
                (modifier == rhs.modifier);
2383
0
        }
2384
0
        void Serialize(Datasource& ds) const {
2385
0
            calcOp.Serialize(ds);
2386
0
            bn0.Serialize(ds);
2387
0
            bn1.Serialize(ds);
2388
0
            bn2.Serialize(ds);
2389
0
            bn3.Serialize(ds);
2390
0
        }
2391
        void SetModulo(component::Fp12& modulo);
2392
};
2393
2394
class BLS_PrivateToPublic : public Operation {
2395
    public:
2396
        const component::CurveType curveType;
2397
        const component::BLS_PrivateKey priv;
2398
2399
        BLS_PrivateToPublic(Datasource& ds, component::Modifier modifier) :
2400
            Operation(std::move(modifier)),
2401
            curveType(ds),
2402
            priv(ds)
2403
1.79k
        { }
2404
        BLS_PrivateToPublic(nlohmann::json json) :
2405
            Operation(json["modifier"]),
2406
            curveType(json["curveType"]),
2407
            priv(json["priv"])
2408
0
        { }
2409
2410
165
        static size_t MaxOperations(void) { return 5; }
2411
        std::string Name(void) const override;
2412
        std::string ToString(void) const override;
2413
        nlohmann::json ToJSON(void) const override;
2414
0
        inline bool operator==(const BLS_PrivateToPublic& rhs) const {
2415
0
            return
2416
0
                (curveType == rhs.curveType) &&
2417
0
                (priv == rhs.priv) &&
2418
0
                (modifier == rhs.modifier);
2419
0
        }
2420
0
        void Serialize(Datasource& ds) const {
2421
0
            curveType.Serialize(ds);
2422
0
            priv.Serialize(ds);
2423
0
        }
2424
};
2425
2426
class BLS_PrivateToPublic_G2 : public Operation {
2427
    public:
2428
        const component::CurveType curveType;
2429
        const component::BLS_PrivateKey priv;
2430
2431
        BLS_PrivateToPublic_G2(Datasource& ds, component::Modifier modifier) :
2432
            Operation(std::move(modifier)),
2433
            curveType(ds),
2434
            priv(ds)
2435
1.68k
        { }
2436
        BLS_PrivateToPublic_G2(nlohmann::json json) :
2437
            Operation(json["modifier"]),
2438
            curveType(json["curveType"]),
2439
            priv(json["priv"])
2440
0
        { }
2441
2442
150
        static size_t MaxOperations(void) { return 5; }
2443
        std::string Name(void) const override;
2444
        std::string ToString(void) const override;
2445
        nlohmann::json ToJSON(void) const override;
2446
0
        inline bool operator==(const BLS_PrivateToPublic_G2& rhs) const {
2447
0
            return
2448
0
                (curveType == rhs.curveType) &&
2449
0
                (priv == rhs.priv) &&
2450
0
                (modifier == rhs.modifier);
2451
0
        }
2452
0
        void Serialize(Datasource& ds) const {
2453
0
            curveType.Serialize(ds);
2454
0
            priv.Serialize(ds);
2455
0
        }
2456
};
2457
2458
class BLS_Sign : public Operation {
2459
    public:
2460
        const component::CurveType curveType;
2461
        const component::BLS_PrivateKey priv;
2462
        const bool hashOrPoint;
2463
        const component::G2 point;
2464
        const component::Cleartext cleartext;
2465
        const component::Cleartext dest;
2466
        const component::Cleartext aug;
2467
2468
        BLS_Sign(Datasource& ds, component::Modifier modifier) :
2469
            Operation(std::move(modifier)),
2470
            curveType(ds),
2471
            priv(ds),
2472
            hashOrPoint(ds.Get<bool>()),
2473
            point(ds),
2474
            cleartext(ds),
2475
            dest(ds),
2476
            aug(ds)
2477
2.36k
        { }
2478
        BLS_Sign(nlohmann::json json) :
2479
            Operation(json["modifier"]),
2480
            curveType(json["curveType"]),
2481
            priv(json["priv"]),
2482
            hashOrPoint(json["hashOrPoint"]),
2483
            point(json["point_v"], json["point_w"], json["point_x"], json["point_y"]),
2484
            cleartext(json["cleartext"]),
2485
            dest(json["dest"]),
2486
            aug(json["aug"])
2487
0
        { }
2488
2489
146
        static size_t MaxOperations(void) { return 5; }
2490
        std::string Name(void) const override;
2491
        std::string ToString(void) const override;
2492
        nlohmann::json ToJSON(void) const override;
2493
0
        inline bool operator==(const BLS_Sign& rhs) const {
2494
0
            return
2495
0
                (curveType == rhs.curveType) &&
2496
0
                (priv == rhs.priv) &&
2497
0
                (hashOrPoint == rhs.hashOrPoint) &&
2498
0
                (point == rhs.point) &&
2499
0
                (cleartext == rhs.cleartext) &&
2500
0
                (dest == rhs.dest) &&
2501
0
                (aug == rhs.aug) &&
2502
0
                (modifier == rhs.modifier);
2503
0
        }
2504
0
        void Serialize(Datasource& ds) const {
2505
0
            curveType.Serialize(ds);
2506
0
            priv.Serialize(ds);
2507
0
            ds.Put<bool>(hashOrPoint);
2508
0
            point.Serialize(ds);
2509
0
            cleartext.Serialize(ds);
2510
0
            dest.Serialize(ds);
2511
0
            aug.Serialize(ds);
2512
0
        }
2513
};
2514
2515
class BLS_Verify : public Operation {
2516
    public:
2517
        const component::CurveType curveType;
2518
        const component::BLS_PublicKey pub;
2519
        const bool hashOrPoint;
2520
        const component::G2 point;
2521
        const component::Cleartext cleartext;
2522
        const component::Cleartext dest;
2523
        const component::G2 signature;
2524
2525
        BLS_Verify(Datasource& ds, component::Modifier modifier) :
2526
            Operation(std::move(modifier)),
2527
            curveType(ds),
2528
            pub(ds),
2529
            hashOrPoint(ds.Get<bool>()),
2530
            point(ds),
2531
            cleartext(ds),
2532
            dest(ds),
2533
            signature(ds)
2534
2.53k
        { }
2535
        BLS_Verify(nlohmann::json json) :
2536
            Operation(json["modifier"]),
2537
            curveType(json["curveType"]),
2538
            pub(json["pub_x"], json["pub_y"]),
2539
            hashOrPoint(json["hashOrPoint"]),
2540
            point(json["point_v"], json["point_w"], json["point_x"], json["point_y"]),
2541
            cleartext(json["cleartext"]),
2542
            dest(json["dest"]),
2543
            signature(json["sig_v"], json["sig_w"], json["sig_x"], json["sig_y"])
2544
0
        { }
2545
2546
131
        static size_t MaxOperations(void) { return 5; }
2547
        std::string Name(void) const override;
2548
        std::string ToString(void) const override;
2549
        nlohmann::json ToJSON(void) const override;
2550
0
        inline bool operator==(const BLS_Verify& rhs) const {
2551
0
            return
2552
0
                (curveType == rhs.curveType) &&
2553
0
                (pub == rhs.pub) &&
2554
0
                (hashOrPoint == rhs.hashOrPoint) &&
2555
0
                (point == rhs.point) &&
2556
0
                (cleartext == rhs.cleartext) &&
2557
0
                (dest == rhs.dest) &&
2558
0
                (signature == rhs.signature) &&
2559
0
                (modifier == rhs.modifier);
2560
0
        }
2561
0
        void Serialize(Datasource& ds) const {
2562
0
            curveType.Serialize(ds);
2563
0
            pub.Serialize(ds);
2564
0
            ds.Put<bool>(hashOrPoint);
2565
0
            point.Serialize(ds);
2566
0
            cleartext.Serialize(ds);
2567
0
            dest.Serialize(ds);
2568
0
            signature.Serialize(ds);
2569
0
        }
2570
};
2571
2572
class BLS_BatchSign : public Operation {
2573
    public:
2574
        component::BLS_BatchSign_Vector bf;
2575
2576
        BLS_BatchSign(Datasource& ds, component::Modifier modifier) :
2577
            Operation(std::move(modifier)),
2578
            bf(ds)
2579
2.35k
        { }
2580
        BLS_BatchSign(nlohmann::json json) :
2581
            Operation(json["modifier"]),
2582
            bf(json["bf"])
2583
0
        { }
2584
2585
191
        static size_t MaxOperations(void) { return 5; }
2586
        std::string Name(void) const override;
2587
        std::string ToString(void) const override;
2588
        nlohmann::json ToJSON(void) const override;
2589
0
        inline bool operator==(const BLS_BatchSign& rhs) const {
2590
0
            return
2591
0
                (bf == rhs.bf) &&
2592
0
                (modifier == rhs.modifier);
2593
0
        }
2594
0
        void Serialize(Datasource& ds) const {
2595
0
            bf.Serialize(ds);
2596
0
        }
2597
};
2598
2599
class BLS_BatchVerify : public Operation {
2600
    public:
2601
        component::BLS_BatchVerify_Vector bf;
2602
2603
        BLS_BatchVerify(Datasource& ds, component::Modifier modifier) :
2604
            Operation(std::move(modifier)),
2605
            bf(ds)
2606
1.99k
        { }
2607
        BLS_BatchVerify(nlohmann::json json) :
2608
            Operation(json["modifier"]),
2609
            bf(json["bf"])
2610
0
        { }
2611
2612
198
        static size_t MaxOperations(void) { return 5; }
2613
        std::string Name(void) const override;
2614
        std::string ToString(void) const override;
2615
        nlohmann::json ToJSON(void) const override;
2616
0
        inline bool operator==(const BLS_BatchVerify& rhs) const {
2617
0
            return
2618
0
                (bf == rhs.bf) &&
2619
0
                (modifier == rhs.modifier);
2620
0
        }
2621
0
        void Serialize(Datasource& ds) const {
2622
0
            bf.Serialize(ds);
2623
0
        }
2624
};
2625
2626
class BLS_Aggregate_G1 : public Operation {
2627
    public:
2628
        const component::CurveType curveType;
2629
        component::BLS_G1_Vector points;
2630
2631
        BLS_Aggregate_G1(Datasource& ds, component::Modifier modifier) :
2632
            Operation(std::move(modifier)),
2633
            curveType(ds),
2634
            points(ds)
2635
2.46k
        { }
2636
        BLS_Aggregate_G1(nlohmann::json json) :
2637
            Operation(json["modifier"]),
2638
            curveType(json["curveType"]),
2639
            points(json["points"])
2640
0
        { }
2641
2642
177
        static size_t MaxOperations(void) { return 5; }
2643
        std::string Name(void) const override;
2644
        std::string ToString(void) const override;
2645
        nlohmann::json ToJSON(void) const override;
2646
0
        inline bool operator==(const BLS_Aggregate_G1& rhs) const {
2647
0
            return
2648
0
                (curveType == rhs.curveType) &&
2649
0
                (points == rhs.points) &&
2650
0
                (modifier == rhs.modifier);
2651
0
        }
2652
0
        void Serialize(Datasource& ds) const {
2653
0
            curveType.Serialize(ds);
2654
0
            points.Serialize(ds);
2655
0
        }
2656
};
2657
2658
class BLS_Aggregate_G2 : public Operation {
2659
    public:
2660
        const component::CurveType curveType;
2661
        component::BLS_G2_Vector points;
2662
2663
        BLS_Aggregate_G2(Datasource& ds, component::Modifier modifier) :
2664
            Operation(std::move(modifier)),
2665
            curveType(ds),
2666
            points(ds)
2667
1.90k
        { }
2668
        BLS_Aggregate_G2(nlohmann::json json) :
2669
            Operation(json["modifier"]),
2670
            curveType(json["curveType"]),
2671
            points(json["points"])
2672
0
        { }
2673
2674
155
        static size_t MaxOperations(void) { return 5; }
2675
        std::string Name(void) const override;
2676
        std::string ToString(void) const override;
2677
        nlohmann::json ToJSON(void) const override;
2678
0
        inline bool operator==(const BLS_Aggregate_G2& rhs) const {
2679
0
            return
2680
0
                (curveType == rhs.curveType) &&
2681
0
                (points == rhs.points) &&
2682
0
                (modifier == rhs.modifier);
2683
0
        }
2684
0
        void Serialize(Datasource& ds) const {
2685
0
            curveType.Serialize(ds);
2686
0
            points.Serialize(ds);
2687
0
        }
2688
};
2689
2690
class BLS_Pairing : public Operation {
2691
    public:
2692
        const component::CurveType curveType;
2693
        const component::G1 g1;
2694
        const component::G2 g2;
2695
2696
        BLS_Pairing(Datasource& ds, component::Modifier modifier) :
2697
            Operation(std::move(modifier)),
2698
            curveType(ds),
2699
            g1(ds),
2700
            g2(ds)
2701
2.57k
        { }
2702
        BLS_Pairing(nlohmann::json json) :
2703
            Operation(json["modifier"]),
2704
            curveType(json["curveType"]),
2705
            g1(json["g1_x"], json["g1_y"]),
2706
            g2(json["g2_v"], json["g2_w"], json["g2_x"], json["g2_y"])
2707
0
        { }
2708
2709
141
        static size_t MaxOperations(void) { return 5; }
2710
        std::string Name(void) const override;
2711
        std::string ToString(void) const override;
2712
        nlohmann::json ToJSON(void) const override;
2713
0
        inline bool operator==(const BLS_Pairing& rhs) const {
2714
0
            return
2715
0
                (curveType == rhs.curveType) &&
2716
0
                (g1 == rhs.g1) &&
2717
0
                (g2 == rhs.g2) &&
2718
0
                (modifier == rhs.modifier);
2719
0
        }
2720
0
        void Serialize(Datasource& ds) const {
2721
0
            curveType.Serialize(ds);
2722
0
            g1.Serialize(ds);
2723
0
            g2.Serialize(ds);
2724
0
        }
2725
};
2726
2727
class BLS_MillerLoop : public Operation {
2728
    public:
2729
        const component::CurveType curveType;
2730
        const component::G1 g1;
2731
        const component::G2 g2;
2732
2733
        BLS_MillerLoop(Datasource& ds, component::Modifier modifier) :
2734
            Operation(std::move(modifier)),
2735
            curveType(ds),
2736
            g1(ds),
2737
            g2(ds)
2738
2.65k
        { }
2739
        BLS_MillerLoop(nlohmann::json json) :
2740
            Operation(json["modifier"]),
2741
            curveType(json["curveType"]),
2742
            g1(json["g1_x"], json["g1_y"]),
2743
            g2(json["g2_v"], json["g2_w"], json["g2_x"], json["g2_y"])
2744
0
        { }
2745
2746
155
        static size_t MaxOperations(void) { return 5; }
2747
        std::string Name(void) const override;
2748
        std::string ToString(void) const override;
2749
        nlohmann::json ToJSON(void) const override;
2750
0
        inline bool operator==(const BLS_MillerLoop& rhs) const {
2751
0
            return
2752
0
                (curveType == rhs.curveType) &&
2753
0
                (g1 == rhs.g1) &&
2754
0
                (g2 == rhs.g2) &&
2755
0
                (modifier == rhs.modifier);
2756
0
        }
2757
0
        void Serialize(Datasource& ds) const {
2758
0
            curveType.Serialize(ds);
2759
0
            g1.Serialize(ds);
2760
0
            g2.Serialize(ds);
2761
0
        }
2762
};
2763
2764
class BLS_FinalExp : public Operation {
2765
    public:
2766
        const component::CurveType curveType;
2767
        const component::Fp12 fp12;
2768
2769
        BLS_FinalExp(Datasource& ds, component::Modifier modifier) :
2770
            Operation(std::move(modifier)),
2771
            curveType(ds),
2772
            fp12(ds)
2773
2.21k
        { }
2774
        BLS_FinalExp(nlohmann::json json) :
2775
            Operation(json["modifier"]),
2776
            curveType(json["curveType"]),
2777
            fp12(json["fp12"])
2778
0
        { }
2779
2780
237
        static size_t MaxOperations(void) { return 5; }
2781
        std::string Name(void) const override;
2782
        std::string ToString(void) const override;
2783
        nlohmann::json ToJSON(void) const override;
2784
0
        inline bool operator==(const BLS_FinalExp& rhs) const {
2785
0
            return
2786
0
                (curveType == rhs.curveType) &&
2787
0
                (fp12 == rhs.fp12) &&
2788
0
                (modifier == rhs.modifier);
2789
0
        }
2790
0
        void Serialize(Datasource& ds) const {
2791
0
            curveType.Serialize(ds);
2792
0
            fp12.Serialize(ds);
2793
0
        }
2794
};
2795
2796
class BLS_HashToG1 : public Operation {
2797
    public:
2798
        const component::CurveType curveType;
2799
        const component::Cleartext cleartext;
2800
        const component::Cleartext dest;
2801
        const component::Cleartext aug;
2802
2803
        BLS_HashToG1(Datasource& ds, component::Modifier modifier) :
2804
            Operation(std::move(modifier)),
2805
            curveType(ds),
2806
            cleartext(ds),
2807
            dest(ds),
2808
            aug(ds)
2809
2.88k
        { }
2810
        BLS_HashToG1(const component::CurveType curveType, const component::Cleartext cleartext, const component::Cleartext dest, const component::Cleartext aug, component::Modifier modifier) :
2811
            Operation(std::move(modifier)),
2812
            curveType(curveType),
2813
            cleartext(cleartext),
2814
            dest(dest),
2815
            aug(aug)
2816
0
        { }
2817
        BLS_HashToG1(nlohmann::json json) :
2818
            Operation(json["modifier"]),
2819
            curveType(json["curveType"]),
2820
            cleartext(json["cleartext"]),
2821
            dest(json["dest"]),
2822
            aug(json["aug"])
2823
0
        { }
2824
2825
179
        static size_t MaxOperations(void) { return 5; }
2826
        std::string Name(void) const override;
2827
        std::string ToString(void) const override;
2828
        nlohmann::json ToJSON(void) const override;
2829
0
        inline bool operator==(const BLS_HashToG1& rhs) const {
2830
0
            return
2831
0
                (curveType == rhs.curveType) &&
2832
0
                (cleartext == rhs.cleartext) &&
2833
0
                (dest == rhs.dest) &&
2834
0
                (aug == rhs.aug) &&
2835
0
                (modifier == rhs.modifier);
2836
0
        }
2837
0
        void Serialize(Datasource& ds) const {
2838
0
            curveType.Serialize(ds);
2839
0
            cleartext.Serialize(ds);
2840
0
            dest.Serialize(ds);
2841
0
            aug.Serialize(ds);
2842
0
        }
2843
};
2844
2845
class BLS_HashToG2 : public Operation {
2846
    public:
2847
        const component::CurveType curveType;
2848
        const component::Cleartext cleartext;
2849
        const component::Cleartext dest;
2850
        const component::Cleartext aug;
2851
2852
        BLS_HashToG2(Datasource& ds, component::Modifier modifier) :
2853
            Operation(std::move(modifier)),
2854
            curveType(ds),
2855
            cleartext(ds),
2856
            dest(ds),
2857
            aug(ds)
2858
2.68k
        { }
2859
        BLS_HashToG2(const component::CurveType curveType, const component::Cleartext cleartext, const component::Cleartext dest, const component::Cleartext aug, component::Modifier modifier) :
2860
            Operation(std::move(modifier)),
2861
            curveType(curveType),
2862
            cleartext(cleartext),
2863
            dest(dest),
2864
            aug(aug)
2865
0
        { }
2866
        BLS_HashToG2(nlohmann::json json) :
2867
            Operation(json["modifier"]),
2868
            curveType(json["curveType"]),
2869
            cleartext(json["cleartext"]),
2870
            dest(json["dest"]),
2871
            aug(json["aug"])
2872
0
        { }
2873
2874
128
        static size_t MaxOperations(void) { return 5; }
2875
        std::string Name(void) const override;
2876
        std::string ToString(void) const override;
2877
        nlohmann::json ToJSON(void) const override;
2878
0
        inline bool operator==(const BLS_HashToG2& rhs) const {
2879
0
            return
2880
0
                (curveType == rhs.curveType) &&
2881
0
                (cleartext == rhs.cleartext) &&
2882
0
                (dest == rhs.dest) &&
2883
0
                (aug == rhs.aug) &&
2884
0
                (modifier == rhs.modifier);
2885
0
        }
2886
0
        void Serialize(Datasource& ds) const {
2887
0
            curveType.Serialize(ds);
2888
0
            cleartext.Serialize(ds);
2889
0
            dest.Serialize(ds);
2890
0
            aug.Serialize(ds);
2891
0
        }
2892
};
2893
2894
class BLS_MapToG1 : public Operation {
2895
    public:
2896
        const component::CurveType curveType;
2897
        const component::Bignum u;
2898
        const component::Bignum v;
2899
2900
        BLS_MapToG1(Datasource& ds, component::Modifier modifier) :
2901
            Operation(std::move(modifier)),
2902
            curveType(ds),
2903
            u(ds),
2904
            v(ds)
2905
2.28k
        { }
2906
        BLS_MapToG1(const component::CurveType curveType, const component::Bignum u, const component::Bignum v, component::Modifier modifier) :
2907
            Operation(std::move(modifier)),
2908
            curveType(curveType),
2909
            u(u),
2910
            v(v)
2911
0
        { }
2912
        BLS_MapToG1(nlohmann::json json) :
2913
            Operation(json["modifier"]),
2914
            curveType(json["curveType"]),
2915
            u(json["u"]),
2916
            v(json["v"])
2917
0
        { }
2918
2919
155
        static size_t MaxOperations(void) { return 5; }
2920
        std::string Name(void) const override;
2921
        std::string ToString(void) const override;
2922
        nlohmann::json ToJSON(void) const override;
2923
0
        inline bool operator==(const BLS_MapToG1& rhs) const {
2924
0
            return
2925
0
                (curveType == rhs.curveType) &&
2926
0
                (u == rhs.u) &&
2927
0
                (v == rhs.v) &&
2928
0
                (modifier == rhs.modifier);
2929
0
        }
2930
0
        void Serialize(Datasource& ds) const {
2931
0
            curveType.Serialize(ds);
2932
0
            u.Serialize(ds);
2933
0
            v.Serialize(ds);
2934
0
        }
2935
};
2936
2937
class BLS_MapToG2 : public Operation {
2938
    public:
2939
        const component::CurveType curveType;
2940
        const component::Fp2 u;
2941
        const component::Fp2 v;
2942
2943
        BLS_MapToG2(Datasource& ds, component::Modifier modifier) :
2944
            Operation(std::move(modifier)),
2945
            curveType(ds),
2946
            u(ds),
2947
            v(ds)
2948
2.14k
        { }
2949
        BLS_MapToG2(const component::CurveType curveType, const component::Fp2 u, const component::Fp2 v, component::Modifier modifier) :
2950
            Operation(std::move(modifier)),
2951
            curveType(curveType),
2952
            u(u),
2953
            v(v)
2954
0
        { }
2955
        BLS_MapToG2(nlohmann::json json) :
2956
            Operation(json["modifier"]),
2957
            curveType(json["curveType"]),
2958
            u(json["u"]),
2959
            v(json["v"])
2960
0
        { }
2961
2962
141
        static size_t MaxOperations(void) { return 5; }
2963
        std::string Name(void) const override;
2964
        std::string ToString(void) const override;
2965
        nlohmann::json ToJSON(void) const override;
2966
0
        inline bool operator==(const BLS_MapToG2& rhs) const {
2967
0
            return
2968
0
                (curveType == rhs.curveType) &&
2969
0
                (u == rhs.u) &&
2970
0
                (v == rhs.v) &&
2971
0
                (modifier == rhs.modifier);
2972
0
        }
2973
0
        void Serialize(Datasource& ds) const {
2974
0
            curveType.Serialize(ds);
2975
0
            u.Serialize(ds);
2976
0
            v.Serialize(ds);
2977
0
        }
2978
};
2979
2980
class BLS_IsG1OnCurve : public Operation {
2981
    public:
2982
        const component::CurveType curveType;
2983
        const component::G1 g1;
2984
2985
        BLS_IsG1OnCurve(Datasource& ds, component::Modifier modifier) :
2986
            Operation(std::move(modifier)),
2987
            curveType(ds),
2988
            g1(ds)
2989
1.99k
        { }
2990
        BLS_IsG1OnCurve(nlohmann::json json) :
2991
            Operation(json["modifier"]),
2992
            curveType(json["curveType"]),
2993
            g1(json["g1_x"], json["g1_y"])
2994
0
        { }
2995
2996
151
        static size_t MaxOperations(void) { return 5; }
2997
        std::string Name(void) const override;
2998
        std::string ToString(void) const override;
2999
        nlohmann::json ToJSON(void) const override;
3000
0
        inline bool operator==(const BLS_IsG1OnCurve& rhs) const {
3001
0
            return
3002
0
                (curveType == rhs.curveType) &&
3003
0
                (g1 == rhs.g1) &&
3004
0
                (modifier == rhs.modifier);
3005
0
        }
3006
0
        void Serialize(Datasource& ds) const {
3007
0
            curveType.Serialize(ds);
3008
0
            g1.Serialize(ds);
3009
0
        }
3010
};
3011
3012
class BLS_IsG2OnCurve : public Operation {
3013
    public:
3014
        const component::CurveType curveType;
3015
        const component::G2 g2;
3016
3017
        BLS_IsG2OnCurve(Datasource& ds, component::Modifier modifier) :
3018
            Operation(std::move(modifier)),
3019
            curveType(ds),
3020
            g2(ds)
3021
1.86k
        { }
3022
        BLS_IsG2OnCurve(nlohmann::json json) :
3023
            Operation(json["modifier"]),
3024
            curveType(json["curveType"]),
3025
            g2(json["g2_v"], json["g2_w"], json["g2_x"], json["g2_y"])
3026
0
        { }
3027
3028
185
        static size_t MaxOperations(void) { return 5; }
3029
        std::string Name(void) const override;
3030
        std::string ToString(void) const override;
3031
        nlohmann::json ToJSON(void) const override;
3032
0
        inline bool operator==(const BLS_IsG2OnCurve& rhs) const {
3033
0
            return
3034
0
                (curveType == rhs.curveType) &&
3035
0
                (g2 == rhs.g2) &&
3036
0
                (modifier == rhs.modifier);
3037
0
        }
3038
0
        void Serialize(Datasource& ds) const {
3039
0
            curveType.Serialize(ds);
3040
0
            g2.Serialize(ds);
3041
0
        }
3042
};
3043
3044
class BLS_GenerateKeyPair : public Operation {
3045
    public:
3046
        const component::CurveType curveType;
3047
        const component::Cleartext ikm;
3048
        const component::Cleartext info;
3049
3050
        BLS_GenerateKeyPair(Datasource& ds, component::Modifier modifier) :
3051
            Operation(std::move(modifier)),
3052
            curveType(ds),
3053
            ikm(ds),
3054
            info(ds)
3055
2.24k
        { }
3056
3057
        BLS_GenerateKeyPair(nlohmann::json json) :
3058
            Operation(json["modifier"]),
3059
            curveType(json["curveType"]),
3060
            ikm(json["ikm"]),
3061
            info(json["info"])
3062
0
        { }
3063
3064
139
        static size_t MaxOperations(void) { return 5; }
3065
        std::string Name(void) const override;
3066
        std::string ToString(void) const override;
3067
        nlohmann::json ToJSON(void) const override;
3068
0
        inline bool operator==(const BLS_GenerateKeyPair& rhs) const {
3069
0
            return
3070
0
                (curveType == rhs.curveType) &&
3071
0
                (ikm == rhs.ikm) &&
3072
0
                (info == rhs.info) &&
3073
0
                (modifier == rhs.modifier);
3074
0
        }
3075
0
        void Serialize(Datasource& ds) const {
3076
0
            curveType.Serialize(ds);
3077
0
            ikm.Serialize(ds);
3078
0
            info.Serialize(ds);
3079
0
        }
3080
};
3081
3082
class BLS_Decompress_G1 : public Operation {
3083
    public:
3084
        const component::CurveType curveType;
3085
        const component::Bignum compressed;
3086
3087
        BLS_Decompress_G1(Datasource& ds, component::Modifier modifier) :
3088
            Operation(std::move(modifier)),
3089
            curveType(ds),
3090
            compressed(ds)
3091
1.65k
        { }
3092
        BLS_Decompress_G1(nlohmann::json json) :
3093
            Operation(json["modifier"]),
3094
            curveType(json["curveType"]),
3095
            compressed(json["compressed"])
3096
0
        { }
3097
3098
150
        static size_t MaxOperations(void) { return 5; }
3099
        std::string Name(void) const override;
3100
        std::string ToString(void) const override;
3101
        nlohmann::json ToJSON(void) const override;
3102
0
        inline bool operator==(const BLS_Decompress_G1& rhs) const {
3103
0
            return
3104
0
                (curveType == rhs.curveType) &&
3105
0
                (compressed == rhs.compressed) &&
3106
0
                (modifier == rhs.modifier);
3107
0
        }
3108
0
        void Serialize(Datasource& ds) const {
3109
0
            curveType.Serialize(ds);
3110
0
            compressed.Serialize(ds);
3111
0
        }
3112
};
3113
3114
class BLS_Compress_G1 : public Operation {
3115
    public:
3116
        const component::CurveType curveType;
3117
        const component::G1 uncompressed;
3118
3119
        BLS_Compress_G1(Datasource& ds, component::Modifier modifier) :
3120
            Operation(std::move(modifier)),
3121
            curveType(ds),
3122
            uncompressed(ds)
3123
1.93k
        { }
3124
        BLS_Compress_G1(nlohmann::json json) :
3125
            Operation(json["modifier"]),
3126
            curveType(json["curveType"]),
3127
            uncompressed(json["g1_x"], json["g1_y"])
3128
0
        { }
3129
3130
157
        static size_t MaxOperations(void) { return 5; }
3131
        std::string Name(void) const override;
3132
        std::string ToString(void) const override;
3133
        nlohmann::json ToJSON(void) const override;
3134
0
        inline bool operator==(const BLS_Compress_G1& rhs) const {
3135
0
            return
3136
0
                (curveType == rhs.curveType) &&
3137
0
                (uncompressed == rhs.uncompressed) &&
3138
0
                (modifier == rhs.modifier);
3139
0
        }
3140
0
        void Serialize(Datasource& ds) const {
3141
0
            curveType.Serialize(ds);
3142
0
            uncompressed.Serialize(ds);
3143
0
        }
3144
};
3145
3146
class BLS_Decompress_G2 : public Operation {
3147
    public:
3148
        const component::CurveType curveType;
3149
        const component::G1 compressed;
3150
3151
        BLS_Decompress_G2(Datasource& ds, component::Modifier modifier) :
3152
            Operation(std::move(modifier)),
3153
            curveType(ds),
3154
            compressed(ds)
3155
1.76k
        { }
3156
        BLS_Decompress_G2(nlohmann::json json) :
3157
            Operation(json["modifier"]),
3158
            curveType(json["curveType"]),
3159
            compressed(json["g1_x"], json["g1_y"])
3160
0
        { }
3161
3162
135
        static size_t MaxOperations(void) { return 5; }
3163
        std::string Name(void) const override;
3164
        std::string ToString(void) const override;
3165
        nlohmann::json ToJSON(void) const override;
3166
0
        inline bool operator==(const BLS_Decompress_G2& rhs) const {
3167
0
            return
3168
0
                (curveType == rhs.curveType) &&
3169
0
                (compressed == rhs.compressed) &&
3170
0
                (modifier == rhs.modifier);
3171
0
        }
3172
0
        void Serialize(Datasource& ds) const {
3173
0
            curveType.Serialize(ds);
3174
0
            compressed.Serialize(ds);
3175
0
        }
3176
};
3177
3178
class BLS_Compress_G2 : public Operation {
3179
    public:
3180
        const component::CurveType curveType;
3181
        const component::G2 uncompressed;
3182
3183
        BLS_Compress_G2(Datasource& ds, component::Modifier modifier) :
3184
            Operation(std::move(modifier)),
3185
            curveType(ds),
3186
            uncompressed(ds)
3187
2.17k
        { }
3188
        BLS_Compress_G2(nlohmann::json json) :
3189
            Operation(json["modifier"]),
3190
            curveType(json["curveType"]),
3191
            uncompressed(json["g2_v"], json["g2_w"], json["g2_x"], json["g2_y"])
3192
0
        { }
3193
3194
167
        static size_t MaxOperations(void) { return 5; }
3195
        std::string Name(void) const override;
3196
        std::string ToString(void) const override;
3197
        nlohmann::json ToJSON(void) const override;
3198
0
        inline bool operator==(const BLS_Compress_G2& rhs) const {
3199
0
            return
3200
0
                (curveType == rhs.curveType) &&
3201
0
                (uncompressed == rhs.uncompressed) &&
3202
0
                (modifier == rhs.modifier);
3203
0
        }
3204
0
        void Serialize(Datasource& ds) const {
3205
0
            curveType.Serialize(ds);
3206
0
            uncompressed.Serialize(ds);
3207
0
        }
3208
};
3209
3210
class BLS_G1_Add : public Operation {
3211
    public:
3212
        const component::CurveType curveType;
3213
        const component::G1 a, b;
3214
3215
        BLS_G1_Add(Datasource& ds, component::Modifier modifier) :
3216
            Operation(std::move(modifier)),
3217
            curveType(ds),
3218
            a(ds),
3219
            b(ds)
3220
2.30k
        { }
3221
        BLS_G1_Add(nlohmann::json json) :
3222
            Operation(json["modifier"]),
3223
            curveType(json["curveType"]),
3224
            a(json["a_x"], json["a_y"]),
3225
            b(json["b_x"], json["b_y"])
3226
0
        { }
3227
3228
203
        static size_t MaxOperations(void) { return 5; }
3229
        std::string Name(void) const override;
3230
        std::string ToString(void) const override;
3231
        nlohmann::json ToJSON(void) const override;
3232
0
        inline bool operator==(const BLS_G1_Add& rhs) const {
3233
0
            return
3234
0
                (curveType == rhs.curveType) &&
3235
0
                (a == rhs.a) &&
3236
0
                (b == rhs.b) &&
3237
0
                (modifier == rhs.modifier);
3238
0
        }
3239
0
        void Serialize(Datasource& ds) const {
3240
0
            curveType.Serialize(ds);
3241
0
            a.Serialize(ds);
3242
0
            b.Serialize(ds);
3243
0
        }
3244
};
3245
3246
class BLS_G1_IsEq : public Operation {
3247
    public:
3248
        const component::CurveType curveType;
3249
        const component::G1 a, b;
3250
3251
        BLS_G1_IsEq(Datasource& ds, component::Modifier modifier) :
3252
            Operation(std::move(modifier)),
3253
            curveType(ds),
3254
            a(ds),
3255
            b(ds)
3256
2.06k
        { }
3257
        BLS_G1_IsEq(nlohmann::json json) :
3258
            Operation(json["modifier"]),
3259
            curveType(json["curveType"]),
3260
            a(json["a_x"], json["a_y"]),
3261
            b(json["b_x"], json["b_y"])
3262
0
        { }
3263
3264
186
        static size_t MaxOperations(void) { return 5; }
3265
        std::string Name(void) const override;
3266
        std::string ToString(void) const override;
3267
        nlohmann::json ToJSON(void) const override;
3268
0
        inline bool operator==(const BLS_G1_IsEq& rhs) const {
3269
0
            return
3270
0
                (curveType == rhs.curveType) &&
3271
0
                (a == rhs.a) &&
3272
0
                (b == rhs.b) &&
3273
0
                (modifier == rhs.modifier);
3274
0
        }
3275
0
        void Serialize(Datasource& ds) const {
3276
0
            curveType.Serialize(ds);
3277
0
            a.Serialize(ds);
3278
0
            b.Serialize(ds);
3279
0
        }
3280
};
3281
3282
class BLS_G1_Mul : public Operation {
3283
    public:
3284
        const component::CurveType curveType;
3285
        const component::G1 a;
3286
        const component::Bignum b;
3287
3288
        BLS_G1_Mul(Datasource& ds, component::Modifier modifier) :
3289
            Operation(std::move(modifier)),
3290
            curveType(ds),
3291
            a(ds),
3292
            b(ds)
3293
2.89k
        { }
3294
        BLS_G1_Mul(nlohmann::json json) :
3295
            Operation(json["modifier"]),
3296
            curveType(json["curveType"]),
3297
            a(json["a_x"], json["a_y"]),
3298
            b(json["b"])
3299
0
        { }
3300
3301
158
        static size_t MaxOperations(void) { return 5; }
3302
        std::string Name(void) const override;
3303
        std::string ToString(void) const override;
3304
        nlohmann::json ToJSON(void) const override;
3305
0
        inline bool operator==(const BLS_G1_Mul& rhs) const {
3306
0
            return
3307
0
                (curveType == rhs.curveType) &&
3308
0
                (a == rhs.a) &&
3309
0
                (b == rhs.b) &&
3310
0
                (modifier == rhs.modifier);
3311
0
        }
3312
0
        void Serialize(Datasource& ds) const {
3313
0
            curveType.Serialize(ds);
3314
0
            a.Serialize(ds);
3315
0
            b.Serialize(ds);
3316
0
        }
3317
};
3318
3319
class BLS_G1_Neg : public Operation {
3320
    public:
3321
        const component::CurveType curveType;
3322
        const component::G1 a;
3323
3324
        BLS_G1_Neg(Datasource& ds, component::Modifier modifier) :
3325
            Operation(std::move(modifier)),
3326
            curveType(ds),
3327
            a(ds)
3328
1.71k
        { }
3329
        BLS_G1_Neg(nlohmann::json json) :
3330
            Operation(json["modifier"]),
3331
            curveType(json["curveType"]),
3332
            a(json["a_x"], json["a_y"])
3333
0
        { }
3334
3335
158
        static size_t MaxOperations(void) { return 5; }
3336
        std::string Name(void) const override;
3337
        std::string ToString(void) const override;
3338
        nlohmann::json ToJSON(void) const override;
3339
0
        inline bool operator==(const BLS_G1_Neg& rhs) const {
3340
0
            return
3341
0
                (curveType == rhs.curveType) &&
3342
0
                (a == rhs.a) &&
3343
0
                (modifier == rhs.modifier);
3344
0
        }
3345
0
        void Serialize(Datasource& ds) const {
3346
0
            curveType.Serialize(ds);
3347
0
            a.Serialize(ds);
3348
0
        }
3349
};
3350
3351
class BLS_G2_Add : public Operation {
3352
    public:
3353
        const component::CurveType curveType;
3354
        const component::G2 a, b;
3355
3356
        BLS_G2_Add(Datasource& ds, component::Modifier modifier) :
3357
            Operation(std::move(modifier)),
3358
            curveType(ds),
3359
            a(ds),
3360
            b(ds)
3361
2.66k
        { }
3362
        BLS_G2_Add(nlohmann::json json) :
3363
            Operation(json["modifier"]),
3364
            curveType(json["curveType"]),
3365
            a(json["a_v"], json["a_w"], json["a_x"], json["a_y"]),
3366
            b(json["b_v"], json["b_w"], json["b_x"], json["b_y"])
3367
0
        { }
3368
3369
211
        static size_t MaxOperations(void) { return 5; }
3370
        std::string Name(void) const override;
3371
        std::string ToString(void) const override;
3372
        nlohmann::json ToJSON(void) const override;
3373
0
        inline bool operator==(const BLS_G2_Add& rhs) const {
3374
0
            return
3375
0
                (curveType == rhs.curveType) &&
3376
0
                (a == rhs.a) &&
3377
0
                (b == rhs.b) &&
3378
0
                (modifier == rhs.modifier);
3379
0
        }
3380
0
        void Serialize(Datasource& ds) const {
3381
0
            curveType.Serialize(ds);
3382
0
            a.Serialize(ds);
3383
0
            b.Serialize(ds);
3384
0
        }
3385
};
3386
3387
class BLS_G2_IsEq : public Operation {
3388
    public:
3389
        const component::CurveType curveType;
3390
        const component::G2 a, b;
3391
3392
        BLS_G2_IsEq(Datasource& ds, component::Modifier modifier) :
3393
            Operation(std::move(modifier)),
3394
            curveType(ds),
3395
            a(ds),
3396
            b(ds)
3397
2.54k
        { }
3398
        BLS_G2_IsEq(nlohmann::json json) :
3399
            Operation(json["modifier"]),
3400
            curveType(json["curveType"]),
3401
            a(json["a_v"], json["a_w"], json["a_x"], json["a_y"]),
3402
            b(json["b_v"], json["b_w"], json["b_x"], json["b_y"])
3403
0
        { }
3404
3405
198
        static size_t MaxOperations(void) { return 5; }
3406
        std::string Name(void) const override;
3407
        std::string ToString(void) const override;
3408
        nlohmann::json ToJSON(void) const override;
3409
0
        inline bool operator==(const BLS_G2_IsEq& rhs) const {
3410
0
            return
3411
0
                (curveType == rhs.curveType) &&
3412
0
                (a == rhs.a) &&
3413
0
                (b == rhs.b) &&
3414
0
                (modifier == rhs.modifier);
3415
0
        }
3416
0
        void Serialize(Datasource& ds) const {
3417
0
            curveType.Serialize(ds);
3418
0
            a.Serialize(ds);
3419
0
            b.Serialize(ds);
3420
0
        }
3421
};
3422
3423
class BLS_G2_Mul : public Operation {
3424
    public:
3425
        const component::CurveType curveType;
3426
        const component::G2 a;
3427
        const component::Bignum b;
3428
3429
        BLS_G2_Mul(Datasource& ds, component::Modifier modifier) :
3430
            Operation(std::move(modifier)),
3431
            curveType(ds),
3432
            a(ds),
3433
            b(ds)
3434
2.40k
        { }
3435
        BLS_G2_Mul(nlohmann::json json) :
3436
            Operation(json["modifier"]),
3437
            curveType(json["curveType"]),
3438
            a(json["a_v"], json["a_w"], json["a_x"], json["a_y"]),
3439
            b(json["b"])
3440
0
        { }
3441
3442
237
        static size_t MaxOperations(void) { return 5; }
3443
        std::string Name(void) const override;
3444
        std::string ToString(void) const override;
3445
        nlohmann::json ToJSON(void) const override;
3446
0
        inline bool operator==(const BLS_G2_Mul& rhs) const {
3447
0
            return
3448
0
                (curveType == rhs.curveType) &&
3449
0
                (a == rhs.a) &&
3450
0
                (b == rhs.b) &&
3451
0
                (modifier == rhs.modifier);
3452
0
        }
3453
0
        void Serialize(Datasource& ds) const {
3454
0
            curveType.Serialize(ds);
3455
0
            a.Serialize(ds);
3456
0
            b.Serialize(ds);
3457
0
        }
3458
};
3459
3460
class BLS_G2_Neg : public Operation {
3461
    public:
3462
        const component::CurveType curveType;
3463
        const component::G2 a;
3464
3465
        BLS_G2_Neg(Datasource& ds, component::Modifier modifier) :
3466
            Operation(std::move(modifier)),
3467
            curveType(ds),
3468
            a(ds)
3469
2.41k
        { }
3470
        BLS_G2_Neg(nlohmann::json json) :
3471
            Operation(json["modifier"]),
3472
            curveType(json["curveType"]),
3473
            a(json["a_v"], json["a_w"], json["a_x"], json["a_y"])
3474
0
        { }
3475
3476
193
        static size_t MaxOperations(void) { return 5; }
3477
        std::string Name(void) const override;
3478
        std::string ToString(void) const override;
3479
        nlohmann::json ToJSON(void) const override;
3480
0
        inline bool operator==(const BLS_G2_Neg& rhs) const {
3481
0
            return
3482
0
                (curveType == rhs.curveType) &&
3483
0
                (a == rhs.a) &&
3484
0
                (modifier == rhs.modifier);
3485
0
        }
3486
0
        void Serialize(Datasource& ds) const {
3487
0
            curveType.Serialize(ds);
3488
0
            a.Serialize(ds);
3489
0
        }
3490
};
3491
3492
class BLS_G1_MultiExp : public Operation {
3493
    public:
3494
        const component::CurveType curveType;
3495
        component::BLS_G1_Scalar_Vector points_scalars;
3496
3497
        BLS_G1_MultiExp(Datasource& ds, component::Modifier modifier) :
3498
            Operation(std::move(modifier)),
3499
            curveType(ds),
3500
            points_scalars(ds)
3501
2.04k
        { }
3502
        BLS_G1_MultiExp(nlohmann::json json) :
3503
            Operation(json["modifier"]),
3504
            curveType(json["curveType"]),
3505
            points_scalars(json["points_scalars"])
3506
0
        { }
3507
3508
237
        static size_t MaxOperations(void) { return 5; }
3509
        std::string Name(void) const override;
3510
        std::string ToString(void) const override;
3511
        nlohmann::json ToJSON(void) const override;
3512
0
        inline bool operator==(const BLS_G1_MultiExp& rhs) const {
3513
0
            return
3514
0
                (curveType == rhs.curveType) &&
3515
0
                (points_scalars == rhs.points_scalars) &&
3516
0
                (modifier == rhs.modifier);
3517
0
        }
3518
0
        void Serialize(Datasource& ds) const {
3519
0
            curveType.Serialize(ds);
3520
0
            points_scalars.Serialize(ds);
3521
0
        }
3522
};
3523
3524
class Misc : public Operation {
3525
    public:
3526
        const Type operation;
3527
3528
        Misc(Datasource& ds, component::Modifier modifier) :
3529
            Operation(std::move(modifier)),
3530
            operation(ds)
3531
1.67k
        { }
3532
3533
        Misc(nlohmann::json json) :
3534
            Operation(json["modifier"]),
3535
            operation(json["operation"])
3536
0
        { }
3537
3538
156
        static size_t MaxOperations(void) { return 5; }
3539
        std::string Name(void) const override;
3540
        std::string ToString(void) const override;
3541
        nlohmann::json ToJSON(void) const override;
3542
0
        inline bool operator==(const Misc& rhs) const {
3543
0
            return
3544
0
                (operation == rhs.operation) &&
3545
0
                (modifier == rhs.modifier);
3546
0
        }
3547
0
        void Serialize(Datasource& ds) const {
3548
0
            operation.Serialize(ds);
3549
0
        }
3550
};
3551
3552
class SR25519_Verify : public Operation {
3553
    public:
3554
        const component::Cleartext cleartext;
3555
        const component::SR25519_Signature signature;
3556
3557
        SR25519_Verify(Datasource& ds, component::Modifier modifier) :
3558
            Operation(std::move(modifier)),
3559
            cleartext(ds),
3560
            signature(ds)
3561
2.57k
        { }
3562
        SR25519_Verify(nlohmann::json json) :
3563
            Operation(json["modifier"]),
3564
            cleartext(json["cleartext"]),
3565
            signature(json["signature"])
3566
0
        { }
3567
3568
154
        static size_t MaxOperations(void) { return 5; }
3569
        std::string Name(void) const override;
3570
        std::string ToString(void) const override;
3571
        nlohmann::json ToJSON(void) const override;
3572
0
        inline bool operator==(const SR25519_Verify& rhs) const {
3573
0
            return
3574
0
                (cleartext == rhs.cleartext) &&
3575
0
                (signature == rhs.signature) &&
3576
0
                (modifier == rhs.modifier);
3577
0
        }
3578
0
        void Serialize(Datasource& ds) const {
3579
0
            cleartext.Serialize(ds);
3580
0
            signature.Serialize(ds);
3581
0
        }
3582
};
3583
3584
} /* namespace operation */
3585
} /* namespace cryptofuzz */