Coverage Report

Created: 2023-09-25 06:34

/src/cryptofuzz/operation.cpp
Line
Count
Source (jump to first uncovered line)
1
#include <cryptofuzz/operations.h>
2
#include <cryptofuzz/util.h>
3
#include <cryptofuzz/repository.h>
4
#include <sstream>
5
6
namespace cryptofuzz {
7
namespace operation {
8
9
0
std::string Digest::Name(void) const { return "Digest"; }
10
0
std::string Digest::ToString(void) const {
11
0
    std::stringstream ss;
12
13
0
    ss << "operation name: Digest" << std::endl;
14
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
15
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
16
17
0
    return ss.str();
18
0
}
19
20
0
nlohmann::json Digest::ToJSON(void) const {
21
0
    nlohmann::json j;
22
0
    j["operation"] = "Digest";
23
0
    j["cleartext"] = cleartext.ToJSON();
24
0
    j["digestType"] = digestType.ToJSON();
25
0
    j["modifier"] = modifier.ToJSON();
26
0
    return j;
27
0
}
28
29
0
std::string HMAC::Name(void) const { return "HMAC"; }
30
0
std::string HMAC::ToString(void) const {
31
0
    std::stringstream ss;
32
33
0
    ss << "operation name: HMAC" << std::endl;
34
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
35
0
    ss << "key: " << util::HexDump(cipher.key.Get()) << std::endl;
36
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
37
38
0
    return ss.str();
39
0
}
40
41
0
nlohmann::json HMAC::ToJSON(void) const {
42
0
    nlohmann::json j;
43
0
    j["operation"] = "HMAC";
44
0
    j["cleartext"] = cleartext.ToJSON();
45
0
    j["digestType"] = digestType.ToJSON();
46
0
    j["cipher"] = cipher.ToJSON();
47
0
    j["modifier"] = modifier.ToJSON();
48
0
    return j;
49
0
}
50
51
0
std::string UMAC::Name(void) const { return "UMAC"; }
52
0
std::string UMAC::ToString(void) const {
53
0
    std::stringstream ss;
54
55
0
    ss << "operation name: UMAC" << std::endl;
56
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
57
0
    ss << "key: " << util::HexDump(key.Get()) << std::endl;
58
0
    ss << "iv: " << util::HexDump(iv.Get()) << std::endl;
59
0
    ss << "type: " << std::to_string(type) << std::endl;
60
0
    ss << "outSize: " << std::to_string(outSize) << std::endl;
61
62
0
    return ss.str();
63
0
}
64
65
0
nlohmann::json UMAC::ToJSON(void) const {
66
0
    nlohmann::json j;
67
0
    j["operation"] = "UMAC";
68
0
    j["cleartext"] = cleartext.ToJSON();
69
0
    j["key"] = key.ToJSON();
70
0
    j["iv"] = iv.ToJSON();
71
0
    j["type"] = type;
72
0
    j["outSize"] = outSize;
73
0
    j["modifier"] = modifier.ToJSON();
74
0
    return j;
75
0
}
76
77
0
std::string SymmetricEncrypt::Name(void) const { return "SymmetricEncrypt"; }
78
0
std::string SymmetricEncrypt::ToString(void) const {
79
0
    std::stringstream ss;
80
81
0
    ss << "operation name: SymmetricEncrypt" << std::endl;
82
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
83
0
    ss << "aad: " << (aad ? util::HexDump(aad->Get()) : "nullopt") << std::endl;
84
0
    ss << "cipher iv: " << util::HexDump(cipher.iv.Get()) << std::endl;
85
0
    ss << "cipher key: " << util::HexDump(cipher.key.Get()) << std::endl;
86
0
    ss << "cipher: " << repository::CipherToString(cipher.cipherType.Get()) << std::endl;
87
0
    ss << "ciphertextSize: " << std::to_string(ciphertextSize) << std::endl;
88
0
    ss << "tagSize: " << (tagSize ? std::to_string(*tagSize) : "nullopt") << std::endl;
89
90
0
    return ss.str();
91
0
}
92
93
0
nlohmann::json SymmetricEncrypt::ToJSON(void) const {
94
0
    nlohmann::json j;
95
0
    j["operation"] = "SymmetricEncrypt";
96
0
    j["cleartext"] = cleartext.ToJSON();
97
0
    j["cipher"] = cipher.ToJSON();
98
0
    j["aad_enabled"] = (bool)(aad != std::nullopt);
99
0
    j["aad"] = aad != std::nullopt ? aad->ToJSON() : "";
100
0
    j["ciphertextSize"] = ciphertextSize;
101
0
    j["tagSize_enabled"] = (bool)(tagSize != std::nullopt);
102
0
    j["tagSize"] = tagSize != std::nullopt ? *tagSize : 0;
103
0
    j["modifier"] = modifier.ToJSON();
104
0
    return j;
105
0
}
106
107
0
std::string SymmetricDecrypt::Name(void) const { return "SymmetricDecrypt"; }
108
0
std::string SymmetricDecrypt::ToString(void) const {
109
0
    std::stringstream ss;
110
111
0
    ss << "operation name: SymmetricDecrypt" << std::endl;
112
0
    ss << "ciphertext: " << util::HexDump(ciphertext.Get()) << std::endl;
113
0
    ss << "tag: " << (tag ? util::HexDump(tag->Get()) : "nullopt") << std::endl;
114
0
    ss << "aad: " << (aad ? util::HexDump(aad->Get()) : "nullopt") << std::endl;
115
0
    ss << "cipher iv: " << util::HexDump(cipher.iv.Get()) << std::endl;
116
0
    ss << "cipher key: " << util::HexDump(cipher.key.Get()) << std::endl;
117
0
    ss << "cipher: " << repository::CipherToString(cipher.cipherType.Get()) << std::endl;
118
0
    ss << "cleartextSize: " << std::to_string(cleartextSize) << std::endl;
119
120
0
    return ss.str();
121
0
}
122
123
0
nlohmann::json SymmetricDecrypt::ToJSON(void) const {
124
0
    nlohmann::json j;
125
0
    j["operation"] = "SymmetricDecrypt";
126
0
    j["ciphertext"] = ciphertext.ToJSON();
127
0
    j["cipher"] = cipher.ToJSON();
128
0
    j["aad_enabled"] = (bool)(aad != std::nullopt);
129
0
    j["aad"] = aad != std::nullopt ? aad->ToJSON() : "";
130
0
    j["tag_enabled"] = (bool)(tag != std::nullopt);
131
0
    j["tag"] = tag != std::nullopt ? tag->ToJSON() : "";
132
0
    j["cleartextSize"] = cleartextSize;
133
0
    j["modifier"] = modifier.ToJSON();
134
0
    return j;
135
0
}
136
137
/* Construct SymmetricDecrypt from SymmetricEncrypt */
138
SymmetricDecrypt::SymmetricDecrypt(const SymmetricEncrypt& opSymmetricEncrypt, const component::Ciphertext ciphertext, const uint64_t cleartextSize, std::optional<component::AAD> aad, component::Modifier modifier) :
139
    Operation(std::move(modifier)),
140
    ciphertext(ciphertext.ciphertext),
141
    cipher(opSymmetricEncrypt.cipher),
142
    tag(ciphertext.tag),
143
    aad(aad),
144
    cleartextSize(cleartextSize)
145
6.69k
{ }
146
147
0
std::string KDF_SCRYPT::Name(void) const { return "KDF_SCRYPT"; }
148
0
std::string KDF_SCRYPT::ToString(void) const {
149
0
    std::stringstream ss;
150
151
0
    ss << "operation name: KDF_SCRYPT" << std::endl;
152
0
    ss << "password: " << util::HexDump(password.Get()) << std::endl;
153
0
    ss << "salt: " << util::HexDump(salt.Get()) << std::endl;
154
0
    ss << "N: " << std::to_string(N) << std::endl;
155
0
    ss << "r: " << std::to_string(r) << std::endl;
156
0
    ss << "p: " << std::to_string(p) << std::endl;
157
0
    ss << "keySize: " << std::to_string(keySize) << std::endl;
158
159
0
    return ss.str();
160
0
}
161
162
0
nlohmann::json KDF_SCRYPT::ToJSON(void) const {
163
0
    nlohmann::json j;
164
0
    j["operation"] = "KDF_SCRYPT";
165
0
    j["password"] = password.ToJSON();
166
0
    j["salt"] = salt.ToJSON();
167
0
    j["N"] = N;
168
0
    j["r"] = r;
169
0
    j["p"] = p;
170
0
    j["keySize"] = keySize;
171
0
    j["modifier"] = modifier.ToJSON();
172
0
    return j;
173
0
}
174
175
0
std::string KDF_HKDF::Name(void) const { return "KDF_HKDF"; }
176
0
std::string KDF_HKDF::ToString(void) const {
177
0
    std::stringstream ss;
178
179
0
    ss << "operation name: KDF_HKDF" << std::endl;
180
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
181
0
    ss << "password: " << util::HexDump(password.Get()) << std::endl;
182
0
    ss << "salt: " << util::HexDump(salt.Get()) << std::endl;
183
0
    ss << "info: " << util::HexDump(info.Get()) << std::endl;
184
0
    ss << "keySize: " << std::to_string(keySize) << std::endl;
185
186
0
    return ss.str();
187
0
}
188
189
0
nlohmann::json KDF_HKDF::ToJSON(void) const {
190
0
    nlohmann::json j;
191
0
    j["operation"] = "KDF_HKDF";
192
0
    j["digestType"] = digestType.ToJSON();
193
0
    j["password"] = password.ToJSON();
194
0
    j["salt"] = salt.ToJSON();
195
0
    j["info"] = info.ToJSON();
196
0
    j["keySize"] = keySize;
197
0
    j["modifier"] = modifier.ToJSON();
198
0
    return j;
199
0
}
200
201
0
std::string KDF_TLS1_PRF::Name(void) const { return "KDF_TLS1_PRF"; }
202
0
std::string KDF_TLS1_PRF::ToString(void) const {
203
0
    std::stringstream ss;
204
205
0
    ss << "operation name: KDF_TLS1_PRF" << std::endl;
206
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
207
0
    ss << "secret: " << util::HexDump(secret.Get()) << std::endl;
208
0
    ss << "seed: " << util::HexDump(seed.Get()) << std::endl;
209
0
    ss << "keySize: " << std::to_string(keySize) << std::endl;
210
211
0
    return ss.str();
212
0
}
213
214
0
nlohmann::json KDF_TLS1_PRF::ToJSON(void) const {
215
0
    nlohmann::json j;
216
0
    j["operation"] = "KDF_TLS1_PRF";
217
0
    j["digestType"] = digestType.ToJSON();
218
0
    j["secret"] = secret.ToJSON();
219
0
    j["seed"] = seed.ToJSON();
220
0
    j["keySize"] = keySize;
221
0
    j["modifier"] = modifier.ToJSON();
222
0
    return j;
223
0
}
224
225
0
std::string KDF_PBKDF::Name(void) const { return "KDF_PBKDF"; }
226
0
std::string KDF_PBKDF::ToString(void) const {
227
0
    std::stringstream ss;
228
229
0
    ss << "operation name: KDF_PBKDF" << std::endl;
230
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
231
0
    ss << "password: " << util::HexDump(password.Get()) << std::endl;
232
0
    ss << "salt: " << util::HexDump(salt.Get()) << std::endl;
233
0
    ss << "iterations: " << std::to_string(iterations) << std::endl;
234
0
    ss << "keySize: " << std::to_string(keySize) << std::endl;
235
236
0
    return ss.str();
237
0
}
238
239
0
nlohmann::json KDF_PBKDF::ToJSON(void) const {
240
0
    nlohmann::json j;
241
0
    j["operation"] = "KDF_PBKDF";
242
0
    j["digestType"] = digestType.ToJSON();
243
0
    j["password"] = password.ToJSON();
244
0
    j["salt"] = salt.ToJSON();
245
0
    j["iterations"] = iterations;
246
0
    j["keySize"] = keySize;
247
0
    j["modifier"] = modifier.ToJSON();
248
0
    return j;
249
0
}
250
251
0
std::string KDF_PBKDF1::Name(void) const { return "KDF_PBKDF1"; }
252
0
std::string KDF_PBKDF1::ToString(void) const {
253
0
    std::stringstream ss;
254
255
0
    ss << "operation name: KDF_PBKDF1" << std::endl;
256
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
257
0
    ss << "password: " << util::HexDump(password.Get()) << std::endl;
258
0
    ss << "salt: " << util::HexDump(salt.Get()) << std::endl;
259
0
    ss << "iterations: " << std::to_string(iterations) << std::endl;
260
0
    ss << "keySize: " << std::to_string(keySize) << std::endl;
261
262
0
    return ss.str();
263
0
}
264
265
0
nlohmann::json KDF_PBKDF1::ToJSON(void) const {
266
0
    nlohmann::json j;
267
0
    j["operation"] = "KDF_PBKDF1";
268
0
    j["digestType"] = digestType.ToJSON();
269
0
    j["password"] = password.ToJSON();
270
0
    j["salt"] = salt.ToJSON();
271
0
    j["iterations"] = iterations;
272
0
    j["keySize"] = keySize;
273
0
    j["modifier"] = modifier.ToJSON();
274
0
    return j;
275
0
}
276
277
0
std::string KDF_PBKDF2::Name(void) const { return "KDF_PBKDF2"; }
278
0
std::string KDF_PBKDF2::ToString(void) const {
279
0
    std::stringstream ss;
280
281
0
    ss << "operation name: KDF_PBKDF2" << std::endl;
282
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
283
0
    ss << "password: " << util::HexDump(password.Get()) << std::endl;
284
0
    ss << "salt: " << util::HexDump(salt.Get()) << std::endl;
285
0
    ss << "iterations: " << std::to_string(iterations) << std::endl;
286
0
    ss << "keySize: " << std::to_string(keySize) << std::endl;
287
288
0
    return ss.str();
289
0
}
290
291
0
nlohmann::json KDF_PBKDF2::ToJSON(void) const {
292
0
    nlohmann::json j;
293
0
    j["operation"] = "KDF_PBKDF2";
294
0
    j["digestType"] = digestType.ToJSON();
295
0
    j["password"] = password.ToJSON();
296
0
    j["salt"] = salt.ToJSON();
297
0
    j["iterations"] = iterations;
298
0
    j["keySize"] = keySize;
299
0
    j["modifier"] = modifier.ToJSON();
300
0
    return j;
301
0
}
302
303
0
std::string KDF_ARGON2::Name(void) const { return "KDF_ARGON2"; }
304
0
std::string KDF_ARGON2::ToString(void) const {
305
0
    std::stringstream ss;
306
307
0
    ss << "operation name: KDF_ARGON2" << std::endl;
308
0
    ss << "password: " << util::HexDump(password.Get()) << std::endl;
309
0
    ss << "salt: " << util::HexDump(salt.Get()) << std::endl;
310
0
    ss << "type: " << std::to_string(type) << std::endl;
311
0
    ss << "threads: " << std::to_string(threads) << std::endl;
312
0
    ss << "memory: " << std::to_string(memory) << std::endl;
313
0
    ss << "iterations: " << std::to_string(iterations) << std::endl;
314
0
    ss << "keySize: " << std::to_string(keySize) << std::endl;
315
316
0
    return ss.str();
317
0
}
318
319
0
nlohmann::json KDF_ARGON2::ToJSON(void) const {
320
0
    nlohmann::json j;
321
0
    j["operation"] = "KDF_ARGON2";
322
0
    j["password"] = password.ToJSON();
323
0
    j["salt"] = salt.ToJSON();
324
0
    j["type"] = type;
325
0
    j["threads"] = threads;
326
0
    j["memory"] = memory;
327
0
    j["iterations"] = iterations;
328
0
    j["modifier"] = modifier.ToJSON();
329
0
    return j;
330
0
}
331
332
0
std::string KDF_SSH::Name(void) const { return "KDF_SSH"; }
333
0
std::string KDF_SSH::ToString(void) const {
334
0
    std::stringstream ss;
335
336
0
    ss << "operation name: KDF_SSH" << std::endl;
337
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
338
0
    ss << "key: " << util::HexDump(key.Get()) << std::endl;
339
0
    ss << "xcghash: " << util::HexDump(xcghash.Get()) << std::endl;
340
0
    ss << "session_id: " << util::HexDump(session_id.Get()) << std::endl;
341
0
    ss << "type: " << util::HexDump(type.Get()) << std::endl;
342
0
    ss << "keySize: " << std::to_string(keySize) << std::endl;
343
344
0
    return ss.str();
345
0
}
346
347
0
nlohmann::json KDF_SSH::ToJSON(void) const {
348
0
    nlohmann::json j;
349
0
    j["operation"] = "KDF_SSH";
350
0
    j["digestType"] = digestType.ToJSON();
351
0
    j["key"] = key.ToJSON();
352
0
    j["xcghash"] = xcghash.ToJSON();
353
0
    j["session_id"] = session_id.ToJSON();
354
0
    j["type"] = type.ToJSON();
355
0
    j["keySize"] = keySize;
356
0
    j["modifier"] = modifier.ToJSON();
357
0
    return j;
358
0
}
359
360
0
std::string KDF_X963::Name(void) const { return "KDF_X963"; }
361
0
std::string KDF_X963::ToString(void) const {
362
0
    std::stringstream ss;
363
364
0
    ss << "operation name: KDF_X963" << std::endl;
365
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
366
0
    ss << "secret: " << util::HexDump(secret.Get()) << std::endl;
367
0
    ss << "info: " << util::HexDump(info.Get()) << std::endl;
368
0
    ss << "keySize: " << std::to_string(keySize) << std::endl;
369
370
0
    return ss.str();
371
0
}
372
373
0
nlohmann::json KDF_X963::ToJSON(void) const {
374
0
    nlohmann::json j;
375
0
    j["operation"] = "KDF_X963";
376
0
    j["digestType"] = digestType.ToJSON();
377
0
    j["secret"] = secret.ToJSON();
378
0
    j["info"] = info.ToJSON();
379
0
    j["keySize"] = keySize;
380
0
    j["modifier"] = modifier.ToJSON();
381
0
    return j;
382
0
}
383
384
0
std::string KDF_BCRYPT::Name(void) const { return "KDF_BCRYPT"; }
385
0
std::string KDF_BCRYPT::ToString(void) const {
386
0
    std::stringstream ss;
387
388
0
    ss << "operation name: KDF_BCRYPT" << std::endl;
389
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
390
0
    ss << "secret: " << util::HexDump(secret.Get()) << std::endl;
391
0
    ss << "salt: " << util::HexDump(salt.Get()) << std::endl;
392
0
    ss << "iterations: " << std::to_string(iterations) << std::endl;
393
0
    ss << "keySize: " << std::to_string(keySize) << std::endl;
394
395
0
    return ss.str();
396
0
}
397
398
0
nlohmann::json KDF_BCRYPT::ToJSON(void) const {
399
0
    nlohmann::json j;
400
0
    j["operation"] = "KDF_BCRYPT";
401
0
    j["digestType"] = digestType.ToJSON();
402
0
    j["secret"] = secret.ToJSON();
403
0
    j["salt"] = salt.ToJSON();
404
0
    j["iterations"] = iterations;
405
0
    j["keySize"] = keySize;
406
0
    j["modifier"] = modifier.ToJSON();
407
0
    return j;
408
0
}
409
410
0
std::string KDF_SP_800_108::Name(void) const { return "KDF_SP_800_108"; }
411
0
std::string KDF_SP_800_108::ToString(void) const {
412
0
    std::stringstream ss;
413
414
0
    ss << "operation name: KDF_SP_800_108" << std::endl;
415
0
    ss << "hmac/cmac: " << (mech.mode ? "HMAC" : "CMAC") << std::endl;
416
0
    if ( mech.mode == true ) {
417
0
        ss << "digest: " << repository::DigestToString(mech.type.Get()) << std::endl;
418
0
    } else {
419
0
        ss << "cipher: " << repository::CipherToString(mech.type.Get()) << std::endl;
420
0
    }
421
0
    ss << "secret: " << util::HexDump(secret.Get()) << std::endl;
422
0
    ss << "salt: " << util::HexDump(salt.Get()) << std::endl;
423
0
    ss << "label: " << util::HexDump(label.Get()) << std::endl;
424
0
    ss << "mode: " << std::to_string(mode) << std::endl;
425
0
    ss << "keySize: " << std::to_string(keySize) << std::endl;
426
427
0
    return ss.str();
428
0
}
429
430
0
nlohmann::json KDF_SP_800_108::ToJSON(void) const {
431
0
    nlohmann::json j;
432
0
    j["operation"] = "KDF_SP_800_108";
433
0
    j["mech"] = mech.ToJSON();
434
0
    j["secret"] = secret.ToJSON();
435
0
    j["salt"] = salt.ToJSON();
436
0
    j["label"] = label.ToJSON();
437
0
    j["mode"] = mode;
438
0
    j["modifier"] = modifier.ToJSON();
439
0
    return j;
440
0
}
441
442
0
std::string CMAC::Name(void) const { return "CMAC"; }
443
0
std::string CMAC::ToString(void) const {
444
0
    std::stringstream ss;
445
446
0
    ss << "operation name: CMAC" << std::endl;
447
0
    ss << "cipher iv: " << util::HexDump(cipher.iv.Get()) << std::endl;
448
0
    ss << "cipher key: " << util::HexDump(cipher.key.Get()) << std::endl;
449
0
    ss << "cipher: " << repository::CipherToString(cipher.cipherType.Get()) << std::endl;
450
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
451
0
    ss << "key: " << util::HexDump(cipher.key.Get()) << std::endl;
452
453
0
    return ss.str();
454
0
}
455
456
0
nlohmann::json CMAC::ToJSON(void) const {
457
0
    nlohmann::json j;
458
0
    j["operation"] = "CMAC";
459
0
    j["cleartext"] = cleartext.ToJSON();
460
0
    j["cipher"] = cipher.ToJSON();
461
0
    j["modifier"] = modifier.ToJSON();
462
0
    return j;
463
0
}
464
465
0
std::string ECC_PrivateToPublic::Name(void) const { return "ECC_PrivateToPublic"; }
466
0
std::string ECC_PrivateToPublic::ToString(void) const {
467
0
    std::stringstream ss;
468
469
0
    ss << "operation name: ECC_PrivateToPublic" << std::endl;
470
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
471
0
    ss << "private key: " << priv.ToString() << std::endl;
472
473
0
    return ss.str();
474
0
}
475
476
0
nlohmann::json ECC_PrivateToPublic::ToJSON(void) const {
477
0
    nlohmann::json j;
478
0
    j["operation"] = "ECC_PrivateToPublic";
479
0
    j["priv"] = priv.ToJSON();
480
0
    j["curveType"] = curveType.ToJSON();
481
0
    j["modifier"] = modifier.ToJSON();
482
0
    return j;
483
0
}
484
485
0
std::string ECC_ValidatePubkey::Name(void) const { return "ECC_ValidatePubkey"; }
486
0
std::string ECC_ValidatePubkey::ToString(void) const {
487
0
    std::stringstream ss;
488
489
0
    ss << "operation name: ECC_ValidatePubkey" << std::endl;
490
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
491
0
    ss << "public key X: " << pub.first.ToString() << std::endl;
492
0
    ss << "public key Y: " << pub.second.ToString() << std::endl;
493
494
0
    return ss.str();
495
0
}
496
497
0
nlohmann::json ECC_ValidatePubkey::ToJSON(void) const {
498
0
    nlohmann::json j;
499
0
    j["operation"] = "ECC_ValidatePubkey";
500
0
    j["pub_x"] = pub.first.ToJSON();
501
0
    j["pub_y"] = pub.second.ToJSON();
502
0
    j["curveType"] = curveType.ToJSON();
503
0
    j["modifier"] = modifier.ToJSON();
504
0
    return j;
505
0
}
506
507
0
std::string ECC_GenerateKeyPair::Name(void) const { return "ECC_GenerateKeyPair"; }
508
0
std::string ECC_GenerateKeyPair::ToString(void) const {
509
0
    std::stringstream ss;
510
511
0
    ss << "operation name: ECC_GenerateKeyPair" << std::endl;
512
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
513
514
0
    return ss.str();
515
0
}
516
517
0
nlohmann::json ECC_GenerateKeyPair::ToJSON(void) const {
518
0
    nlohmann::json j;
519
0
    j["operation"] = "ECC_GenerateKeyPair";
520
0
    j["curveType"] = curveType.ToJSON();
521
0
    j["modifier"] = modifier.ToJSON();
522
0
    return j;
523
0
}
524
525
0
std::string ECCSI_Sign::Name(void) const { return "ECCSI_Sign"; }
526
0
std::string ECCSI_Sign::ToString(void) const {
527
0
    std::stringstream ss;
528
529
0
    ss << "operation name: ECCSI_Sign" << std::endl;
530
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
531
0
    ss << "private key: " << priv.ToString() << std::endl;
532
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
533
0
    ss << "id: " << util::HexDump(id.Get()) << std::endl;
534
535
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
536
537
0
    return ss.str();
538
0
}
539
540
0
nlohmann::json ECCSI_Sign::ToJSON(void) const {
541
0
    nlohmann::json j;
542
0
    j["operation"] = "ECCSI_Sign";
543
0
    j["priv"] = priv.ToJSON();
544
0
    j["curveType"] = curveType.ToJSON();
545
0
    j["cleartext"] = cleartext.ToJSON();
546
0
    j["id"] = id.ToJSON();
547
0
    j["digestType"] = digestType.ToJSON();
548
0
    j["modifier"] = modifier.ToJSON();
549
0
    return j;
550
0
}
551
552
0
std::string ECDSA_Sign::Name(void) const { return "ECDSA_Sign"; }
553
0
std::string ECDSA_Sign::ToString(void) const {
554
0
    std::stringstream ss;
555
556
0
    ss << "operation name: ECDSA_Sign" << std::endl;
557
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
558
0
    ss << "nonce: " << nonce.ToString() << std::endl;
559
0
    ss << "private key: " << priv.ToString() << std::endl;
560
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
561
0
    ss << "nonce source: ";
562
0
    if ( UseRandomNonce() ) {
563
0
        ss << "random";
564
0
    } else if ( UseRFC6979Nonce() ) {
565
0
        ss << "RFC 6979";
566
0
    } else if ( UseSpecifiedNonce() ) {
567
0
        ss << "specified";
568
0
    } else {
569
0
        ss << "(unknown)";
570
0
    }
571
0
    ss << std::endl;
572
573
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
574
575
0
    return ss.str();
576
0
}
577
578
0
nlohmann::json ECDSA_Sign::ToJSON(void) const {
579
0
    nlohmann::json j;
580
0
    j["operation"] = "ECDSA_Sign";
581
0
    j["priv"] = priv.ToJSON();
582
0
    j["nonce"] = priv.ToJSON();
583
0
    j["curveType"] = curveType.ToJSON();
584
0
    j["cleartext"] = cleartext.ToJSON();
585
0
    j["nonceSource"] = nonceSource;
586
0
    j["digestType"] = digestType.ToJSON();
587
0
    j["modifier"] = modifier.ToJSON();
588
0
    return j;
589
0
}
590
591
0
std::string ECGDSA_Sign::Name(void) const { return "ECGDSA_Sign"; }
592
0
std::string ECGDSA_Sign::ToString(void) const {
593
0
    std::stringstream ss;
594
595
0
    ss << "operation name: ECGDSA_Sign" << std::endl;
596
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
597
0
    ss << "nonce: " << nonce.ToString() << std::endl;
598
0
    ss << "private key: " << priv.ToString() << std::endl;
599
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
600
0
    ss << "nonce source: ";
601
0
    if ( UseRandomNonce() ) {
602
0
        ss << "random";
603
0
    } else if ( UseRFC6979Nonce() ) {
604
0
        ss << "RFC 6979";
605
0
    } else if ( UseSpecifiedNonce() ) {
606
0
        ss << "specified";
607
0
    } else {
608
0
        ss << "(unknown)";
609
0
    }
610
0
    ss << std::endl;
611
612
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
613
614
0
    return ss.str();
615
0
}
616
617
0
nlohmann::json ECGDSA_Sign::ToJSON(void) const {
618
0
    nlohmann::json j;
619
0
    j["operation"] = "ECGDSA_Sign";
620
0
    j["priv"] = priv.ToJSON();
621
0
    j["nonce"] = priv.ToJSON();
622
0
    j["curveType"] = curveType.ToJSON();
623
0
    j["cleartext"] = cleartext.ToJSON();
624
0
    j["nonceSource"] = nonceSource;
625
0
    j["digestType"] = digestType.ToJSON();
626
0
    j["modifier"] = modifier.ToJSON();
627
0
    return j;
628
0
}
629
630
0
std::string ECRDSA_Sign::Name(void) const { return "ECRDSA_Sign"; }
631
0
std::string ECRDSA_Sign::ToString(void) const {
632
0
    std::stringstream ss;
633
634
0
    ss << "operation name: ECRDSA_Sign" << std::endl;
635
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
636
0
    ss << "nonce: " << nonce.ToString() << std::endl;
637
0
    ss << "private key: " << priv.ToString() << std::endl;
638
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
639
0
    ss << "nonce source: ";
640
0
    if ( UseRandomNonce() ) {
641
0
        ss << "random";
642
0
    } else if ( UseRFC6979Nonce() ) {
643
0
        ss << "RFC 6979";
644
0
    } else if ( UseSpecifiedNonce() ) {
645
0
        ss << "specified";
646
0
    } else {
647
0
        ss << "(unknown)";
648
0
    }
649
0
    ss << std::endl;
650
651
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
652
653
0
    return ss.str();
654
0
}
655
656
0
nlohmann::json ECRDSA_Sign::ToJSON(void) const {
657
0
    nlohmann::json j;
658
0
    j["operation"] = "ECRDSA_Sign";
659
0
    j["priv"] = priv.ToJSON();
660
0
    j["nonce"] = priv.ToJSON();
661
0
    j["curveType"] = curveType.ToJSON();
662
0
    j["cleartext"] = cleartext.ToJSON();
663
0
    j["nonceSource"] = nonceSource;
664
0
    j["digestType"] = digestType.ToJSON();
665
0
    j["modifier"] = modifier.ToJSON();
666
0
    return j;
667
0
}
668
669
0
std::string Schnorr_Sign::Name(void) const { return "Schnorr_Sign"; }
670
0
std::string Schnorr_Sign::ToString(void) const {
671
0
    std::stringstream ss;
672
673
0
    ss << "operation name: Schnorr_Sign" << std::endl;
674
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
675
0
    ss << "nonce: " << nonce.ToString() << std::endl;
676
0
    ss << "private key: " << priv.ToString() << std::endl;
677
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
678
0
    ss << "nonce source: ";
679
0
    if ( UseRandomNonce() ) {
680
0
        ss << "random";
681
0
    } else if ( UseBIP340Nonce() ) {
682
0
        ss << "BIP 340";
683
0
    } else if ( UseSpecifiedNonce() ) {
684
0
        ss << "specified";
685
0
    } else {
686
0
        ss << "(unknown)";
687
0
    }
688
0
    ss << std::endl;
689
690
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
691
692
0
    return ss.str();
693
0
}
694
695
0
nlohmann::json Schnorr_Sign::ToJSON(void) const {
696
0
    nlohmann::json j;
697
0
    j["operation"] = "Schnorr_Sign";
698
0
    j["priv"] = priv.ToJSON();
699
0
    j["nonce"] = priv.ToJSON();
700
0
    j["curveType"] = curveType.ToJSON();
701
0
    j["cleartext"] = cleartext.ToJSON();
702
0
    j["nonceSource"] = nonceSource;
703
0
    j["digestType"] = digestType.ToJSON();
704
0
    j["modifier"] = modifier.ToJSON();
705
0
    return j;
706
0
}
707
708
0
std::string ECCSI_Verify::Name(void) const { return "ECCSI_Verify"; }
709
0
std::string ECCSI_Verify::ToString(void) const {
710
0
    std::stringstream ss;
711
712
0
    ss << "operation name: ECCSI_Verify" << std::endl;
713
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
714
0
    ss << "public key X: " << signature.pub.first.ToString() << std::endl;
715
0
    ss << "public key Y: " << signature.pub.second.ToString() << std::endl;
716
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
717
0
    ss << "id: " << util::HexDump(id.Get()) << std::endl;
718
0
    ss << "signature R: " << signature.signature.first.ToString() << std::endl;
719
0
    ss << "signature S: " << signature.signature.second.ToString() << std::endl;
720
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
721
722
0
    return ss.str();
723
0
}
724
725
0
nlohmann::json ECCSI_Verify::ToJSON(void) const {
726
0
    nlohmann::json j;
727
0
    j["operation"] = "ECCSI_Verify";
728
0
    j["curveType"] = curveType.ToJSON();
729
0
    j["pub_x"] = signature.pub.first.ToJSON();
730
0
    j["pub_y"] = signature.pub.second.ToJSON();
731
0
    j["cleartext"] = cleartext.ToJSON();
732
0
    j["id"] = id.ToJSON();
733
0
    j["sig_r"] = signature.signature.first.ToJSON();
734
0
    j["sig_s"] = signature.signature.second.ToJSON();
735
0
    j["digestType"] = digestType.ToJSON();
736
0
    j["modifier"] = modifier.ToJSON();
737
0
    return j;
738
0
}
739
740
/* Construct ECCSI_Verify from ECCSI_Sign */
741
ECCSI_Verify::ECCSI_Verify(const ECCSI_Sign& opECCSI_Sign, const component::ECCSI_Signature signature, component::Modifier modifier) :
742
    Operation(std::move(modifier)),
743
    curveType(opECCSI_Sign.curveType),
744
    cleartext(opECCSI_Sign.cleartext),
745
    id(opECCSI_Sign.id),
746
    signature(signature),
747
    digestType(opECCSI_Sign.digestType)
748
0
{ }
749
750
0
std::string ECDSA_Verify::Name(void) const { return "ECDSA_Verify"; }
751
0
std::string ECDSA_Verify::ToString(void) const {
752
0
    std::stringstream ss;
753
754
0
    ss << "operation name: ECDSA_Verify" << std::endl;
755
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
756
0
    ss << "public key X: " << signature.pub.first.ToString() << std::endl;
757
0
    ss << "public key Y: " << signature.pub.second.ToString() << std::endl;
758
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
759
0
    ss << "signature R: " << signature.signature.first.ToString() << std::endl;
760
0
    ss << "signature S: " << signature.signature.second.ToString() << std::endl;
761
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
762
763
0
    return ss.str();
764
0
}
765
766
0
nlohmann::json ECDSA_Verify::ToJSON(void) const {
767
0
    nlohmann::json j;
768
0
    j["operation"] = "ECDSA_Verify";
769
0
    j["curveType"] = curveType.ToJSON();
770
0
    j["pub_x"] = signature.pub.first.ToJSON();
771
0
    j["pub_y"] = signature.pub.second.ToJSON();
772
0
    j["cleartext"] = cleartext.ToJSON();
773
0
    j["sig_r"] = signature.signature.first.ToJSON();
774
0
    j["sig_s"] = signature.signature.second.ToJSON();
775
0
    j["digestType"] = digestType.ToJSON();
776
0
    j["modifier"] = modifier.ToJSON();
777
0
    return j;
778
0
}
779
780
/* Construct ECDSA_Verify from ECDSA_Sign */
781
ECDSA_Verify::ECDSA_Verify(const ECDSA_Sign& opECDSA_Sign, const component::ECDSA_Signature signature, component::Modifier modifier) :
782
    Operation(std::move(modifier)),
783
    curveType(opECDSA_Sign.curveType),
784
    cleartext(opECDSA_Sign.cleartext),
785
    signature(signature),
786
    digestType(opECDSA_Sign.digestType)
787
889
{ }
788
789
0
std::string ECGDSA_Verify::Name(void) const { return "ECGDSA_Verify"; }
790
0
std::string ECGDSA_Verify::ToString(void) const {
791
0
    std::stringstream ss;
792
793
0
    ss << "operation name: ECGDSA_Verify" << std::endl;
794
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
795
0
    ss << "public key X: " << signature.pub.first.ToString() << std::endl;
796
0
    ss << "public key Y: " << signature.pub.second.ToString() << std::endl;
797
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
798
0
    ss << "signature R: " << signature.signature.first.ToString() << std::endl;
799
0
    ss << "signature S: " << signature.signature.second.ToString() << std::endl;
800
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
801
802
0
    return ss.str();
803
0
}
804
805
0
nlohmann::json ECGDSA_Verify::ToJSON(void) const {
806
0
    nlohmann::json j;
807
0
    j["operation"] = "ECGDSA_Verify";
808
0
    j["curveType"] = curveType.ToJSON();
809
0
    j["pub_x"] = signature.pub.first.ToJSON();
810
0
    j["pub_y"] = signature.pub.second.ToJSON();
811
0
    j["cleartext"] = cleartext.ToJSON();
812
0
    j["sig_r"] = signature.signature.first.ToJSON();
813
0
    j["sig_s"] = signature.signature.second.ToJSON();
814
0
    j["digestType"] = digestType.ToJSON();
815
0
    j["modifier"] = modifier.ToJSON();
816
0
    return j;
817
0
}
818
819
0
std::string ECRDSA_Verify::Name(void) const { return "ECRDSA_Verify"; }
820
0
std::string ECRDSA_Verify::ToString(void) const {
821
0
    std::stringstream ss;
822
823
0
    ss << "operation name: ECRDSA_Verify" << std::endl;
824
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
825
0
    ss << "public key X: " << signature.pub.first.ToString() << std::endl;
826
0
    ss << "public key Y: " << signature.pub.second.ToString() << std::endl;
827
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
828
0
    ss << "signature R: " << signature.signature.first.ToString() << std::endl;
829
0
    ss << "signature S: " << signature.signature.second.ToString() << std::endl;
830
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
831
832
0
    return ss.str();
833
0
}
834
835
0
nlohmann::json ECRDSA_Verify::ToJSON(void) const {
836
0
    nlohmann::json j;
837
0
    j["operation"] = "ECRDSA_Verify";
838
0
    j["curveType"] = curveType.ToJSON();
839
0
    j["pub_x"] = signature.pub.first.ToJSON();
840
0
    j["pub_y"] = signature.pub.second.ToJSON();
841
0
    j["cleartext"] = cleartext.ToJSON();
842
0
    j["sig_r"] = signature.signature.first.ToJSON();
843
0
    j["sig_s"] = signature.signature.second.ToJSON();
844
0
    j["digestType"] = digestType.ToJSON();
845
0
    j["modifier"] = modifier.ToJSON();
846
0
    return j;
847
0
}
848
849
0
std::string Schnorr_Verify::Name(void) const { return "Schnorr_Verify"; }
850
0
std::string Schnorr_Verify::ToString(void) const {
851
0
    std::stringstream ss;
852
853
0
    ss << "operation name: Schnorr_Verify" << std::endl;
854
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
855
0
    ss << "public key X: " << signature.pub.first.ToString() << std::endl;
856
0
    ss << "public key Y: " << signature.pub.second.ToString() << std::endl;
857
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
858
0
    ss << "signature R: " << signature.signature.first.ToString() << std::endl;
859
0
    ss << "signature S: " << signature.signature.second.ToString() << std::endl;
860
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
861
862
0
    return ss.str();
863
0
}
864
865
0
nlohmann::json Schnorr_Verify::ToJSON(void) const {
866
0
    nlohmann::json j;
867
0
    j["operation"] = "Schnorr_Verify";
868
0
    j["curveType"] = curveType.ToJSON();
869
0
    j["pub_x"] = signature.pub.first.ToJSON();
870
0
    j["pub_y"] = signature.pub.second.ToJSON();
871
0
    j["cleartext"] = cleartext.ToJSON();
872
0
    j["sig_r"] = signature.signature.first.ToJSON();
873
0
    j["sig_s"] = signature.signature.second.ToJSON();
874
0
    j["digestType"] = digestType.ToJSON();
875
0
    j["modifier"] = modifier.ToJSON();
876
0
    return j;
877
0
}
878
879
0
std::string ECDSA_Recover::Name(void) const { return "ECDSA_Recover"; }
880
0
std::string ECDSA_Recover::ToString(void) const {
881
0
    std::stringstream ss;
882
883
0
    ss << "operation name: ECDSA_Recover" << std::endl;
884
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
885
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
886
0
    ss << "signature R: " << signature.first.ToString() << std::endl;
887
0
    ss << "signature S: " << signature.second.ToString() << std::endl;
888
0
    ss << "digest: " << repository::DigestToString(digestType.Get()) << std::endl;
889
0
    ss << "recovery ID: " << std::to_string(id) << std::endl;
890
891
0
    return ss.str();
892
0
}
893
894
0
nlohmann::json ECDSA_Recover::ToJSON(void) const {
895
0
    nlohmann::json j;
896
0
    j["operation"] = "ECDSA_Recover";
897
0
    j["curveType"] = curveType.ToJSON();
898
0
    j["cleartext"] = cleartext.ToJSON();
899
0
    j["sig_r"] = signature.first.ToJSON();
900
0
    j["sig_s"] = signature.second.ToJSON();
901
0
    j["id"] = id;
902
0
    j["digestType"] = digestType.ToJSON();
903
0
    j["modifier"] = modifier.ToJSON();
904
0
    return j;
905
0
}
906
907
0
std::string DSA_Verify::Name(void) const { return "DSA_Verify"; }
908
0
std::string DSA_Verify::ToString(void) const {
909
0
    std::stringstream ss;
910
911
0
    ss << "operation name: DSA_Verify" << std::endl;
912
0
    ss << "p: " << parameters.p.ToString() << std::endl;
913
0
    ss << "q: " << parameters.q.ToString() << std::endl;
914
0
    ss << "g: " << parameters.g.ToString() << std::endl;
915
0
    ss << "public key: " << pub.ToString() << std::endl;
916
0
    ss << "r: " << signature.first.ToString() << std::endl;
917
0
    ss << "s: " << signature.second.ToString() << std::endl;
918
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
919
920
0
    return ss.str();
921
0
}
922
923
0
nlohmann::json DSA_Verify::ToJSON(void) const {
924
0
    nlohmann::json j;
925
0
    j["p"] = parameters.p.ToJSON();
926
0
    j["q"] = parameters.q.ToJSON();
927
0
    j["g"] = parameters.g.ToJSON();
928
0
    j["pub"] = pub.ToJSON();
929
0
    j["r"] = signature.first.ToJSON();
930
0
    j["s"] = signature.second.ToJSON();
931
0
    j["cleartext"] = cleartext.ToJSON();
932
0
    j["modifier"] = modifier.ToJSON();
933
0
    return j;
934
0
}
935
936
0
std::string DSA_Sign::Name(void) const { return "DSA_Sign"; }
937
0
std::string DSA_Sign::ToString(void) const {
938
0
    std::stringstream ss;
939
940
0
    ss << "operation name: DSA_Sign" << std::endl;
941
0
    ss << "p: " << parameters.p.ToString() << std::endl;
942
0
    ss << "q: " << parameters.q.ToString() << std::endl;
943
0
    ss << "g: " << parameters.g.ToString() << std::endl;
944
0
    ss << "private key: " << priv.ToString() << std::endl;
945
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
946
947
0
    return ss.str();
948
0
}
949
950
0
nlohmann::json DSA_Sign::ToJSON(void) const {
951
0
    nlohmann::json j;
952
0
    j["p"] = parameters.p.ToJSON();
953
0
    j["q"] = parameters.q.ToJSON();
954
0
    j["g"] = parameters.g.ToJSON();
955
0
    j["priv"] = priv.ToJSON();
956
0
    j["cleartext"] = cleartext.ToJSON();
957
0
    j["modifier"] = modifier.ToJSON();
958
0
    return j;
959
0
}
960
961
0
std::string DSA_PrivateToPublic::Name(void) const { return "DSA_PrivateToPublic"; }
962
0
std::string DSA_PrivateToPublic::ToString(void) const {
963
0
    std::stringstream ss;
964
965
0
    ss << "operation name: DSA_PrivateToPublic" << std::endl;
966
0
    ss << "priv: " << priv.ToString() << std::endl;
967
968
0
    return ss.str();
969
0
}
970
971
0
nlohmann::json DSA_PrivateToPublic::ToJSON(void) const {
972
0
    nlohmann::json j;
973
0
    j["priv"] = priv.ToJSON();
974
0
    j["modifier"] = modifier.ToJSON();
975
0
    return j;
976
0
}
977
978
0
std::string DSA_GenerateKeyPair::Name(void) const { return "DSA_GenerateKeyPair"; }
979
0
std::string DSA_GenerateKeyPair::ToString(void) const {
980
0
    std::stringstream ss;
981
982
0
    ss << "operation name: DSA_GenerateKeyPair" << std::endl;
983
0
    ss << "p: " << p.ToString() << std::endl;
984
0
    ss << "q: " << q.ToString() << std::endl;
985
0
    ss << "g: " << g.ToString() << std::endl;
986
987
0
    return ss.str();
988
0
}
989
990
0
nlohmann::json DSA_GenerateKeyPair::ToJSON(void) const {
991
0
    nlohmann::json j;
992
0
    j["p"] = p.ToJSON();
993
0
    j["q"] = q.ToJSON();
994
0
    j["g"] = g.ToJSON();
995
0
    j["modifier"] = modifier.ToJSON();
996
0
    return j;
997
0
}
998
999
0
std::string DSA_GenerateParameters::Name(void) const { return "DSA_GenerateParameters"; }
1000
0
std::string DSA_GenerateParameters::ToString(void) const {
1001
0
    std::stringstream ss;
1002
1003
0
    ss << "operation name: DSA_GenerateParameters" << std::endl;
1004
1005
0
    return ss.str();
1006
0
}
1007
1008
0
nlohmann::json DSA_GenerateParameters::ToJSON(void) const {
1009
0
    nlohmann::json j;
1010
0
    j["modifier"] = modifier.ToJSON();
1011
0
    return j;
1012
0
}
1013
1014
0
std::string ECDH_Derive::Name(void) const { return "ECDH_Derive"; }
1015
0
std::string ECDH_Derive::ToString(void) const {
1016
0
    std::stringstream ss;
1017
1018
0
    ss << "operation name: ECDH_Derive" << std::endl;
1019
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1020
0
    ss << "private key: " << priv.ToString() << std::endl;
1021
0
    ss << "public key X: " << pub.first.ToString() << std::endl;
1022
0
    ss << "public key Y: " << pub.second.ToString() << std::endl;
1023
1024
0
    return ss.str();
1025
0
}
1026
1027
0
nlohmann::json ECDH_Derive::ToJSON(void) const {
1028
0
    nlohmann::json j;
1029
0
    j["operation"] = "ECDH_Derive";
1030
0
    j["curveType"] = curveType.ToJSON();
1031
0
    j["priv"] = priv.ToJSON();
1032
0
    j["pub_x"] = pub.first.ToJSON();
1033
0
    j["pub_y"] = pub.second.ToJSON();
1034
0
    j["modifier"] = modifier.ToJSON();
1035
0
    return j;
1036
0
}
1037
1038
0
std::string ECIES_Encrypt::Name(void) const { return "ECIES_Encrypt"; }
1039
0
std::string ECIES_Encrypt::ToString(void) const {
1040
0
    std::stringstream ss;
1041
1042
0
    ss << "operation name: ECIES_Encrypt" << std::endl;
1043
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
1044
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1045
0
    ss << "private key: " << priv.ToString() << std::endl;
1046
0
    ss << "public key X: " << pub.first.ToString() << std::endl;
1047
0
    ss << "public key Y: " << pub.second.ToString() << std::endl;
1048
0
    ss << "cipher: " << repository::CipherToString(cipherType.Get()) << std::endl;
1049
0
    ss << "iv: " << (iv ? util::HexDump(iv->Get()) : "nullopt") << std::endl;
1050
1051
0
    return ss.str();
1052
0
}
1053
1054
0
nlohmann::json ECIES_Encrypt::ToJSON(void) const {
1055
0
    nlohmann::json j;
1056
0
    j["operation"] = "ECIES_Encrypt";
1057
0
    j["cleartext"] = cleartext.ToJSON();
1058
0
    j["curveType"] = curveType.ToJSON();
1059
0
    j["priv"] = priv.ToJSON();
1060
0
    j["pub_x"] = pub.first.ToJSON();
1061
0
    j["pub_y"] = pub.second.ToJSON();
1062
0
    j["cipherType"] = cipherType.ToJSON();
1063
0
    j["iv_enabled"] = (bool)(iv != std::nullopt);
1064
0
    j["iv"] = iv != std::nullopt ? iv->ToJSON() : "";
1065
0
    j["modifier"] = modifier.ToJSON();
1066
0
    return j;
1067
0
}
1068
1069
0
std::string ECIES_Decrypt::Name(void) const { return "ECIES_Decrypt"; }
1070
0
std::string ECIES_Decrypt::ToString(void) const {
1071
0
    std::stringstream ss;
1072
1073
0
    ss << "operation name: ECIES_Decrypt" << std::endl;
1074
0
    ss << "ciphertext: " << util::HexDump(ciphertext.Get()) << std::endl;
1075
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1076
0
    ss << "private key: " << priv.ToString() << std::endl;
1077
0
    ss << "public key X: " << pub.first.ToString() << std::endl;
1078
0
    ss << "public key Y: " << pub.second.ToString() << std::endl;
1079
0
    ss << "cipher: " << repository::CipherToString(cipherType.Get()) << std::endl;
1080
0
    ss << "iv: " << (iv ? util::HexDump(iv->Get()) : "nullopt") << std::endl;
1081
1082
0
    return ss.str();
1083
0
}
1084
1085
0
nlohmann::json ECIES_Decrypt::ToJSON(void) const {
1086
0
    nlohmann::json j;
1087
0
    j["operation"] = "ECIES_Decrypt";
1088
0
    j["ciphertext"] = ciphertext.ToJSON();
1089
0
    j["curveType"] = curveType.ToJSON();
1090
0
    j["priv"] = priv.ToJSON();
1091
0
    j["pub_x"] = pub.first.ToJSON();
1092
0
    j["pub_y"] = pub.second.ToJSON();
1093
0
    j["cipherType"] = cipherType.ToJSON();
1094
0
    j["iv_enabled"] = (bool)(iv != std::nullopt);
1095
0
    j["iv"] = iv != std::nullopt ? iv->ToJSON() : "";
1096
0
    j["modifier"] = modifier.ToJSON();
1097
0
    return j;
1098
0
}
1099
1100
0
std::string ECC_Point_Add::Name(void) const { return "ECC_Point_Add"; }
1101
0
std::string ECC_Point_Add::ToString(void) const {
1102
0
    std::stringstream ss;
1103
1104
0
    ss << "operation name: ECC_Point_Add" << std::endl;
1105
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1106
0
    ss << "A X: " << a.first.ToString() << std::endl;
1107
0
    ss << "A Y: " << a.second.ToString() << std::endl;
1108
0
    ss << "B X: " << b.first.ToString() << std::endl;
1109
0
    ss << "B Y: " << b.second.ToString() << std::endl;
1110
1111
0
    return ss.str();
1112
0
}
1113
1114
0
nlohmann::json ECC_Point_Add::ToJSON(void) const {
1115
0
    nlohmann::json j;
1116
0
    j["operation"] = "ECC_Point_Add";
1117
0
    j["curveType"] = curveType.ToJSON();
1118
1119
0
    j["a_x"] = a.first.ToJSON();
1120
0
    j["a_y"] = a.second.ToJSON();
1121
1122
0
    j["b_x"] = b.first.ToJSON();
1123
0
    j["b_y"] = b.second.ToJSON();
1124
1125
0
    j["modifier"] = modifier.ToJSON();
1126
0
    return j;
1127
0
}
1128
1129
0
std::string ECC_Point_Sub::Name(void) const { return "ECC_Point_Sub"; }
1130
0
std::string ECC_Point_Sub::ToString(void) const {
1131
0
    std::stringstream ss;
1132
1133
0
    ss << "operation name: ECC_Point_Sub" << std::endl;
1134
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1135
0
    ss << "A X: " << a.first.ToString() << std::endl;
1136
0
    ss << "A Y: " << a.second.ToString() << std::endl;
1137
0
    ss << "B X: " << b.first.ToString() << std::endl;
1138
0
    ss << "B Y: " << b.second.ToString() << std::endl;
1139
1140
0
    return ss.str();
1141
0
}
1142
1143
0
nlohmann::json ECC_Point_Sub::ToJSON(void) const {
1144
0
    nlohmann::json j;
1145
0
    j["operation"] = "ECC_Point_Sub";
1146
0
    j["curveType"] = curveType.ToJSON();
1147
1148
0
    j["a_x"] = a.first.ToJSON();
1149
0
    j["a_y"] = a.second.ToJSON();
1150
1151
0
    j["b_x"] = b.first.ToJSON();
1152
0
    j["b_y"] = b.second.ToJSON();
1153
1154
0
    j["modifier"] = modifier.ToJSON();
1155
0
    return j;
1156
0
}
1157
1158
0
std::string ECC_Point_Mul::Name(void) const { return "ECC_Point_Mul"; }
1159
0
std::string ECC_Point_Mul::ToString(void) const {
1160
0
    std::stringstream ss;
1161
1162
0
    ss << "operation name: ECC_Point_Mul" << std::endl;
1163
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1164
0
    ss << "A X: " << a.first.ToString() << std::endl;
1165
0
    ss << "A Y: " << a.second.ToString() << std::endl;
1166
0
    ss << "B: " << b.ToString() << std::endl;
1167
1168
0
    return ss.str();
1169
0
}
1170
1171
0
nlohmann::json ECC_Point_Mul::ToJSON(void) const {
1172
0
    nlohmann::json j;
1173
0
    j["operation"] = "ECC_Point_Mul";
1174
0
    j["curveType"] = curveType.ToJSON();
1175
1176
0
    j["a_x"] = a.first.ToJSON();
1177
0
    j["a_y"] = a.second.ToJSON();
1178
1179
0
    j["b"] = b.ToJSON();
1180
1181
0
    j["modifier"] = modifier.ToJSON();
1182
0
    return j;
1183
0
}
1184
1185
0
std::string ECC_Point_Neg::Name(void) const { return "ECC_Point_Neg"; }
1186
0
std::string ECC_Point_Neg::ToString(void) const {
1187
0
    std::stringstream ss;
1188
1189
0
    ss << "operation name: ECC_Point_Neg" << std::endl;
1190
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1191
0
    ss << "A X: " << a.first.ToString() << std::endl;
1192
0
    ss << "A Y: " << a.second.ToString() << std::endl;
1193
1194
0
    return ss.str();
1195
0
}
1196
1197
0
nlohmann::json ECC_Point_Neg::ToJSON(void) const {
1198
0
    nlohmann::json j;
1199
0
    j["curveType"] = curveType.ToJSON();
1200
1201
0
    j["a_x"] = a.first.ToJSON();
1202
0
    j["a_y"] = a.second.ToJSON();
1203
1204
0
    j["modifier"] = modifier.ToJSON();
1205
0
    return j;
1206
0
}
1207
1208
0
std::string ECC_Point_Dbl::Name(void) const { return "ECC_Point_Dbl"; }
1209
0
std::string ECC_Point_Dbl::ToString(void) const {
1210
0
    std::stringstream ss;
1211
1212
0
    ss << "operation name: ECC_Point_Dbl" << std::endl;
1213
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1214
0
    ss << "A X: " << a.first.ToString() << std::endl;
1215
0
    ss << "A Y: " << a.second.ToString() << std::endl;
1216
1217
0
    return ss.str();
1218
0
}
1219
1220
0
nlohmann::json ECC_Point_Dbl::ToJSON(void) const {
1221
0
    nlohmann::json j;
1222
0
    j["curveType"] = curveType.ToJSON();
1223
1224
0
    j["a_x"] = a.first.ToJSON();
1225
0
    j["a_y"] = a.second.ToJSON();
1226
1227
0
    j["modifier"] = modifier.ToJSON();
1228
0
    return j;
1229
0
}
1230
1231
0
std::string ECC_Point_Cmp::Name(void) const { return "ECC_Point_Cmp"; }
1232
0
std::string ECC_Point_Cmp::ToString(void) const {
1233
0
    std::stringstream ss;
1234
1235
0
    ss << "operation name: ECC_Point_Cmp" << std::endl;
1236
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1237
0
    ss << "A X: " << a.first.ToString() << std::endl;
1238
0
    ss << "A Y: " << a.second.ToString() << std::endl;
1239
0
    ss << "B X: " << b.first.ToString() << std::endl;
1240
0
    ss << "B Y: " << b.second.ToString() << std::endl;
1241
1242
0
    return ss.str();
1243
0
}
1244
1245
0
nlohmann::json ECC_Point_Cmp::ToJSON(void) const {
1246
0
    nlohmann::json j;
1247
0
    j["operation"] = "ECC_Point_Cmp";
1248
0
    j["curveType"] = curveType.ToJSON();
1249
1250
0
    j["a_x"] = a.first.ToJSON();
1251
0
    j["a_y"] = a.second.ToJSON();
1252
1253
0
    j["b_x"] = b.first.ToJSON();
1254
0
    j["b_y"] = b.second.ToJSON();
1255
1256
0
    j["modifier"] = modifier.ToJSON();
1257
0
    return j;
1258
0
}
1259
1260
0
std::string DH_GenerateKeyPair::Name(void) const { return "DH_GenerateKeyPair"; }
1261
0
std::string DH_GenerateKeyPair::ToString(void) const {
1262
0
    std::stringstream ss;
1263
1264
0
    ss << "operation name: DH_GenerateKeyPair" << std::endl;
1265
0
    ss << "prime: " << prime.ToString() << std::endl;
1266
0
    ss << "base: " << base.ToString() << std::endl;
1267
1268
0
    return ss.str();
1269
0
}
1270
1271
0
nlohmann::json DH_GenerateKeyPair::ToJSON(void) const {
1272
0
    nlohmann::json j;
1273
0
    j["operation"] = "DH_GenerateKeyPair";
1274
0
    j["prime"] = prime.ToJSON();
1275
0
    j["base"] = base.ToJSON();
1276
0
    j["modifier"] = modifier.ToJSON();
1277
0
    return j;
1278
0
}
1279
1280
0
std::string DH_Derive::Name(void) const { return "DH_Derive"; }
1281
0
std::string DH_Derive::ToString(void) const {
1282
0
    std::stringstream ss;
1283
1284
0
    ss << "operation name: DH_Derive" << std::endl;
1285
0
    ss << "prime: " << prime.ToString() << std::endl;
1286
0
    ss << "base: " << base.ToString() << std::endl;
1287
0
    ss << "public key: " << pub.ToString() << std::endl;
1288
0
    ss << "private key: " << priv.ToString() << std::endl;
1289
1290
0
    return ss.str();
1291
0
}
1292
1293
0
nlohmann::json DH_Derive::ToJSON(void) const {
1294
0
    nlohmann::json j;
1295
0
    j["operation"] = "DH_Derive";
1296
0
    j["prime"] = prime.ToJSON();
1297
0
    j["base"] = base.ToJSON();
1298
0
    j["pub"] = pub.ToJSON();
1299
0
    j["priv"] = priv.ToJSON();
1300
0
    j["modifier"] = modifier.ToJSON();
1301
0
    return j;
1302
0
}
1303
1304
0
std::string BignumCalc::Name(void) const { return "BignumCalc"; }
1305
0
std::string BignumCalc::ToString(void) const {
1306
0
    std::stringstream ss;
1307
1308
0
    ss << "operation name: BignumCalc" << std::endl;
1309
0
    ss << "calc operation: " << repository::CalcOpToString(calcOp.Get()) << std::endl;
1310
0
    ss << "bignum 1: " << bn0.ToString() << std::endl;
1311
0
    ss << "bignum 2: " << bn1.ToString() << std::endl;
1312
0
    ss << "bignum 3: " << bn2.ToString() << std::endl;
1313
0
    ss << "bignum 4: " << bn3.ToString() << std::endl;
1314
1315
0
    return ss.str();
1316
0
}
1317
1318
0
nlohmann::json BignumCalc::ToJSON(void) const {
1319
0
    nlohmann::json j;
1320
0
    j["operation"] = "BignumCalc";
1321
0
    j["calcOp"] = calcOp.ToJSON();
1322
0
    j["bn0"] = bn0.ToJSON();
1323
0
    j["bn1"] = bn1.ToJSON();
1324
0
    j["bn2"] = bn2.ToJSON();
1325
0
    j["bn3"] = bn3.ToJSON();
1326
0
    j["modifier"] = modifier.ToJSON();
1327
0
    return j;
1328
0
}
1329
1330
0
std::string BignumCalc_Fp2::Name(void) const { return "BignumCalc_Fp2"; }
1331
0
std::string BignumCalc_Fp2::ToString(void) const {
1332
0
    std::stringstream ss;
1333
1334
0
    ss << "operation name: BignumCalc_Fp2" << std::endl;
1335
0
    ss << "calc operation: " << repository::CalcOpToString(calcOp.Get()) << std::endl;
1336
0
    ss << "Fp2 1 x: " << bn0.first.ToString() << std::endl;
1337
0
    ss << "Fp2 1 x: " << bn0.second.ToString() << std::endl;
1338
0
    ss << "Fp2 2 x: " << bn1.first.ToString() << std::endl;
1339
0
    ss << "Fp2 2 x: " << bn1.second.ToString() << std::endl;
1340
0
    ss << "Fp2 3 x: " << bn2.first.ToString() << std::endl;
1341
0
    ss << "Fp2 3 x: " << bn2.second.ToString() << std::endl;
1342
0
    ss << "Fp2 4 x: " << bn3.first.ToString() << std::endl;
1343
0
    ss << "Fp2 4 x: " << bn3.second.ToString() << std::endl;
1344
1345
0
    return ss.str();
1346
0
}
1347
1348
0
nlohmann::json BignumCalc_Fp2::ToJSON(void) const {
1349
0
    nlohmann::json j;
1350
    /* TODO */
1351
0
    return j;
1352
0
}
1353
1354
0
std::string BignumCalc_Fp12::Name(void) const { return "BignumCalc_Fp12"; }
1355
0
std::string BignumCalc_Fp12::ToString(void) const {
1356
0
    std::stringstream ss;
1357
1358
0
    ss << "operation name: BignumCalc_Fp12" << std::endl;
1359
0
    ss << "calc operation: " << repository::CalcOpToString(calcOp.Get()) << std::endl;
1360
0
    ss << "bn0 1: " << bn0.bn1.ToString() << std::endl;
1361
0
    ss << "bn0 2: " << bn0.bn2.ToString() << std::endl;
1362
0
    ss << "bn0 3: " << bn0.bn3.ToString() << std::endl;
1363
0
    ss << "bn0 4: " << bn0.bn4.ToString() << std::endl;
1364
0
    ss << "bn0 5: " << bn0.bn5.ToString() << std::endl;
1365
0
    ss << "bn0 6: " << bn0.bn6.ToString() << std::endl;
1366
0
    ss << "bn0 7: " << bn0.bn7.ToString() << std::endl;
1367
0
    ss << "bn0 8: " << bn0.bn8.ToString() << std::endl;
1368
0
    ss << "bn0 9: " << bn0.bn9.ToString() << std::endl;
1369
0
    ss << "bn0 10: " << bn0.bn10.ToString() << std::endl;
1370
0
    ss << "bn0 11: " << bn0.bn11.ToString() << std::endl;
1371
0
    ss << "bn0 12: " << bn0.bn12.ToString() << std::endl;
1372
1373
0
    ss << std::endl;
1374
1375
0
    ss << "bn1 1: " << bn1.bn1.ToString() << std::endl;
1376
0
    ss << "bn1 2: " << bn1.bn2.ToString() << std::endl;
1377
0
    ss << "bn1 3: " << bn1.bn3.ToString() << std::endl;
1378
0
    ss << "bn1 4: " << bn1.bn4.ToString() << std::endl;
1379
0
    ss << "bn1 5: " << bn1.bn5.ToString() << std::endl;
1380
0
    ss << "bn1 6: " << bn1.bn6.ToString() << std::endl;
1381
0
    ss << "bn1 7: " << bn1.bn7.ToString() << std::endl;
1382
0
    ss << "bn1 8: " << bn1.bn8.ToString() << std::endl;
1383
0
    ss << "bn1 9: " << bn1.bn9.ToString() << std::endl;
1384
0
    ss << "bn1 10: " << bn1.bn10.ToString() << std::endl;
1385
0
    ss << "bn1 11: " << bn1.bn11.ToString() << std::endl;
1386
0
    ss << "bn1 12: " << bn1.bn12.ToString() << std::endl;
1387
1388
0
    return ss.str();
1389
0
}
1390
1391
0
nlohmann::json BignumCalc_Fp12::ToJSON(void) const {
1392
0
    nlohmann::json j;
1393
    /* TODO */
1394
0
    return j;
1395
0
}
1396
1397
0
std::string BLS_PrivateToPublic::Name(void) const { return "BLS_PrivateToPublic"; }
1398
0
std::string BLS_PrivateToPublic::ToString(void) const {
1399
0
    std::stringstream ss;
1400
1401
0
    ss << "operation name: BLS_PrivateToPublic" << std::endl;
1402
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1403
0
    ss << "private key: " << priv.ToString() << std::endl;
1404
1405
0
    return ss.str();
1406
0
}
1407
1408
0
nlohmann::json BLS_PrivateToPublic::ToJSON(void) const {
1409
0
    nlohmann::json j;
1410
0
    j["priv"] = priv.ToJSON();
1411
0
    j["curveType"] = curveType.ToJSON();
1412
0
    j["modifier"] = modifier.ToJSON();
1413
0
    return j;
1414
0
}
1415
1416
0
std::string BLS_PrivateToPublic_G2::Name(void) const { return "BLS_PrivateToPublic_G2"; }
1417
0
std::string BLS_PrivateToPublic_G2::ToString(void) const {
1418
0
    std::stringstream ss;
1419
1420
0
    ss << "operation name: BLS_PrivateToPublic_G2" << std::endl;
1421
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1422
0
    ss << "private key: " << priv.ToString() << std::endl;
1423
1424
0
    return ss.str();
1425
0
}
1426
1427
0
nlohmann::json BLS_PrivateToPublic_G2::ToJSON(void) const {
1428
0
    nlohmann::json j;
1429
0
    j["priv"] = priv.ToJSON();
1430
0
    j["curveType"] = curveType.ToJSON();
1431
0
    j["modifier"] = modifier.ToJSON();
1432
0
    return j;
1433
0
}
1434
1435
0
std::string BLS_Sign::Name(void) const { return "BLS_Sign"; }
1436
0
std::string BLS_Sign::ToString(void) const {
1437
0
    std::stringstream ss;
1438
1439
0
    ss << "operation name: BLS_Sign" << std::endl;
1440
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1441
0
    ss << "private key: " << priv.ToString() << std::endl;
1442
0
    if ( hashOrPoint == true ) {
1443
0
        ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
1444
0
    } else {
1445
0
        ss << "point V: " << point.first.first.ToString() << std::endl;
1446
0
        ss << "point W: " << point.first.second.ToString() << std::endl;
1447
0
        ss << "point X: " << point.second.first.ToString() << std::endl;
1448
0
        ss << "point Y: " << point.second.second.ToString() << std::endl;
1449
0
    }
1450
0
    ss << "dest: " << util::HexDump(dest.Get()) << std::endl;
1451
0
    ss << "aug: " << util::HexDump(aug.Get()) << std::endl;
1452
1453
0
    return ss.str();
1454
0
}
1455
1456
0
nlohmann::json BLS_Sign::ToJSON(void) const {
1457
0
    nlohmann::json j;
1458
1459
0
    j["curveType"] = curveType.ToJSON();
1460
1461
0
    j["hashOrPoint"] = hashOrPoint;
1462
1463
0
    j["priv"] = priv.ToJSON();
1464
1465
0
    if ( hashOrPoint == true ) {
1466
0
        j["cleartext"] = cleartext.ToJSON();
1467
0
    } else {
1468
0
        j["g2_v"] = point.first.first.ToJSON();
1469
0
        j["g2_w"] = point.first.second.ToJSON();
1470
0
        j["g2_x"] = point.second.first.ToJSON();
1471
0
        j["g2_y"] = point.second.second.ToJSON();
1472
0
    }
1473
0
    j["dest"] = dest.ToJSON();
1474
0
    j["aug"] = aug.ToJSON();
1475
1476
0
    j["modifier"] = modifier.ToJSON();
1477
1478
0
    return j;
1479
0
}
1480
1481
0
std::string BLS_Verify::Name(void) const { return "BLS_Verify"; }
1482
0
std::string BLS_Verify::ToString(void) const {
1483
0
    std::stringstream ss;
1484
1485
0
    ss << "operation name: BLS_Verify" << std::endl;
1486
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1487
0
    ss << "public key X: " << pub.first.ToString() << std::endl;
1488
0
    ss << "public key Y: " << pub.second.ToString() << std::endl;
1489
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
1490
0
    ss << "signature V: " << signature.first.first.ToString() << std::endl;
1491
0
    ss << "signature W: " << signature.first.second.ToString() << std::endl;
1492
0
    ss << "signature X: " << signature.second.first.ToString() << std::endl;
1493
0
    ss << "signature Y: " << signature.second.second.ToString() << std::endl;
1494
0
    ss << "dest: " << util::HexDump(dest.Get()) << std::endl;
1495
1496
0
    return ss.str();
1497
0
}
1498
1499
0
nlohmann::json BLS_Verify::ToJSON(void) const {
1500
0
    nlohmann::json j;
1501
0
    j["curveType"] = curveType.ToJSON();
1502
1503
0
    j["cleartext"] = cleartext.ToJSON();
1504
1505
0
    j["g1_x"] = pub.first.ToJSON();
1506
0
    j["g1_y"] = pub.second.ToJSON();
1507
1508
0
    j["g2_v"] = signature.first.first.ToJSON();
1509
0
    j["g2_w"] = signature.first.second.ToJSON();
1510
0
    j["g2_x"] = signature.second.first.ToJSON();
1511
0
    j["g2_y"] = signature.second.second.ToJSON();
1512
1513
0
    j["dest"] = dest.ToJSON();
1514
1515
0
    j["modifier"] = modifier.ToJSON();
1516
0
    return j;
1517
0
}
1518
1519
0
std::string BLS_BatchSign::Name(void) const { return "BLS_BatchSign"; }
1520
0
std::string BLS_BatchSign::ToString(void) const {
1521
0
    std::stringstream ss;
1522
1523
0
    ss << "operation name: BLS_BatchSign" << std::endl;
1524
1525
0
    for (const auto& cur : bf.c) {
1526
0
        ss << "priv: " << cur.priv.ToString() << std::endl;
1527
0
        ss << "G1 X: " << cur.g1.first.ToString() << std::endl;
1528
0
        ss << "G1 Y: " << cur.g1.second.ToString() << std::endl;
1529
0
    }
1530
0
    return ss.str();
1531
0
}
1532
1533
0
nlohmann::json BLS_BatchSign::ToJSON(void) const {
1534
0
    nlohmann::json j;
1535
    /* TODO */
1536
0
    return j;
1537
0
}
1538
1539
0
std::string BLS_BatchVerify::Name(void) const { return "BLS_BatchVerify"; }
1540
0
std::string BLS_BatchVerify::ToString(void) const {
1541
0
    std::stringstream ss;
1542
1543
0
    for (const auto& cur : bf.c) {
1544
0
        ss << "G1 X: " << cur.g1.first.ToString() << std::endl;
1545
0
        ss << "G1 Y: " << cur.g1.second.ToString() << std::endl;
1546
0
        ss << std::endl;
1547
0
        ss << "G2 V: " << cur.g2.first.first.ToString() << std::endl;
1548
0
        ss << "G2 W: " << cur.g2.first.second.ToString() << std::endl;
1549
0
        ss << "G2 X: " << cur.g2.second.first.ToString() << std::endl;
1550
0
        ss << "G2 Y: " << cur.g2.second.second.ToString() << std::endl;
1551
0
        ss << "----------" << std::endl;
1552
0
    }
1553
1554
    /* TODO */
1555
0
    return ss.str();
1556
0
}
1557
1558
0
nlohmann::json BLS_BatchVerify::ToJSON(void) const {
1559
0
    nlohmann::json j;
1560
0
    j["operation"] = "BLS_BatchVerify";
1561
0
    j["modifier"] = modifier.ToJSON();
1562
0
    j["bf"] = bf.ToJSON();
1563
0
    return j;
1564
0
}
1565
1566
0
std::string BLS_Pairing::Name(void) const { return "BLS_Pairing"; }
1567
0
std::string BLS_Pairing::ToString(void) const {
1568
0
    std::stringstream ss;
1569
1570
0
    ss << "operation name: BLS_Pairing" << std::endl;
1571
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1572
0
    ss << "G1 X: " << g1.first.ToString() << std::endl;
1573
0
    ss << "G1 Y: " << g1.second.ToString() << std::endl;
1574
0
    ss << "G2 V: " << g2.first.first.ToString() << std::endl;
1575
0
    ss << "G2 W: " << g2.first.second.ToString() << std::endl;
1576
0
    ss << "G2 X: " << g2.second.first.ToString() << std::endl;
1577
0
    ss << "G2 Y: " << g2.second.second.ToString() << std::endl;
1578
1579
0
    return ss.str();
1580
0
}
1581
1582
0
nlohmann::json BLS_Pairing::ToJSON(void) const {
1583
0
    nlohmann::json j;
1584
0
    j["curveType"] = curveType.ToJSON();
1585
0
    j["modifier"] = modifier.ToJSON();
1586
0
    j["g1_x"] = g1.first.ToJSON();
1587
0
    j["g1_y"] = g1.second.ToJSON();
1588
0
    j["g2_v"] = g2.first.first.ToJSON();
1589
0
    j["g2_w"] = g2.first.second.ToJSON();
1590
0
    j["g2_x"] = g2.second.first.ToJSON();
1591
0
    j["g2_y"] = g2.second.second.ToJSON();
1592
0
    return j;
1593
0
}
1594
1595
0
std::string BLS_MillerLoop::Name(void) const { return "BLS_MillerLoop"; }
1596
0
std::string BLS_MillerLoop::ToString(void) const {
1597
0
    std::stringstream ss;
1598
1599
0
    ss << "operation name: BLS_MillerLoop" << std::endl;
1600
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1601
0
    ss << "G1 X: " << g1.first.ToString() << std::endl;
1602
0
    ss << "G1 Y: " << g1.second.ToString() << std::endl;
1603
0
    ss << "G2 V: " << g2.first.first.ToString() << std::endl;
1604
0
    ss << "G2 W: " << g2.first.second.ToString() << std::endl;
1605
0
    ss << "G2 X: " << g2.second.first.ToString() << std::endl;
1606
0
    ss << "G2 Y: " << g2.second.second.ToString() << std::endl;
1607
1608
0
    return ss.str();
1609
0
}
1610
1611
0
nlohmann::json BLS_MillerLoop::ToJSON(void) const {
1612
0
    nlohmann::json j;
1613
0
    j["curveType"] = curveType.ToJSON();
1614
0
    j["modifier"] = modifier.ToJSON();
1615
0
    return j;
1616
0
}
1617
1618
0
std::string BLS_FinalExp::Name(void) const { return "BLS_FinalExp"; }
1619
0
std::string BLS_FinalExp::ToString(void) const {
1620
0
    std::stringstream ss;
1621
1622
0
    ss << "operation name: BLS_FinalExp" << std::endl;
1623
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1624
0
    ss << "Fp12 c0.b0.a0: " << fp12.bn1.ToString() << std::endl;
1625
0
    ss << "Fp12 c0.b0.a1: " << fp12.bn2.ToString() << std::endl;
1626
0
    ss << "Fp12 c0.b1.a0: " << fp12.bn3.ToString() << std::endl;
1627
0
    ss << "Fp12 c0.b1.a1: " << fp12.bn4.ToString() << std::endl;
1628
0
    ss << "Fp12 c0.b2.a0: " << fp12.bn5.ToString() << std::endl;
1629
0
    ss << "Fp12 c0.b2.a1: " << fp12.bn6.ToString() << std::endl;
1630
0
    ss << "Fp12 c1.b0.a0: " << fp12.bn7.ToString() << std::endl;
1631
0
    ss << "Fp12 c1.b0.a1: " << fp12.bn8.ToString() << std::endl;
1632
0
    ss << "Fp12 c1.b1.a0: " << fp12.bn9.ToString() << std::endl;
1633
0
    ss << "Fp12 c1.b1.a1: " << fp12.bn10.ToString() << std::endl;
1634
0
    ss << "Fp12 c1.b2.a0: " << fp12.bn11.ToString() << std::endl;
1635
0
    ss << "Fp12 c1.b2.a1: " << fp12.bn12.ToString() << std::endl;
1636
1637
0
    return ss.str();
1638
0
}
1639
1640
0
nlohmann::json BLS_FinalExp::ToJSON(void) const {
1641
0
    nlohmann::json j;
1642
0
    j["curveType"] = curveType.ToJSON();
1643
0
    j["modifier"] = modifier.ToJSON();
1644
0
    j["fp12"] = fp12.ToJSON();
1645
0
    return j;
1646
0
}
1647
0
std::string BLS_Aggregate_G1::Name(void) const { return "BLS_Aggregate_G1"; }
1648
0
std::string BLS_Aggregate_G1::ToString(void) const {
1649
0
    std::stringstream ss;
1650
1651
0
    ss << "operation name: BLS_Aggregate_G1" << std::endl;
1652
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1653
1654
0
    for (const auto& g1 : points.points) {
1655
0
        ss << "    X: " << g1.first.ToString() << std::endl;
1656
0
        ss << "    Y: " << g1.second.ToString() << std::endl;
1657
0
        ss << std::endl;
1658
0
    }
1659
1660
0
    return ss.str();
1661
0
}
1662
1663
0
nlohmann::json BLS_Aggregate_G1::ToJSON(void) const {
1664
0
    nlohmann::json j;
1665
0
    j["curveType"] = curveType.ToJSON();
1666
0
    j["modifier"] = modifier.ToJSON();
1667
1668
0
    nlohmann::json points_json = nlohmann::json::array();
1669
1670
0
    for (const auto& g1 : points.points) {
1671
0
        nlohmann::json point;
1672
1673
0
        point["x"] = g1.first.ToJSON();
1674
0
        point["y"] = g1.second.ToJSON();
1675
1676
0
        points_json.push_back(point);
1677
0
    }
1678
1679
0
    j["points"] = points_json;
1680
1681
0
    return j;
1682
0
}
1683
1684
0
std::string BLS_Aggregate_G2::Name(void) const { return "BLS_Aggregate_G2"; }
1685
0
std::string BLS_Aggregate_G2::ToString(void) const {
1686
0
    std::stringstream ss;
1687
1688
0
    ss << "operation name: BLS_Aggregate_G2" << std::endl;
1689
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1690
1691
0
    for (const auto& g2 : points.points) {
1692
0
        ss << "    V:" << g2.first.first.ToString() << std::endl;
1693
0
        ss << "    W:" << g2.first.second.ToString() << std::endl;
1694
0
        ss << "    X:" << g2.second.first.ToString() << std::endl;
1695
0
        ss << "    Y:" << g2.second.second.ToString() << std::endl;
1696
0
        ss << std::endl;
1697
0
    }
1698
1699
0
    return ss.str();
1700
0
}
1701
1702
0
nlohmann::json BLS_Aggregate_G2::ToJSON(void) const {
1703
0
    nlohmann::json j;
1704
0
    j["curveType"] = curveType.ToJSON();
1705
0
    j["modifier"] = modifier.ToJSON();
1706
1707
0
    nlohmann::json points_json = nlohmann::json::array();
1708
1709
0
    for (const auto& g2 : points.points) {
1710
0
        nlohmann::json point;
1711
1712
0
        point["v"] = g2.first.first.ToJSON();
1713
0
        point["w"] = g2.first.second.ToJSON();
1714
0
        point["x"] = g2.second.first.ToJSON();
1715
0
        point["y"] = g2.second.second.ToJSON();
1716
1717
0
        points_json.push_back(point);
1718
0
    }
1719
1720
0
    j["points"] = points_json;
1721
0
    return j;
1722
0
}
1723
1724
0
std::string BLS_HashToG1::Name(void) const { return "BLS_HashToG1"; }
1725
0
std::string BLS_HashToG1::ToString(void) const {
1726
0
    std::stringstream ss;
1727
1728
0
    ss << "operation name: BLS_HashToG1" << std::endl;
1729
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1730
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
1731
0
    ss << "dest: " << util::HexDump(dest.Get()) << std::endl;
1732
0
    ss << "aug: " << util::HexDump(aug.Get()) << std::endl;
1733
1734
0
    return ss.str();
1735
0
}
1736
1737
0
nlohmann::json BLS_HashToG1::ToJSON(void) const {
1738
0
    nlohmann::json j;
1739
0
    j["curveType"] = curveType.ToJSON();
1740
0
    j["cleartext"] = cleartext.ToJSON();
1741
0
    j["dest"] = dest.ToJSON();
1742
0
    j["aug"] = aug.ToJSON();
1743
0
    j["modifier"] = modifier.ToJSON();
1744
0
    return j;
1745
0
}
1746
1747
0
std::string BLS_HashToG2::Name(void) const { return "BLS_HashToG2"; }
1748
0
std::string BLS_HashToG2::ToString(void) const {
1749
0
    std::stringstream ss;
1750
1751
0
    ss << "operation name: BLS_HashToG2" << std::endl;
1752
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1753
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
1754
0
    ss << "dest: " << util::HexDump(dest.Get()) << std::endl;
1755
0
    ss << "aug: " << util::HexDump(aug.Get()) << std::endl;
1756
1757
0
    return ss.str();
1758
0
}
1759
1760
0
nlohmann::json BLS_HashToG2::ToJSON(void) const {
1761
0
    nlohmann::json j;
1762
0
    j["curveType"] = curveType.ToJSON();
1763
0
    j["cleartext"] = cleartext.ToJSON();
1764
0
    j["dest"] = dest.ToJSON();
1765
0
    j["aug"] = aug.ToJSON();
1766
0
    j["modifier"] = modifier.ToJSON();
1767
0
    return j;
1768
0
}
1769
1770
0
std::string BLS_MapToG1::Name(void) const { return "BLS_MapToG1"; }
1771
0
std::string BLS_MapToG1::ToString(void) const {
1772
0
    std::stringstream ss;
1773
1774
0
    ss << "operation name: BLS_MapToG1" << std::endl;
1775
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1776
0
    ss << "u: " << u.ToString() << std::endl;
1777
0
    ss << "v: " << v.ToString() << std::endl;
1778
1779
0
    return ss.str();
1780
0
}
1781
1782
0
nlohmann::json BLS_MapToG1::ToJSON(void) const {
1783
0
    nlohmann::json j;
1784
0
    j["curveType"] = curveType.ToJSON();
1785
0
    j["u"] = u.ToJSON();
1786
0
    j["v"] = v.ToJSON();
1787
0
    j["modifier"] = modifier.ToJSON();
1788
0
    return j;
1789
0
}
1790
1791
0
std::string BLS_MapToG2::Name(void) const { return "BLS_MapToG2"; }
1792
0
std::string BLS_MapToG2::ToString(void) const {
1793
0
    std::stringstream ss;
1794
1795
0
    ss << "operation name: BLS_MapToG2" << std::endl;
1796
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1797
0
    ss << "u_x: " << u.first.ToString() << std::endl;
1798
0
    ss << "u_y: " << u.second.ToString() << std::endl;
1799
0
    ss << "v_x: " << v.first.ToString() << std::endl;
1800
0
    ss << "v_y: " << v.second.ToString() << std::endl;
1801
1802
0
    return ss.str();
1803
0
}
1804
1805
0
nlohmann::json BLS_MapToG2::ToJSON(void) const {
1806
0
    nlohmann::json j;
1807
1808
0
    j["u_x"] = u.first.ToJSON();
1809
0
    j["u_y"] = u.second.ToJSON();
1810
0
    j["v_x"] = v.first.ToJSON();
1811
0
    j["v_y"] = v.second.ToJSON();
1812
1813
0
    return j;
1814
0
}
1815
1816
0
std::string BLS_IsG1OnCurve::Name(void) const { return "BLS_IsG1OnCurve"; }
1817
0
std::string BLS_IsG1OnCurve::ToString(void) const {
1818
0
    std::stringstream ss;
1819
1820
0
    ss << "operation name: BLS_IsG1OnCurve" << std::endl;
1821
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1822
0
    ss << "G1 X: " << g1.first.ToString() << std::endl;
1823
0
    ss << "G1 Y: " << g1.second.ToString() << std::endl;
1824
1825
0
    return ss.str();
1826
0
}
1827
1828
0
nlohmann::json BLS_IsG1OnCurve::ToJSON(void) const {
1829
0
    nlohmann::json j;
1830
0
    j["curveType"] = curveType.ToJSON();
1831
1832
0
    j["g1_x"] = g1.first.ToJSON();
1833
0
    j["g1_y"] = g1.second.ToJSON();
1834
1835
0
    j["modifier"] = modifier.ToJSON();
1836
0
    return j;
1837
0
}
1838
1839
0
std::string BLS_IsG2OnCurve::Name(void) const { return "BLS_IsG2OnCurve"; }
1840
0
std::string BLS_IsG2OnCurve::ToString(void) const {
1841
0
    std::stringstream ss;
1842
1843
0
    ss << "operation name: BLS_IsG2OnCurve" << std::endl;
1844
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1845
0
    ss << "G2 V: " << g2.first.first.ToString() << std::endl;
1846
0
    ss << "G2 W: " << g2.first.second.ToString() << std::endl;
1847
0
    ss << "G2 X: " << g2.second.first.ToString() << std::endl;
1848
0
    ss << "G2 Y: " << g2.second.second.ToString() << std::endl;
1849
1850
0
    return ss.str();
1851
0
}
1852
1853
0
nlohmann::json BLS_IsG2OnCurve::ToJSON(void) const {
1854
0
    nlohmann::json j;
1855
0
    j["curveType"] = curveType.ToJSON();
1856
1857
0
    j["g2_v"] = g2.first.first.ToJSON();
1858
0
    j["g2_w"] = g2.first.second.ToJSON();
1859
0
    j["g2_x"] = g2.second.first.ToJSON();
1860
0
    j["g2_y"] = g2.second.second.ToJSON();
1861
1862
0
    j["modifier"] = modifier.ToJSON();
1863
0
    return j;
1864
0
}
1865
1866
0
std::string BLS_GenerateKeyPair::Name(void) const { return "BLS_GenerateKeyPair"; }
1867
0
std::string BLS_GenerateKeyPair::ToString(void) const {
1868
0
    std::stringstream ss;
1869
1870
0
    ss << "operation name: BLS_GenerateKeyPair" << std::endl;
1871
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1872
0
    ss << "ikm: " << util::HexDump(ikm.Get()) << std::endl;
1873
0
    ss << "info: " << util::HexDump(info.Get()) << std::endl;
1874
1875
0
    return ss.str();
1876
0
}
1877
1878
0
nlohmann::json BLS_GenerateKeyPair::ToJSON(void) const {
1879
0
    nlohmann::json j;
1880
0
    j["curveType"] = curveType.ToJSON();
1881
0
    j["modifier"] = modifier.ToJSON();
1882
0
    j["ikm"] = ikm.ToJSON();
1883
0
    j["info"] = info.ToJSON();
1884
0
    return j;
1885
0
}
1886
1887
0
std::string BLS_Decompress_G1::Name(void) const { return "BLS_Decompress_G1"; }
1888
0
std::string BLS_Decompress_G1::ToString(void) const {
1889
0
    std::stringstream ss;
1890
1891
0
    ss << "operation name: BLS_Decompress_G1" << std::endl;
1892
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1893
0
    ss << "compressed: " << compressed.ToString() << std::endl;
1894
1895
0
    return ss.str();
1896
0
}
1897
1898
0
nlohmann::json BLS_Decompress_G1::ToJSON(void) const {
1899
0
    nlohmann::json j;
1900
0
    j["curveType"] = curveType.ToJSON();
1901
0
    j["compressed"] = compressed.ToJSON();
1902
0
    j["modifier"] = modifier.ToJSON();
1903
0
    return j;
1904
0
}
1905
1906
0
std::string BLS_Compress_G1::Name(void) const { return "BLS_Compress_G1"; }
1907
0
std::string BLS_Compress_G1::ToString(void) const {
1908
0
    std::stringstream ss;
1909
1910
0
    ss << "operation name: BLS_Compress_G1" << std::endl;
1911
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1912
0
    ss << "uncompressed X:" << uncompressed.first.ToString() << std::endl;
1913
0
    ss << "uncompressed Y:" << uncompressed.second.ToString() << std::endl;
1914
1915
0
    return ss.str();
1916
0
}
1917
1918
0
nlohmann::json BLS_Compress_G1::ToJSON(void) const {
1919
0
    nlohmann::json j;
1920
0
    j["curveType"] = curveType.ToJSON();
1921
0
    j["g1_x"] = uncompressed.first.ToJSON();
1922
0
    j["g1_y"] = uncompressed.second.ToJSON();
1923
0
    j["modifier"] = modifier.ToJSON();
1924
0
    return j;
1925
0
}
1926
1927
0
std::string BLS_Decompress_G2::Name(void) const { return "BLS_Decompress_G2"; }
1928
0
std::string BLS_Decompress_G2::ToString(void) const {
1929
0
    std::stringstream ss;
1930
1931
0
    ss << "operation name: BLS_Decompress_G2" << std::endl;
1932
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1933
0
    ss << "compressed X: " << compressed.first.ToString() << std::endl;
1934
0
    ss << "compressed Y: " << compressed.second.ToString() << std::endl;
1935
1936
0
    return ss.str();
1937
0
}
1938
1939
0
nlohmann::json BLS_Decompress_G2::ToJSON(void) const {
1940
0
    nlohmann::json j;
1941
0
    j["curveType"] = curveType.ToJSON();
1942
0
    j["g1_x"] = compressed.first.ToJSON();
1943
0
    j["g1_y"] = compressed.second.ToJSON();
1944
0
    j["modifier"] = modifier.ToJSON();
1945
0
    return j;
1946
0
}
1947
1948
0
std::string BLS_Compress_G2::Name(void) const { return "BLS_Compress_G2"; }
1949
0
std::string BLS_Compress_G2::ToString(void) const {
1950
0
    std::stringstream ss;
1951
1952
0
    ss << "operation name: BLS_Compress_G2" << std::endl;
1953
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1954
0
    ss << "uncompressed V:" << uncompressed.first.first.ToString() << std::endl;
1955
0
    ss << "uncompressed W:" << uncompressed.first.second.ToString() << std::endl;
1956
0
    ss << "uncompressed X:" << uncompressed.second.first.ToString() << std::endl;
1957
0
    ss << "uncompressed Y:" << uncompressed.second.second.ToString() << std::endl;
1958
1959
0
    return ss.str();
1960
0
}
1961
1962
0
nlohmann::json BLS_Compress_G2::ToJSON(void) const {
1963
0
    nlohmann::json j;
1964
0
    j["curveType"] = curveType.ToJSON();
1965
0
    j["g2_v"] = uncompressed.first.first.ToJSON();
1966
0
    j["g2_w"] = uncompressed.first.second.ToJSON();
1967
0
    j["g2_x"] = uncompressed.second.first.ToJSON();
1968
0
    j["g2_y"] = uncompressed.second.second.ToJSON();
1969
0
    j["modifier"] = modifier.ToJSON();
1970
0
    return j;
1971
0
}
1972
1973
0
std::string BLS_G1_Add::Name(void) const { return "BLS_G1_Add"; }
1974
0
std::string BLS_G1_Add::ToString(void) const {
1975
0
    std::stringstream ss;
1976
1977
0
    ss << "operation name: BLS_G1_Add" << std::endl;
1978
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
1979
0
    ss << "A X: " << a.first.ToString() << std::endl;
1980
0
    ss << "A Y: " << a.second.ToString() << std::endl;
1981
0
    ss << "B X: " << b.first.ToString() << std::endl;
1982
0
    ss << "B Y: " << b.second.ToString() << std::endl;
1983
1984
0
    return ss.str();
1985
0
}
1986
1987
0
nlohmann::json BLS_G1_Add::ToJSON(void) const {
1988
0
    nlohmann::json j;
1989
0
    j["operation"] = "BLS_G1_Add";
1990
0
    j["curveType"] = curveType.ToJSON();
1991
1992
0
    j["a_x"] = a.first.ToJSON();
1993
0
    j["a_y"] = a.second.ToJSON();
1994
1995
0
    j["b_x"] = b.first.ToJSON();
1996
0
    j["b_y"] = b.second.ToJSON();
1997
1998
0
    j["modifier"] = modifier.ToJSON();
1999
0
    return j;
2000
0
}
2001
2002
0
std::string BLS_G1_Mul::Name(void) const { return "BLS_G1_Mul"; }
2003
0
std::string BLS_G1_Mul::ToString(void) const {
2004
0
    std::stringstream ss;
2005
2006
0
    ss << "operation name: BLS_G1_Mul" << std::endl;
2007
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
2008
0
    ss << "A X: " << a.first.ToString() << std::endl;
2009
0
    ss << "A Y: " << a.second.ToString() << std::endl;
2010
0
    ss << "B: " << b.ToString() << std::endl;
2011
2012
0
    return ss.str();
2013
0
}
2014
2015
0
nlohmann::json BLS_G1_Mul::ToJSON(void) const {
2016
0
    nlohmann::json j;
2017
0
    j["operation"] = "BLS_G1_Mul";
2018
0
    j["curveType"] = curveType.ToJSON();
2019
2020
0
    j["a_x"] = a.first.ToJSON();
2021
0
    j["a_y"] = a.second.ToJSON();
2022
2023
0
    j["b"] = b.ToJSON();
2024
2025
0
    j["modifier"] = modifier.ToJSON();
2026
0
    return j;
2027
0
}
2028
2029
0
std::string BLS_G1_IsEq::Name(void) const { return "BLS_G1_IsEq"; }
2030
0
std::string BLS_G1_IsEq::ToString(void) const {
2031
0
    std::stringstream ss;
2032
2033
0
    ss << "operation name: BLS_G1_IsEq" << std::endl;
2034
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
2035
0
    ss << "A X: " << a.first.ToString() << std::endl;
2036
0
    ss << "A Y: " << a.second.ToString() << std::endl;
2037
0
    ss << "B X: " << b.first.ToString() << std::endl;
2038
0
    ss << "B Y: " << b.second.ToString() << std::endl;
2039
2040
0
    return ss.str();
2041
0
}
2042
2043
0
nlohmann::json BLS_G1_IsEq::ToJSON(void) const {
2044
0
    nlohmann::json j;
2045
0
    j["curveType"] = curveType.ToJSON();
2046
2047
0
    j["a_x"] = a.first.ToJSON();
2048
0
    j["a_y"] = a.second.ToJSON();
2049
2050
0
    j["b_x"] = b.first.ToJSON();
2051
0
    j["b_y"] = b.second.ToJSON();
2052
2053
0
    j["modifier"] = modifier.ToJSON();
2054
0
    return j;
2055
0
}
2056
2057
0
std::string BLS_G1_Neg::Name(void) const { return "BLS_G1_Neg"; }
2058
0
std::string BLS_G1_Neg::ToString(void) const {
2059
0
    std::stringstream ss;
2060
2061
0
    ss << "operation name: BLS_G1_Neg" << std::endl;
2062
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
2063
0
    ss << "A X: " << a.first.ToString() << std::endl;
2064
0
    ss << "A Y: " << a.second.ToString() << std::endl;
2065
2066
0
    return ss.str();
2067
0
}
2068
2069
0
nlohmann::json BLS_G1_Neg::ToJSON(void) const {
2070
0
    nlohmann::json j;
2071
0
    j["curveType"] = curveType.ToJSON();
2072
2073
0
    j["a_x"] = a.first.ToJSON();
2074
0
    j["a_y"] = a.second.ToJSON();
2075
2076
0
    j["modifier"] = modifier.ToJSON();
2077
0
    return j;
2078
0
}
2079
2080
0
std::string BLS_G2_Add::Name(void) const { return "BLS_G2_Add"; }
2081
0
std::string BLS_G2_Add::ToString(void) const {
2082
0
    std::stringstream ss;
2083
2084
0
    ss << "operation name: BLS_G2_Add" << std::endl;
2085
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
2086
0
    ss << "A V:" << a.first.first.ToString() << std::endl;
2087
0
    ss << "A W:" << a.first.second.ToString() << std::endl;
2088
0
    ss << "A X:" << a.second.first.ToString() << std::endl;
2089
0
    ss << "A Y:" << a.second.second.ToString() << std::endl;
2090
0
    ss << "B V:" << b.first.first.ToString() << std::endl;
2091
0
    ss << "B W:" << b.first.second.ToString() << std::endl;
2092
0
    ss << "B X:" << b.second.first.ToString() << std::endl;
2093
0
    ss << "B Y:" << b.second.second.ToString() << std::endl;
2094
2095
0
    return ss.str();
2096
0
}
2097
2098
0
nlohmann::json BLS_G2_Add::ToJSON(void) const {
2099
0
    nlohmann::json j;
2100
0
    j["curveType"] = curveType.ToJSON();
2101
2102
0
    j["a_v"] = a.first.first.ToJSON();
2103
0
    j["a_w"] = a.first.second.ToJSON();
2104
0
    j["a_x"] = a.second.first.ToJSON();
2105
0
    j["a_y"] = a.second.second.ToJSON();
2106
2107
0
    j["b_v"] = b.first.first.ToJSON();
2108
0
    j["b_w"] = b.first.second.ToJSON();
2109
0
    j["b_x"] = b.second.first.ToJSON();
2110
0
    j["b_y"] = b.second.second.ToJSON();
2111
2112
0
    j["modifier"] = modifier.ToJSON();
2113
0
    return j;
2114
0
}
2115
2116
0
std::string BLS_G2_Mul::Name(void) const { return "BLS_G2_Mul"; }
2117
0
std::string BLS_G2_Mul::ToString(void) const {
2118
0
    std::stringstream ss;
2119
2120
0
    ss << "operation name: BLS_G2_Mul" << std::endl;
2121
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
2122
0
    ss << "A V:" << a.first.first.ToString() << std::endl;
2123
0
    ss << "A W:" << a.first.second.ToString() << std::endl;
2124
0
    ss << "A X:" << a.second.first.ToString() << std::endl;
2125
0
    ss << "A Y:" << a.second.second.ToString() << std::endl;
2126
0
    ss << "B: " << b.ToString() << std::endl;
2127
2128
0
    return ss.str();
2129
0
}
2130
2131
0
nlohmann::json BLS_G2_Mul::ToJSON(void) const {
2132
0
    nlohmann::json j;
2133
0
    j["curveType"] = curveType.ToJSON();
2134
2135
0
    j["a_v"] = a.first.first.ToJSON();
2136
0
    j["a_w"] = a.first.second.ToJSON();
2137
0
    j["a_x"] = a.second.first.ToJSON();
2138
0
    j["a_y"] = a.second.second.ToJSON();
2139
2140
0
    j["b"] = b.ToJSON();
2141
2142
0
    j["modifier"] = modifier.ToJSON();
2143
0
    return j;
2144
0
}
2145
2146
0
std::string BLS_G2_IsEq::Name(void) const { return "BLS_G2_IsEq"; }
2147
0
std::string BLS_G2_IsEq::ToString(void) const {
2148
0
    std::stringstream ss;
2149
2150
0
    ss << "operation name: BLS_G2_IsEq" << std::endl;
2151
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
2152
0
    ss << "A V:" << a.first.first.ToString() << std::endl;
2153
0
    ss << "A W:" << a.first.second.ToString() << std::endl;
2154
0
    ss << "A X:" << a.second.first.ToString() << std::endl;
2155
0
    ss << "A Y:" << a.second.second.ToString() << std::endl;
2156
0
    ss << "B V:" << b.first.first.ToString() << std::endl;
2157
0
    ss << "B W:" << b.first.second.ToString() << std::endl;
2158
0
    ss << "B X:" << b.second.first.ToString() << std::endl;
2159
0
    ss << "B Y:" << b.second.second.ToString() << std::endl;
2160
2161
0
    return ss.str();
2162
0
}
2163
2164
0
nlohmann::json BLS_G2_IsEq::ToJSON(void) const {
2165
0
    nlohmann::json j;
2166
0
    j["curveType"] = curveType.ToJSON();
2167
2168
0
    j["a_v"] = a.first.first.ToJSON();
2169
0
    j["a_w"] = a.first.second.ToJSON();
2170
0
    j["a_x"] = a.second.first.ToJSON();
2171
0
    j["a_y"] = a.second.second.ToJSON();
2172
2173
0
    j["b_v"] = b.first.first.ToJSON();
2174
0
    j["b_w"] = b.first.second.ToJSON();
2175
0
    j["b_x"] = b.second.first.ToJSON();
2176
0
    j["b_y"] = b.second.second.ToJSON();
2177
2178
0
    j["modifier"] = modifier.ToJSON();
2179
0
    return j;
2180
0
}
2181
2182
0
std::string BLS_G2_Neg::Name(void) const { return "BLS_G2_Neg"; }
2183
0
std::string BLS_G2_Neg::ToString(void) const {
2184
0
    std::stringstream ss;
2185
2186
0
    ss << "operation name: BLS_G2_Neg" << std::endl;
2187
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
2188
0
    ss << "A V:" << a.first.first.ToString() << std::endl;
2189
0
    ss << "A W:" << a.first.second.ToString() << std::endl;
2190
0
    ss << "A X:" << a.second.first.ToString() << std::endl;
2191
0
    ss << "A Y:" << a.second.second.ToString() << std::endl;
2192
2193
0
    return ss.str();
2194
0
}
2195
2196
0
nlohmann::json BLS_G2_Neg::ToJSON(void) const {
2197
0
    nlohmann::json j;
2198
0
    j["curveType"] = curveType.ToJSON();
2199
2200
0
    j["a_v"] = a.first.first.ToJSON();
2201
0
    j["a_w"] = a.first.second.ToJSON();
2202
0
    j["a_x"] = a.second.first.ToJSON();
2203
0
    j["a_y"] = a.second.second.ToJSON();
2204
2205
0
    j["modifier"] = modifier.ToJSON();
2206
0
    return j;
2207
0
}
2208
2209
0
std::string BLS_G1_MultiExp::Name(void) const { return "BLS_G1_MultiExp"; }
2210
0
std::string BLS_G1_MultiExp::ToString(void) const {
2211
0
    std::stringstream ss;
2212
2213
0
    ss << "operation name: BLS_G1_MultiExp" << std::endl;
2214
0
    ss << "ecc curve: " << repository::ECC_CurveToString(curveType.Get()) << std::endl;
2215
2216
0
    for (const auto& point_scalar : points_scalars.points_scalars) {
2217
0
        ss << "    X: " << point_scalar.first.first.ToString() << std::endl;
2218
0
        ss << "    Y: " << point_scalar.first.second.ToString() << std::endl;
2219
0
        ss << "    scalar: " << point_scalar.second.ToString() << std::endl;
2220
0
        ss << std::endl;
2221
0
    }
2222
2223
0
    return ss.str();
2224
0
}
2225
2226
0
nlohmann::json BLS_G1_MultiExp::ToJSON(void) const {
2227
0
    nlohmann::json j;
2228
0
    j["curveType"] = curveType.ToJSON();
2229
2230
0
    nlohmann::json points_scalars_json = nlohmann::json::array();
2231
2232
0
    for (const auto& point_scalar : points_scalars.points_scalars) {
2233
0
        nlohmann::json ps;
2234
0
        ps["x"] = point_scalar.first.first.ToJSON();
2235
0
        ps["y"] = point_scalar.first.second.ToJSON();
2236
0
        ps["scalar"] = point_scalar.second.ToJSON();
2237
2238
0
        points_scalars_json.push_back(ps);
2239
0
    }
2240
2241
0
    j["points_scalars"] = points_scalars_json;
2242
2243
0
    j["modifier"] = modifier.ToJSON();
2244
0
    return j;
2245
0
}
2246
2247
0
std::string Misc::Name(void) const { return "Misc"; }
2248
0
std::string Misc::ToString(void) const {
2249
0
    std::stringstream ss;
2250
2251
0
    ss << "operation name: Misc" << std::endl;
2252
0
    ss << "operation: " << std::to_string(operation.Get()) << std::endl;
2253
2254
0
    return ss.str();
2255
0
}
2256
2257
0
nlohmann::json Misc::ToJSON(void) const {
2258
0
    nlohmann::json j;
2259
0
    j["operation"] = operation.ToJSON();
2260
0
    j["modifier"] = modifier.ToJSON();
2261
0
    return j;
2262
0
}
2263
2264
0
std::string SR25519_Verify::Name(void) const { return "ECDSA_Verify"; }
2265
0
std::string SR25519_Verify::ToString(void) const {
2266
0
    std::stringstream ss;
2267
2268
0
    ss << "operation name: SR25519_Verify" << std::endl;
2269
0
    ss << "public key: " << signature.pub.ToString() << std::endl;
2270
0
    ss << "cleartext: " << util::HexDump(cleartext.Get()) << std::endl;
2271
0
    ss << "signature R: " << signature.signature.first.ToString() << std::endl;
2272
0
    ss << "signature S: " << signature.signature.second.ToString() << std::endl;
2273
2274
0
    return ss.str();
2275
0
}
2276
2277
0
nlohmann::json SR25519_Verify::ToJSON(void) const {
2278
0
    nlohmann::json j;
2279
0
    j["operation"] = "SR25519_Verify";
2280
0
    j["pub"] = signature.pub.ToJSON();
2281
0
    j["cleartext"] = cleartext.ToJSON();
2282
0
    j["sig_r"] = signature.signature.first.ToJSON();
2283
0
    j["sig_s"] = signature.signature.second.ToJSON();
2284
0
    j["modifier"] = modifier.ToJSON();
2285
0
    return j;
2286
0
}
2287
2288
} /* namespace operation */
2289
} /* namespace cryptofuzz */