forked from mobilecoinfoundation/fog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibmobilecoin_cbindgen.h
764 lines (667 loc) · 27.3 KB
/
libmobilecoin_cbindgen.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
// Warning, this file is autogenerated by cbindgen. Don't modify this manually.
/**
* This file is meant to be used as an aid when making changes to the manually written
* `libmobilecoin.h` header by comparing it to the output of this cbindgen-autogenerated
* file and checking for equivalency.
*/
#define LIB_MC_ERROR_CODE_UNKNOWN -1
#define LIB_MC_ERROR_CODE_PANIC -2
#define LIB_MC_ERROR_CODE_INVALID_INPUT 100
#define LIB_MC_ERROR_CODE_INVALID_OUTPUT 101
#define LIB_MC_ERROR_CODE_ATTESTATION_VERIFICATION_FAILED 200
#define LIB_MC_ERROR_CODE_AEAD 300
#define LIB_MC_ERROR_CODE_CIPHER 301
#define LIB_MC_ERROR_CODE_UNSUPPORTED_CRYPTO_BOX_VERSION 302
#define LIB_MC_ERROR_CODE_TRANSACTION_CRYPTO 400
typedef struct AttestAke AttestAke;
typedef struct McFogResolver McFogResolver;
typedef struct McTransactionBuilderRing McTransactionBuilderRing;
typedef struct Option_TransactionBuilder_FogResolver Option_TransactionBuilder_FogResolver;
typedef struct Vec_u8 Vec_u8;
typedef struct Vec_u8 McData;
typedef struct McMutableBuffer {
FfiMutPtr<uint8_t> buffer;
size_t len;
} McMutableBuffer;
typedef struct McError {
int error_code;
FfiOwnedStr error_description;
} McError;
typedef MrEnclaveVerifier McMrEnclaveVerifier;
/**
* This type is meant to be used as a parameter (or field of an another
* parameter, etc) to C-FFI functions to code written in Rust. Objects of this
* type are typically allocated on the foreign side of the FFI boundary and are
* passed in to Rust via an `extern fn`-style function.
*
* The purpose of this type is to encapsulate unsafety within a type, such that
* if this type were to be created solely in safe Rust, that it would contain
* no unsafety. This is to say that, while this type performs unsafe operations
* internally, in order for those unsafe operations to actually cause unsafety,
* this type must have been created or otherwise manipulated from unsafe
* code (typically either unsafe Rust or unsafe-by-definition foreign code).
* Therefore, care must be taken when using this type from unsafe code (and
* indeed it is intended to be used from unsafe code), but the same care does
* not need to be taken in order to otherwise use it from safe code,
* with the assumption that no preconditions were violated from unsafe code.
*/
typedef struct McBuffer {
FfiRefPtr<uint8_t> buffer;
size_t len;
} McBuffer;
typedef MrSignerVerifier McMrSignerVerifier;
typedef Verifier McVerifier;
typedef struct AttestAke McAttestAke;
/**
* Transparent wrapper around a function pointer that accepts a context
* argument and returns a `u64`, intended for use as a parameter to FFI
* functions so that foreign code may provide a callback for generating random
* numbers.
*
* This type has the exact memory layout as the C equivalent `uint64_t
* (*)(void*)` function pointer.
*
* `null` is not considered a valid value.
*/
typedef uint64_t (*FfiCallbackRng)(void*);
typedef struct McRngCallback {
FfiCallbackRng rng;
FfiOptMutPtr<void> context;
} McRngCallback;
typedef VersionedKexRng McFogRng;
typedef struct McAccountKeyFogInfo {
FfiStr report_url;
FfiStr report_id;
FfiRefPtr<McBuffer> authority_spki;
} McAccountKeyFogInfo;
typedef struct McAccountKey {
/**
* 32-byte `RistrettoPrivate`
*/
FfiRefPtr<McBuffer> view_private_key;
/**
* 32-byte `RistrettoPrivate`
*/
FfiRefPtr<McBuffer> spend_private_key;
FfiOptRefPtr<McAccountKeyFogInfo> fog_info;
} McAccountKey;
typedef struct McTxOutAmount {
/**
* 32-byte `CompressedCommitment`
*/
FfiRefPtr<McBuffer> commitment;
uint64_t masked_value;
} McTxOutAmount;
typedef struct Option_TransactionBuilder_FogResolver McTransactionBuilder;
typedef struct McPublicAddressFogInfo {
FfiStr report_url;
FfiStr report_id;
FfiRefPtr<McBuffer> authority_sig;
} McPublicAddressFogInfo;
typedef struct McPublicAddress {
/**
* 32-byte `CompressedRistrettoPublic`
*/
FfiRefPtr<McBuffer> view_public_key;
/**
* 32-byte `CompressedRistrettoPublic`
*/
FfiRefPtr<McBuffer> spend_public_key;
FfiOptRefPtr<McPublicAddressFogInfo> fog_info;
} McPublicAddress;
void mc_data_free(FfiOptOwnedPtr<McData> data);
/**
* # Preconditions
*
* * `out_bytes` - must be null or else length must be >= `data.len`.
*/
ssize_t mc_data_get_bytes(FfiRefPtr<McData> data, FfiOptMutPtr<McMutableBuffer> out_bytes);
/**
* All non-null owned pointers of type `McError *` that are returned from a
* Rust FFI function to a foreign caller must call this function in order to
* free the underlying memory pointed to by the pointer.
*
* It is undefined behavior for foreign code to dereference the pointer after
* it has called this method.
*/
void mc_error_free(FfiOptOwnedPtr<McError> error);
/**
* All non-null values with a `char *` return (or out parameter) type that are
* returned to foreign code must call this function in order to free the
* underlying memory pointed to by the pointer.
*
* It is undefined behavior for foreign code to dereference the pointer after
* it has called this method.
*/
void mc_string_free(FfiOptOwnedStr string);
void mc_mr_enclave_verifier_free(FfiOptOwnedPtr<McMrEnclaveVerifier> mr_enclave_verifier);
/**
* Create a new status verifier that will check for the existence of the
* given MrEnclave.
*
* # Preconditions
*
* * `mr_enclave` - must be 32 bytes in length.
*/
FfiOptOwnedPtr<McMrEnclaveVerifier> mc_mr_enclave_verifier_create(FfiRefPtr<McBuffer> mr_enclave);
/**
* Assume an enclave with the specified measurement does not need
* BIOS configuration changes to address the provided advisory ID.
*
* This method should only be used when advised by an enclave author.
*
* # Preconditions
*
* * `advisory_id` - must be a nul-terminated C string containing valid UTF-8.
*/
bool mc_mr_enclave_verifier_allow_config_advisory(FfiMutPtr<McMrEnclaveVerifier> mr_enclave_verifier,
FfiStr advisory_id);
/**
* Assume the given MrEnclave value has the appropriate software/build-time
* hardening for the given advisory ID.
*
* This method should only be used when advised by an enclave author.
*
* # Preconditions
*
* * `advisory_id` - must be a nul-terminated C string containing valid UTF-8.
*/
bool mc_mr_enclave_verifier_allow_hardening_advisory(FfiMutPtr<McMrEnclaveVerifier> mr_enclave_verifier,
FfiStr advisory_id);
void mc_mr_signer_verifier_free(FfiOptOwnedPtr<McMrSignerVerifier> mr_signer_verifier);
/**
* Create a new status verifier that will check for the existence of the
* given MrSigner.
*
* # Preconditions
*
* * `mr_signer` - must be 32 bytes in length.
*/
FfiOptOwnedPtr<McMrSignerVerifier> mc_mr_signer_verifier_create(FfiRefPtr<McBuffer> mr_signer,
uint16_t expected_product_id,
uint16_t minimum_security_version);
/**
* Assume an enclave with the specified measurement does not need
* BIOS configuration changes to address the provided advisory ID.
*
* This method should only be used when advised by an enclave author.
*
* # Preconditions
*
* * `advisory_id` - must be a nul-terminated C string containing valid UTF-8.
*/
bool mc_mr_signer_verifier_allow_config_advisory(FfiMutPtr<MrSignerVerifier> mr_signer_verifier,
FfiStr advisory_id);
/**
* Assume an enclave with the specified measurement has the appropriate
* software/build-time hardening for the given advisory ID.
*
* This method should only be used when advised by an enclave author.
*
* # Preconditions
*
* * `advisory_id` - must be a nul-terminated C string containing valid UTF-8.
*/
bool mc_mr_signer_verifier_allow_hardening_advisory(FfiMutPtr<MrSignerVerifier> mr_signer_verifier,
FfiStr advisory_id);
/**
* Construct a new builder using the baked-in IAS root certificates and debug
* settings.
*/
FfiOptOwnedPtr<McVerifier> mc_verifier_create(void);
void mc_verifier_free(FfiOptOwnedPtr<McVerifier> verifier);
/**
* Verify the given MrEnclave-based status verifier succeeds
*/
bool mc_verifier_add_mr_enclave(FfiMutPtr<McVerifier> verifier,
FfiRefPtr<McMrEnclaveVerifier> mr_enclave_verifier);
/**
* Verify the given MrSigner-based status verifier succeeds
*/
bool mc_verifier_add_mr_signer(FfiMutPtr<McVerifier> verifier,
FfiRefPtr<McMrSignerVerifier> mr_signer_verifier);
FfiOptOwnedPtr<McAttestAke> mc_attest_ake_create(void);
void mc_attest_ake_free(FfiOptOwnedPtr<McAttestAke> attest_ake);
bool mc_attest_ake_is_attested(FfiRefPtr<McAttestAke> attest_ake, FfiMutPtr<bool> out_attested);
/**
* # Preconditions
*
* * `attest_ake` - must be in the attested state.
* * `out_binding` - must be null or else length must be >= `binding.len`.
*/
ssize_t mc_attest_ake_get_binding(FfiRefPtr<McAttestAke> attest_ake,
FfiOptMutPtr<McMutableBuffer> out_binding);
/**
* # Preconditions
*
* * `responder_id` - must be a nul-terminated C string containing a valid
* responder ID.
* * `out_auth_request` - must be null or else length must be >=
* auth_request_output.len.
*/
ssize_t mc_attest_ake_get_auth_request(FfiMutPtr<McAttestAke> attest_ake,
FfiStr responder_id,
FfiOptMutPtr<McRngCallback> rng_callback,
FfiOptMutPtr<McMutableBuffer> out_auth_request);
/**
* # Preconditions
*
* * `attest_ake` - must be in the auth pending state.
*
* # Errors
*
* * `LibMcError::AttestationVerificationFailed`
* * `LibMcError::InvalidInput`
*/
bool mc_attest_ake_process_auth_response(FfiMutPtr<McAttestAke> attest_ake,
FfiRefPtr<McBuffer> auth_response_data,
FfiRefPtr<McVerifier> verifier,
FfiOptMutPtr<FfiOptOwnedPtr<McError>> out_error);
/**
* # Preconditions
*
* * `attest_ake` - must be in the attested state.
* * `out_ciphertext` - must be null or else length must be >=
* `ciphertext.len`.
*
* # Errors
*
* * `LibMcError::Aead`
* * `LibMcError::Cipher`
*/
ssize_t mc_attest_ake_encrypt(FfiMutPtr<McAttestAke> attest_ake,
FfiRefPtr<McBuffer> aad,
FfiRefPtr<McBuffer> plaintext,
FfiOptMutPtr<McMutableBuffer> out_ciphertext,
FfiOptMutPtr<FfiOptOwnedPtr<McError>> out_error);
/**
* # Preconditions
*
* * `attest_ake` - must be in the attested state.
* * `out_plaintext` - length must be >= `ciphertext.len`.
*
* # Errors
*
* * `LibMcError::Aead`
* * `LibMcError::Cipher`
*/
ssize_t mc_attest_ake_decrypt(FfiMutPtr<McAttestAke> attest_ake,
FfiRefPtr<McBuffer> aad,
FfiRefPtr<McBuffer> ciphertext,
FfiMutPtr<McMutableBuffer> out_plaintext,
FfiOptMutPtr<FfiOptOwnedPtr<McError>> out_error);
/**
* # Preconditions
*
* * `entropy` - length must be a multiple of 4 and between 16 and 32,
* inclusive, in bytes.
*/
FfiOptOwnedStr mc_bip39_mnemonic_from_entropy(FfiRefPtr<McBuffer> entropy);
/**
* # Preconditions
*
* * `mnemonic` - must be a nul-terminated C string containing valid UTF-8.
* * `out_entropy` - must be null or else length must be >= `entropy.len`.
*
* # Errors
*
* * `LibMcError::InvalidInput`
*/
ssize_t mc_bip39_entropy_from_mnemonic(FfiStr mnemonic,
FfiOptMutPtr<McMutableBuffer> out_entropy,
FfiOptMutPtr<FfiOptOwnedPtr<McError>> out_error);
/**
* # Preconditions
*
* * `prefix` - must be a nul-terminated C string containing valid UTF-8.
*/
FfiOptOwnedStr mc_bip39_words_by_prefix(FfiStr prefix);
bool mc_ristretto_private_validate(FfiRefPtr<McBuffer> ristretto_private,
FfiMutPtr<bool> out_valid);
/**
* # Preconditions
*
* * `ristretto_private` - must be a valid 32-byte Ristretto-format scalar.
* * `out_ristretto_public` - length must be >= 32.
*/
bool mc_ristretto_public_from_ristretto_private(FfiRefPtr<McBuffer> ristretto_private,
FfiMutPtr<McMutableBuffer> out_ristretto_public);
bool mc_ristretto_public_validate(FfiRefPtr<McBuffer> ristretto_public, FfiMutPtr<bool> out_valid);
/**
* # Preconditions
*
* * `public_key` - must be a valid 32-byte compressed Ristretto point.
* * `out_ciphertext` - must be null or else length must be >=
* `ciphertext.len`.
*
* # Errors
*
* * `LibMcError::Aead`
*/
ssize_t mc_versioned_crypto_box_encrypt(FfiRefPtr<McBuffer> public_key,
FfiRefPtr<McBuffer> plaintext,
FfiOptMutPtr<McRngCallback> rng_callback,
FfiOptMutPtr<McMutableBuffer> out_ciphertext,
FfiOptMutPtr<FfiOptOwnedPtr<McError>> out_error);
/**
* # Preconditions
*
* * `private_key` - must be a valid 32-byte Ristretto-format scalar.
* * `out_plaintext` - length must be >= `ciphertext.len`.
*
* # Errors
*
* * `LibMcError::Aead`
* * `LibMcError::InvalidInput`
* * `LibMcError::UnsupportedCryptoBoxVersion`
*/
ssize_t mc_versioned_crypto_box_decrypt(FfiRefPtr<McBuffer> private_key,
FfiRefPtr<McBuffer> ciphertext,
FfiMutPtr<McMutableBuffer> out_plaintext,
FfiOptMutPtr<FfiOptOwnedPtr<McError>> out_error);
/**
* # Preconditions
*
* * `printable_wrapper_proto_bytes` - must be a valid binary-serialized
* `printable.PrintableWrapper` Protobuf.
*/
FfiOptOwnedStr mc_printable_wrapper_b58_encode(FfiRefPtr<McBuffer> printable_wrapper_proto_bytes);
/**
* # Preconditions
*
* * `b58_encoded_string` - must be a nul-terminated C string containing valid
* UTF-8.
* * `out_printable_wrapper_proto_bytes` - must be null or else length must be
* >= `wrapper_bytes.len`.
*
* # Errors
*
* * `LibMcError::InvalidInput`
*/
ssize_t mc_printable_wrapper_b58_decode(FfiStr b58_encoded_string,
FfiOptMutPtr<McMutableBuffer> out_printable_wrapper_proto_bytes,
FfiOptMutPtr<FfiOptOwnedPtr<McError>> out_error);
FfiOptOwnedPtr<McFogResolver> mc_fog_resolver_create(FfiRefPtr<McVerifier> fog_report_verifier);
void mc_fog_resolver_free(FfiOptOwnedPtr<McFogResolver> fog_resolver);
/**
* # Preconditions
*
* * `report_url` - must be a nul-terminated C string containing a valid Fog
* report uri.
*
* # Errors
*
* * `LibMcError::InvalidInput`
*/
bool mc_fog_resolver_add_report_response(FfiMutPtr<McFogResolver> fog_resolver,
FfiStr report_url,
FfiRefPtr<McBuffer> report_response,
FfiOptMutPtr<FfiOptOwnedPtr<McError>> out_error);
/**
* # Preconditions
*
* * `subaddress_view_private_key` - must be a valid 32-byte Ristretto-format
* scalar.
*
* # Errors
*
* * `LibMcError::InvalidInput`
* * `LibMcError::UnsupportedCryptoBoxVersion`
*/
FfiOptOwnedPtr<McFogRng> mc_fog_rng_create(FfiRefPtr<McBuffer> subaddress_view_private_key,
FfiRefPtr<McBuffer> rng_public_key,
uint32_t rng_version,
FfiOptMutPtr<FfiOptOwnedPtr<McError>> out_error);
void mc_fog_rng_free(FfiOptOwnedPtr<McFogRng> fog_rng);
FfiOptOwnedPtr<McFogRng> mc_fog_rng_clone(FfiRefPtr<McFogRng> fog_rng);
/**
* # Preconditions
*
* * `out_fog_rng_proto_bytes` - must be null or else length must be >=
* `encoded.len`.
*/
ssize_t mc_fog_rng_serialize_proto(FfiRefPtr<McFogRng> fog_rng,
FfiOptMutPtr<McMutableBuffer> out_fog_rng_proto_bytes);
/**
* # Errors
*
* * `LibMcError::InvalidInput`
* * `LibMcError::UnsupportedCryptoBoxVersion`
*/
FfiOptOwnedPtr<McFogRng> mc_fog_rng_deserialize_proto(FfiRefPtr<McBuffer> fog_rng_proto_bytes,
FfiOptMutPtr<FfiOptOwnedPtr<McError>> out_error);
int64_t mc_fog_rng_index(FfiRefPtr<McFogRng> fog_rng);
ssize_t mc_fog_rng_get_output_len(FfiRefPtr<McFogRng> fog_rng);
/**
* # Preconditions
*
* * `out_output` - length must be >= `output.len`.
*/
bool mc_fog_rng_peek(FfiRefPtr<McFogRng> fog_rng, FfiMutPtr<McMutableBuffer> out_output);
/**
* # Preconditions
*
* * `out_output` - must be null or else length must be >= `output.len`.
*/
bool mc_fog_rng_advance(FfiMutPtr<McFogRng> fog_rng, FfiOptMutPtr<McMutableBuffer> out_output);
/**
* # Preconditions
*
* * `view_private_key` - must be a valid 32-byte Ristretto-format scalar.
* * `spend_private_key` - must be a valid 32-byte Ristretto-format scalar.
* * `out_subaddress_view_private_key` - length must be >= 32.
* * `out_subaddress_spend_private_key` - length must be >= 32.
*/
bool mc_account_key_get_subaddress_private_keys(FfiRefPtr<McBuffer> view_private_key,
FfiRefPtr<McBuffer> spend_private_key,
uint64_t subaddress_index,
FfiMutPtr<McMutableBuffer> out_subaddress_view_private_key,
FfiMutPtr<McMutableBuffer> out_subaddress_spend_private_key);
/**
* # Preconditions
*
* * `view_private_key` - must be a valid 32-byte Ristretto-format scalar.
* * `spend_private_key` - must be a valid 32-byte Ristretto-format scalar.
* * `out_subaddress_view_public_key` - length must be >= 32.
* * `out_subaddress_spend_public_key` - length must be >= 32.
*/
bool mc_account_key_get_public_address_public_keys(FfiRefPtr<McBuffer> view_private_key,
FfiRefPtr<McBuffer> spend_private_key,
uint64_t subaddress_index,
FfiMutPtr<McMutableBuffer> out_subaddress_view_public_key,
FfiMutPtr<McMutableBuffer> out_subaddress_spend_public_key);
/**
* # Preconditions
*
* * `account_key` - must be a valid `AccountKey` with `fog_info`.
* * `out_fog_authority_sig` - length must be >= 64.
*/
bool mc_account_key_get_public_address_fog_authority_sig(FfiRefPtr<McAccountKey> account_key,
uint64_t subaddress_index,
FfiMutPtr<McMutableBuffer> out_fog_authority_sig);
/**
* # Preconditions
*
* * `mnemonic` - must be a nul-terminated C string containing valid UTF-8.
* * `out_view_private_key` - length must be >= 32.
* * `out_spend_private_key` - length must be >= 32.
*
* # Errors
*
* * `LibMcError::InvalidInput`
*/
bool mc_slip10_account_private_keys_from_mnemonic(FfiStr mnemonic,
uint32_t account_index,
FfiMutPtr<McMutableBuffer> out_view_private_key,
FfiMutPtr<McMutableBuffer> out_spend_private_key,
FfiOptMutPtr<FfiOptOwnedPtr<McError>> out_error);
/**
* # Preconditions
*
* * `view_private_key` - must be a valid 32-byte Ristretto-format scalar.
*/
bool mc_tx_out_matches_any_subaddress(FfiRefPtr<McTxOutAmount> tx_out_amount,
FfiRefPtr<McBuffer> tx_out_public_key,
FfiRefPtr<McBuffer> view_private_key,
FfiMutPtr<bool> out_matches);
/**
* # Preconditions
*
* * `view_private_key` - must be a valid 32-byte Ristretto-format scalar.
* * `subaddress_spend_private_key` - must be a valid 32-byte Ristretto-format
* scalar.
*/
bool mc_tx_out_matches_subaddress(FfiRefPtr<McBuffer> tx_out_target_key,
FfiRefPtr<McBuffer> tx_out_public_key,
FfiRefPtr<McBuffer> view_private_key,
FfiRefPtr<McBuffer> subaddress_spend_private_key,
FfiMutPtr<bool> out_matches);
/**
* # Preconditions
*
* * `view_private_key` - must be a valid 32-byte Ristretto-format scalar.
* * `out_subaddress_spend_public_key` - length must be >= 32.
*
* # Errors
*
* * `LibMcError::InvalidInput`
*/
bool mc_tx_out_get_subaddress_spend_public_key(FfiRefPtr<McBuffer> tx_out_target_key,
FfiRefPtr<McBuffer> tx_out_public_key,
FfiRefPtr<McBuffer> view_private_key,
FfiMutPtr<McMutableBuffer> out_subaddress_spend_public_key,
FfiOptMutPtr<FfiOptOwnedPtr<McError>> out_error);
/**
* # Preconditions
*
* * `view_private_key` - must be a valid 32-byte Ristretto-format scalar.
*
* # Errors
*
* * `LibMcError::InvalidInput`
* * `LibMcError::TransactionCrypto`
*/
bool mc_tx_out_get_value(FfiRefPtr<McTxOutAmount> tx_out_amount,
FfiRefPtr<McBuffer> tx_out_public_key,
FfiRefPtr<McBuffer> view_private_key,
FfiMutPtr<uint64_t> out_value,
FfiOptMutPtr<FfiOptOwnedPtr<McError>> out_error);
/**
* # Preconditions
*
* * `view_private_key` - must be a valid 32-byte Ristretto-format scalar.
* * `subaddress_spend_private_key` - must be a valid 32-byte Ristretto-format
* scalar.
* * `out_key_image` - length must be >= 32.
*
* # Errors
*
* * `LibMcError::InvalidInput`
* * `LibMcError::TransactionCrypto`
*/
bool mc_tx_out_get_key_image(FfiRefPtr<McBuffer> tx_out_target_key,
FfiRefPtr<McBuffer> tx_out_public_key,
FfiRefPtr<McBuffer> view_private_key,
FfiRefPtr<McBuffer> subaddress_spend_private_key,
FfiMutPtr<McMutableBuffer> out_key_image,
FfiOptMutPtr<FfiOptOwnedPtr<McError>> out_error);
/**
* # Preconditions
*
* * `view_private_key` - must be a valid 32-byte Ristretto-format scalar.
*/
bool mc_tx_out_validate_confirmation_number(FfiRefPtr<McBuffer> tx_out_public_key,
FfiRefPtr<McBuffer> tx_out_confirmation_number,
FfiRefPtr<McBuffer> view_private_key,
FfiMutPtr<bool> out_valid);
FfiOptOwnedPtr<McTransactionBuilderRing> mc_transaction_builder_ring_create(void);
void mc_transaction_builder_ring_free(FfiOptOwnedPtr<McTransactionBuilderRing> transaction_builder_ring);
/**
* # Preconditions
*
* * `tx_out_proto_bytes` - must be a valid binary-serialized `external.TxOut`
* Protobuf.
* * `membership_proof_proto_bytes` - must be a valid binary-serialized
* `external.TxOutMembershipProof` Protobuf.
*/
bool mc_transaction_builder_ring_add_element(FfiMutPtr<McTransactionBuilderRing> ring,
FfiRefPtr<McBuffer> tx_out_proto_bytes,
FfiRefPtr<McBuffer> membership_proof_proto_bytes);
FfiOptOwnedPtr<McTransactionBuilder> mc_transaction_builder_create(uint64_t fee,
uint64_t tombstone_block,
FfiOptRefPtr<McFogResolver> fog_resolver);
void mc_transaction_builder_free(FfiOptOwnedPtr<McTransactionBuilder> transaction_builder);
/**
* # Preconditions
*
* * `transaction_builder` - must not have been previously consumed by a call
* to `build`.
* * `view_private_key` - must be a valid 32-byte Ristretto-format scalar.
* * `subaddress_spend_private_key` - must be a valid 32-byte Ristretto-format
* scalar.
* * `real_index` - must be within bounds of `ring`.
* * `ring` - `TxOut` at `real_index` must be owned by account keys.
*
* # Errors
*
* * `LibMcError::InvalidInput`
*/
bool mc_transaction_builder_add_input(FfiMutPtr<McTransactionBuilder> transaction_builder,
FfiRefPtr<McBuffer> view_private_key,
FfiRefPtr<McBuffer> subaddress_spend_private_key,
uintptr_t real_index,
FfiRefPtr<McTransactionBuilderRing> ring,
FfiOptMutPtr<FfiOptOwnedPtr<McError>> out_error);
/**
* # Preconditions
*
* * `transaction_builder` - must not have been previously consumed by a call
* to `build`.
* * `recipient_address` - must be a valid `PublicAddress`.
* * `out_subaddress_spend_public_key` - length must be >= 32.
*
* # Errors
*
* * `LibMcError::AttestationVerification`
* * `LibMcError::InvalidInput`
*/
FfiOptOwnedPtr<McData> mc_transaction_builder_add_output(FfiMutPtr<McTransactionBuilder> transaction_builder,
uint64_t amount,
FfiRefPtr<McPublicAddress> recipient_address,
FfiOptMutPtr<McRngCallback> rng_callback,
FfiMutPtr<McMutableBuffer> out_tx_out_confirmation_number,
FfiOptMutPtr<FfiOptOwnedPtr<McError>> out_error);
/**
* # Preconditions
*
* * `transaction_builder` - must not have been previously consumed by a call
* to `build`.
* * `recipient_address` - must be a valid `PublicAddress`.
* * `fog_hint_address` - must be a valid `PublicAddress` with `fog_info`.
* * `out_tx_out_confirmation_number` - length must be >= 32.
*
* # Errors
*
* * `LibMcError::AttestationVerification`
* * `LibMcError::InvalidInput`
*/
FfiOptOwnedPtr<McData> mc_transaction_builder_add_output_with_fog_hint_address(FfiMutPtr<McTransactionBuilder> transaction_builder,
uint64_t amount,
FfiRefPtr<McPublicAddress> recipient_address,
FfiRefPtr<McPublicAddress> fog_hint_address,
FfiOptMutPtr<McRngCallback> rng_callback,
FfiMutPtr<McMutableBuffer> out_tx_out_confirmation_number,
FfiOptMutPtr<FfiOptOwnedPtr<McError>> out_error);
/**
* # Preconditions
*
* * `transaction_builder` - must not have been previously consumed by a call
* to `build`.
*
* # Errors
*
* * `LibMcError::InvalidInput`
*/
FfiOptOwnedPtr<McData> mc_transaction_builder_build(FfiMutPtr<McTransactionBuilder> transaction_builder,
FfiOptMutPtr<McRngCallback> rng_callback,
FfiOptMutPtr<FfiOptOwnedPtr<McError>> out_error);