@baerae/zkap-zkp-react-native 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/android/build.gradle +2 -0
  2. package/android/libs/arm64-v8a/libzkap_uniffi_bindings.so +0 -0
  3. package/android/libs/armeabi-v7a/libzkap_uniffi_bindings.so +0 -0
  4. package/android/libs/x86_64/libzkap_uniffi_bindings.so +0 -0
  5. package/android/src/main/java/expo/modules/zkap/ZkapSdkModule.kt +127 -38
  6. package/android/src/main/java/uniffi/zkap_uniffi_bindings/zkap_uniffi_bindings.kt +1566 -0
  7. package/ios/ZkapSdkModule.podspec +7 -6
  8. package/ios/ZkapSdkModule.swift +104 -62
  9. package/ios/ZkapZkp.xcframework/Info.plist +9 -9
  10. package/ios/ZkapZkp.xcframework/ios-arm64/Headers/zkap_uniffi_bindingsFFI.h +567 -0
  11. package/ios/ZkapZkp.xcframework/ios-arm64/{libzkap_zkp_rn.a → libzkap_uniffi_bindings.a} +0 -0
  12. package/ios/ZkapZkp.xcframework/ios-arm64_x86_64-simulator/Headers/zkap_uniffi_bindingsFFI.h +567 -0
  13. package/ios/ZkapZkp.xcframework/ios-arm64_x86_64-simulator/{libzkap_zkp_rn_sim.a → libzkap_uniffi_bindings.a} +0 -0
  14. package/ios/uniffi/zkap_uniffi_bindings.swift +1174 -0
  15. package/ios/uniffi/zkap_uniffi_bindingsFFI.h +567 -0
  16. package/ios/uniffi/zkap_uniffi_bindingsFFI.modulemap +7 -0
  17. package/package.json +3 -2
  18. package/src/index.ts +10 -8
  19. package/android/libs/arm64-v8a/libzkap_zkp_rn.so +0 -0
  20. package/android/libs/armeabi-v7a/libzkap_zkp_rn.so +0 -0
  21. package/android/libs/x86_64/libzkap_zkp_rn.so +0 -0
  22. package/ios/ZkapZkp.xcframework/ios-arm64/Headers/zkap_zkp_rn.h +0 -15
  23. package/ios/ZkapZkp.xcframework/ios-arm64_x86_64-simulator/Headers/zkap_zkp_rn.h +0 -15
  24. package/ios/include/zkap_zkp_rn.h +0 -15
@@ -0,0 +1,1566 @@
1
+ // This file was autogenerated by some hot garbage in the `uniffi` crate.
2
+ // Trust me, you don't want to mess with it!
3
+
4
+ @file:Suppress("NAME_SHADOWING")
5
+
6
+ package uniffi.zkap_uniffi_bindings
7
+
8
+ // Common helper code.
9
+ //
10
+ // Ideally this would live in a separate .kt file where it can be unittested etc
11
+ // in isolation, and perhaps even published as a re-useable package.
12
+ //
13
+ // However, it's important that the details of how this helper code works (e.g. the
14
+ // way that different builtin types are passed across the FFI) exactly match what's
15
+ // expected by the Rust code on the other side of the interface. In practice right
16
+ // now that means coming from the exact some version of `uniffi` that was used to
17
+ // compile the Rust component. The easiest way to ensure this is to bundle the Kotlin
18
+ // helpers directly inline like we're doing here.
19
+
20
+ import com.sun.jna.Library
21
+ import com.sun.jna.IntegerType
22
+ import com.sun.jna.Native
23
+ import com.sun.jna.Pointer
24
+ import com.sun.jna.Structure
25
+ import com.sun.jna.Callback
26
+ import com.sun.jna.ptr.*
27
+ import java.nio.ByteBuffer
28
+ import java.nio.ByteOrder
29
+ import java.nio.CharBuffer
30
+ import java.nio.charset.CodingErrorAction
31
+ import java.util.concurrent.atomic.AtomicLong
32
+ import java.util.concurrent.ConcurrentHashMap
33
+
34
+ // This is a helper for safely working with byte buffers returned from the Rust code.
35
+ // A rust-owned buffer is represented by its capacity, its current length, and a
36
+ // pointer to the underlying data.
37
+
38
+ /**
39
+ * @suppress
40
+ */
41
+ @Structure.FieldOrder("capacity", "len", "data")
42
+ open class RustBuffer : Structure() {
43
+ // Note: `capacity` and `len` are actually `ULong` values, but JVM only supports signed values.
44
+ // When dealing with these fields, make sure to call `toULong()`.
45
+ @JvmField var capacity: Long = 0
46
+ @JvmField var len: Long = 0
47
+ @JvmField var data: Pointer? = null
48
+
49
+ class ByValue: RustBuffer(), Structure.ByValue
50
+ class ByReference: RustBuffer(), Structure.ByReference
51
+
52
+ internal fun setValue(other: RustBuffer) {
53
+ capacity = other.capacity
54
+ len = other.len
55
+ data = other.data
56
+ }
57
+
58
+ companion object {
59
+ internal fun alloc(size: ULong = 0UL) = uniffiRustCall() { status ->
60
+ // Note: need to convert the size to a `Long` value to make this work with JVM.
61
+ UniffiLib.ffi_zkap_uniffi_bindings_rustbuffer_alloc(size.toLong(), status)
62
+ }.also {
63
+ if(it.data == null) {
64
+ throw RuntimeException("RustBuffer.alloc() returned null data pointer (size=${size})")
65
+ }
66
+ }
67
+
68
+ internal fun create(capacity: ULong, len: ULong, data: Pointer?): RustBuffer.ByValue {
69
+ var buf = RustBuffer.ByValue()
70
+ buf.capacity = capacity.toLong()
71
+ buf.len = len.toLong()
72
+ buf.data = data
73
+ return buf
74
+ }
75
+
76
+ internal fun free(buf: RustBuffer.ByValue) = uniffiRustCall() { status ->
77
+ UniffiLib.ffi_zkap_uniffi_bindings_rustbuffer_free(buf, status)
78
+ }
79
+ }
80
+
81
+ @Suppress("TooGenericExceptionThrown")
82
+ fun asByteBuffer() =
83
+ this.data?.getByteBuffer(0, this.len)?.also {
84
+ it.order(ByteOrder.BIG_ENDIAN)
85
+ }
86
+ }
87
+
88
+ // This is a helper for safely passing byte references into the rust code.
89
+ // It's not actually used at the moment, because there aren't many things that you
90
+ // can take a direct pointer to in the JVM, and if we're going to copy something
91
+ // then we might as well copy it into a `RustBuffer`. But it's here for API
92
+ // completeness.
93
+
94
+ @Structure.FieldOrder("len", "data")
95
+ internal open class ForeignBytes : Structure() {
96
+ @JvmField var len: Int = 0
97
+ @JvmField var data: Pointer? = null
98
+
99
+ class ByValue : ForeignBytes(), Structure.ByValue
100
+ }
101
+ /**
102
+ * The FfiConverter interface handles converter types to and from the FFI
103
+ *
104
+ * All implementing objects should be public to support external types. When a
105
+ * type is external we need to import it's FfiConverter.
106
+ *
107
+ * @suppress
108
+ */
109
+ public interface FfiConverter<KotlinType, FfiType> {
110
+ // Convert an FFI type to a Kotlin type
111
+ fun lift(value: FfiType): KotlinType
112
+
113
+ // Convert an Kotlin type to an FFI type
114
+ fun lower(value: KotlinType): FfiType
115
+
116
+ // Read a Kotlin type from a `ByteBuffer`
117
+ fun read(buf: ByteBuffer): KotlinType
118
+
119
+ // Calculate bytes to allocate when creating a `RustBuffer`
120
+ //
121
+ // This must return at least as many bytes as the write() function will
122
+ // write. It can return more bytes than needed, for example when writing
123
+ // Strings we can't know the exact bytes needed until we the UTF-8
124
+ // encoding, so we pessimistically allocate the largest size possible (3
125
+ // bytes per codepoint). Allocating extra bytes is not really a big deal
126
+ // because the `RustBuffer` is short-lived.
127
+ fun allocationSize(value: KotlinType): ULong
128
+
129
+ // Write a Kotlin type to a `ByteBuffer`
130
+ fun write(value: KotlinType, buf: ByteBuffer)
131
+
132
+ // Lower a value into a `RustBuffer`
133
+ //
134
+ // This method lowers a value into a `RustBuffer` rather than the normal
135
+ // FfiType. It's used by the callback interface code. Callback interface
136
+ // returns are always serialized into a `RustBuffer` regardless of their
137
+ // normal FFI type.
138
+ fun lowerIntoRustBuffer(value: KotlinType): RustBuffer.ByValue {
139
+ val rbuf = RustBuffer.alloc(allocationSize(value))
140
+ try {
141
+ val bbuf = rbuf.data!!.getByteBuffer(0, rbuf.capacity).also {
142
+ it.order(ByteOrder.BIG_ENDIAN)
143
+ }
144
+ write(value, bbuf)
145
+ rbuf.writeField("len", bbuf.position().toLong())
146
+ return rbuf
147
+ } catch (e: Throwable) {
148
+ RustBuffer.free(rbuf)
149
+ throw e
150
+ }
151
+ }
152
+
153
+ // Lift a value from a `RustBuffer`.
154
+ //
155
+ // This here mostly because of the symmetry with `lowerIntoRustBuffer()`.
156
+ // It's currently only used by the `FfiConverterRustBuffer` class below.
157
+ fun liftFromRustBuffer(rbuf: RustBuffer.ByValue): KotlinType {
158
+ val byteBuf = rbuf.asByteBuffer()!!
159
+ try {
160
+ val item = read(byteBuf)
161
+ if (byteBuf.hasRemaining()) {
162
+ throw RuntimeException("junk remaining in buffer after lifting, something is very wrong!!")
163
+ }
164
+ return item
165
+ } finally {
166
+ RustBuffer.free(rbuf)
167
+ }
168
+ }
169
+ }
170
+
171
+ /**
172
+ * FfiConverter that uses `RustBuffer` as the FfiType
173
+ *
174
+ * @suppress
175
+ */
176
+ public interface FfiConverterRustBuffer<KotlinType>: FfiConverter<KotlinType, RustBuffer.ByValue> {
177
+ override fun lift(value: RustBuffer.ByValue) = liftFromRustBuffer(value)
178
+ override fun lower(value: KotlinType) = lowerIntoRustBuffer(value)
179
+ }
180
+ // A handful of classes and functions to support the generated data structures.
181
+ // This would be a good candidate for isolating in its own ffi-support lib.
182
+
183
+ internal const val UNIFFI_CALL_SUCCESS = 0.toByte()
184
+ internal const val UNIFFI_CALL_ERROR = 1.toByte()
185
+ internal const val UNIFFI_CALL_UNEXPECTED_ERROR = 2.toByte()
186
+
187
+ @Structure.FieldOrder("code", "error_buf")
188
+ internal open class UniffiRustCallStatus : Structure() {
189
+ @JvmField var code: Byte = 0
190
+ @JvmField var error_buf: RustBuffer.ByValue = RustBuffer.ByValue()
191
+
192
+ class ByValue: UniffiRustCallStatus(), Structure.ByValue
193
+
194
+ fun isSuccess(): Boolean {
195
+ return code == UNIFFI_CALL_SUCCESS
196
+ }
197
+
198
+ fun isError(): Boolean {
199
+ return code == UNIFFI_CALL_ERROR
200
+ }
201
+
202
+ fun isPanic(): Boolean {
203
+ return code == UNIFFI_CALL_UNEXPECTED_ERROR
204
+ }
205
+
206
+ companion object {
207
+ fun create(code: Byte, errorBuf: RustBuffer.ByValue): UniffiRustCallStatus.ByValue {
208
+ val callStatus = UniffiRustCallStatus.ByValue()
209
+ callStatus.code = code
210
+ callStatus.error_buf = errorBuf
211
+ return callStatus
212
+ }
213
+ }
214
+ }
215
+
216
+ class InternalException(message: String) : kotlin.Exception(message)
217
+
218
+ /**
219
+ * Each top-level error class has a companion object that can lift the error from the call status's rust buffer
220
+ *
221
+ * @suppress
222
+ */
223
+ interface UniffiRustCallStatusErrorHandler<E> {
224
+ fun lift(error_buf: RustBuffer.ByValue): E;
225
+ }
226
+
227
+ // Helpers for calling Rust
228
+ // In practice we usually need to be synchronized to call this safely, so it doesn't
229
+ // synchronize itself
230
+
231
+ // Call a rust function that returns a Result<>. Pass in the Error class companion that corresponds to the Err
232
+ private inline fun <U, E: kotlin.Exception> uniffiRustCallWithError(errorHandler: UniffiRustCallStatusErrorHandler<E>, callback: (UniffiRustCallStatus) -> U): U {
233
+ var status = UniffiRustCallStatus()
234
+ val return_value = callback(status)
235
+ uniffiCheckCallStatus(errorHandler, status)
236
+ return return_value
237
+ }
238
+
239
+ // Check UniffiRustCallStatus and throw an error if the call wasn't successful
240
+ private fun<E: kotlin.Exception> uniffiCheckCallStatus(errorHandler: UniffiRustCallStatusErrorHandler<E>, status: UniffiRustCallStatus) {
241
+ if (status.isSuccess()) {
242
+ return
243
+ } else if (status.isError()) {
244
+ throw errorHandler.lift(status.error_buf)
245
+ } else if (status.isPanic()) {
246
+ // when the rust code sees a panic, it tries to construct a rustbuffer
247
+ // with the message. but if that code panics, then it just sends back
248
+ // an empty buffer.
249
+ if (status.error_buf.len > 0) {
250
+ throw InternalException(FfiConverterString.lift(status.error_buf))
251
+ } else {
252
+ throw InternalException("Rust panic")
253
+ }
254
+ } else {
255
+ throw InternalException("Unknown rust call status: $status.code")
256
+ }
257
+ }
258
+
259
+ /**
260
+ * UniffiRustCallStatusErrorHandler implementation for times when we don't expect a CALL_ERROR
261
+ *
262
+ * @suppress
263
+ */
264
+ object UniffiNullRustCallStatusErrorHandler: UniffiRustCallStatusErrorHandler<InternalException> {
265
+ override fun lift(error_buf: RustBuffer.ByValue): InternalException {
266
+ RustBuffer.free(error_buf)
267
+ return InternalException("Unexpected CALL_ERROR")
268
+ }
269
+ }
270
+
271
+ // Call a rust function that returns a plain value
272
+ private inline fun <U> uniffiRustCall(callback: (UniffiRustCallStatus) -> U): U {
273
+ return uniffiRustCallWithError(UniffiNullRustCallStatusErrorHandler, callback)
274
+ }
275
+
276
+ internal inline fun<T> uniffiTraitInterfaceCall(
277
+ callStatus: UniffiRustCallStatus,
278
+ makeCall: () -> T,
279
+ writeReturn: (T) -> Unit,
280
+ ) {
281
+ try {
282
+ writeReturn(makeCall())
283
+ } catch(e: kotlin.Exception) {
284
+ val err = try { e.stackTraceToString() } catch(_: Throwable) { "" }
285
+ callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR
286
+ callStatus.error_buf = FfiConverterString.lower(err)
287
+ }
288
+ }
289
+
290
+ internal inline fun<T, reified E: Throwable> uniffiTraitInterfaceCallWithError(
291
+ callStatus: UniffiRustCallStatus,
292
+ makeCall: () -> T,
293
+ writeReturn: (T) -> Unit,
294
+ lowerError: (E) -> RustBuffer.ByValue
295
+ ) {
296
+ try {
297
+ writeReturn(makeCall())
298
+ } catch(e: kotlin.Exception) {
299
+ if (e is E) {
300
+ callStatus.code = UNIFFI_CALL_ERROR
301
+ callStatus.error_buf = lowerError(e)
302
+ } else {
303
+ val err = try { e.stackTraceToString() } catch(_: Throwable) { "" }
304
+ callStatus.code = UNIFFI_CALL_UNEXPECTED_ERROR
305
+ callStatus.error_buf = FfiConverterString.lower(err)
306
+ }
307
+ }
308
+ }
309
+ // Initial value and increment amount for handles.
310
+ // These ensure that Kotlin-generated handles always have the lowest bit set
311
+ private const val UNIFFI_HANDLEMAP_INITIAL = 1.toLong()
312
+ private const val UNIFFI_HANDLEMAP_DELTA = 2.toLong()
313
+
314
+ // Map handles to objects
315
+ //
316
+ // This is used pass an opaque 64-bit handle representing a foreign object to the Rust code.
317
+ internal class UniffiHandleMap<T: Any> {
318
+ private val map = ConcurrentHashMap<Long, T>()
319
+ // Start
320
+ private val counter = java.util.concurrent.atomic.AtomicLong(UNIFFI_HANDLEMAP_INITIAL)
321
+
322
+ val size: Int
323
+ get() = map.size
324
+
325
+ // Insert a new object into the handle map and get a handle for it
326
+ fun insert(obj: T): Long {
327
+ val handle = counter.getAndAdd(UNIFFI_HANDLEMAP_DELTA)
328
+ map.put(handle, obj)
329
+ return handle
330
+ }
331
+
332
+ // Clone a handle, creating a new one
333
+ fun clone(handle: Long): Long {
334
+ val obj = map.get(handle) ?: throw InternalException("UniffiHandleMap.clone: Invalid handle")
335
+ return insert(obj)
336
+ }
337
+
338
+ // Get an object from the handle map
339
+ fun get(handle: Long): T {
340
+ return map.get(handle) ?: throw InternalException("UniffiHandleMap.get: Invalid handle")
341
+ }
342
+
343
+ // Remove an entry from the handlemap and get the Kotlin object back
344
+ fun remove(handle: Long): T {
345
+ return map.remove(handle) ?: throw InternalException("UniffiHandleMap: Invalid handle")
346
+ }
347
+ }
348
+
349
+ // Contains loading, initialization code,
350
+ // and the FFI Function declarations in a com.sun.jna.Library.
351
+ @Synchronized
352
+ private fun findLibraryName(componentName: String): String {
353
+ val libOverride = System.getProperty("uniffi.component.$componentName.libraryOverride")
354
+ if (libOverride != null) {
355
+ return libOverride
356
+ }
357
+ return "zkap_uniffi_bindings"
358
+ }
359
+
360
+ // Define FFI callback types
361
+ internal interface UniffiRustFutureContinuationCallback : com.sun.jna.Callback {
362
+ fun callback(`data`: Long,`pollResult`: Byte,)
363
+ }
364
+ internal interface UniffiForeignFutureDroppedCallback : com.sun.jna.Callback {
365
+ fun callback(`handle`: Long,)
366
+ }
367
+ internal interface UniffiCallbackInterfaceFree : com.sun.jna.Callback {
368
+ fun callback(`handle`: Long,)
369
+ }
370
+ internal interface UniffiCallbackInterfaceClone : com.sun.jna.Callback {
371
+ fun callback(`handle`: Long,)
372
+ : Long
373
+ }
374
+ @Structure.FieldOrder("handle", "free")
375
+ internal open class UniffiForeignFutureDroppedCallbackStruct(
376
+ @JvmField internal var `handle`: Long = 0.toLong(),
377
+ @JvmField internal var `free`: UniffiForeignFutureDroppedCallback? = null,
378
+ ) : Structure() {
379
+ class UniffiByValue(
380
+ `handle`: Long = 0.toLong(),
381
+ `free`: UniffiForeignFutureDroppedCallback? = null,
382
+ ): UniffiForeignFutureDroppedCallbackStruct(`handle`,`free`,), Structure.ByValue
383
+
384
+ internal fun uniffiSetValue(other: UniffiForeignFutureDroppedCallbackStruct) {
385
+ `handle` = other.`handle`
386
+ `free` = other.`free`
387
+ }
388
+
389
+ }
390
+ @Structure.FieldOrder("returnValue", "callStatus")
391
+ internal open class UniffiForeignFutureResultU8(
392
+ @JvmField internal var `returnValue`: Byte = 0.toByte(),
393
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
394
+ ) : Structure() {
395
+ class UniffiByValue(
396
+ `returnValue`: Byte = 0.toByte(),
397
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
398
+ ): UniffiForeignFutureResultU8(`returnValue`,`callStatus`,), Structure.ByValue
399
+
400
+ internal fun uniffiSetValue(other: UniffiForeignFutureResultU8) {
401
+ `returnValue` = other.`returnValue`
402
+ `callStatus` = other.`callStatus`
403
+ }
404
+
405
+ }
406
+ internal interface UniffiForeignFutureCompleteU8 : com.sun.jna.Callback {
407
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU8.UniffiByValue,)
408
+ }
409
+ @Structure.FieldOrder("returnValue", "callStatus")
410
+ internal open class UniffiForeignFutureResultI8(
411
+ @JvmField internal var `returnValue`: Byte = 0.toByte(),
412
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
413
+ ) : Structure() {
414
+ class UniffiByValue(
415
+ `returnValue`: Byte = 0.toByte(),
416
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
417
+ ): UniffiForeignFutureResultI8(`returnValue`,`callStatus`,), Structure.ByValue
418
+
419
+ internal fun uniffiSetValue(other: UniffiForeignFutureResultI8) {
420
+ `returnValue` = other.`returnValue`
421
+ `callStatus` = other.`callStatus`
422
+ }
423
+
424
+ }
425
+ internal interface UniffiForeignFutureCompleteI8 : com.sun.jna.Callback {
426
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI8.UniffiByValue,)
427
+ }
428
+ @Structure.FieldOrder("returnValue", "callStatus")
429
+ internal open class UniffiForeignFutureResultU16(
430
+ @JvmField internal var `returnValue`: Short = 0.toShort(),
431
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
432
+ ) : Structure() {
433
+ class UniffiByValue(
434
+ `returnValue`: Short = 0.toShort(),
435
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
436
+ ): UniffiForeignFutureResultU16(`returnValue`,`callStatus`,), Structure.ByValue
437
+
438
+ internal fun uniffiSetValue(other: UniffiForeignFutureResultU16) {
439
+ `returnValue` = other.`returnValue`
440
+ `callStatus` = other.`callStatus`
441
+ }
442
+
443
+ }
444
+ internal interface UniffiForeignFutureCompleteU16 : com.sun.jna.Callback {
445
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU16.UniffiByValue,)
446
+ }
447
+ @Structure.FieldOrder("returnValue", "callStatus")
448
+ internal open class UniffiForeignFutureResultI16(
449
+ @JvmField internal var `returnValue`: Short = 0.toShort(),
450
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
451
+ ) : Structure() {
452
+ class UniffiByValue(
453
+ `returnValue`: Short = 0.toShort(),
454
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
455
+ ): UniffiForeignFutureResultI16(`returnValue`,`callStatus`,), Structure.ByValue
456
+
457
+ internal fun uniffiSetValue(other: UniffiForeignFutureResultI16) {
458
+ `returnValue` = other.`returnValue`
459
+ `callStatus` = other.`callStatus`
460
+ }
461
+
462
+ }
463
+ internal interface UniffiForeignFutureCompleteI16 : com.sun.jna.Callback {
464
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI16.UniffiByValue,)
465
+ }
466
+ @Structure.FieldOrder("returnValue", "callStatus")
467
+ internal open class UniffiForeignFutureResultU32(
468
+ @JvmField internal var `returnValue`: Int = 0,
469
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
470
+ ) : Structure() {
471
+ class UniffiByValue(
472
+ `returnValue`: Int = 0,
473
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
474
+ ): UniffiForeignFutureResultU32(`returnValue`,`callStatus`,), Structure.ByValue
475
+
476
+ internal fun uniffiSetValue(other: UniffiForeignFutureResultU32) {
477
+ `returnValue` = other.`returnValue`
478
+ `callStatus` = other.`callStatus`
479
+ }
480
+
481
+ }
482
+ internal interface UniffiForeignFutureCompleteU32 : com.sun.jna.Callback {
483
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU32.UniffiByValue,)
484
+ }
485
+ @Structure.FieldOrder("returnValue", "callStatus")
486
+ internal open class UniffiForeignFutureResultI32(
487
+ @JvmField internal var `returnValue`: Int = 0,
488
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
489
+ ) : Structure() {
490
+ class UniffiByValue(
491
+ `returnValue`: Int = 0,
492
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
493
+ ): UniffiForeignFutureResultI32(`returnValue`,`callStatus`,), Structure.ByValue
494
+
495
+ internal fun uniffiSetValue(other: UniffiForeignFutureResultI32) {
496
+ `returnValue` = other.`returnValue`
497
+ `callStatus` = other.`callStatus`
498
+ }
499
+
500
+ }
501
+ internal interface UniffiForeignFutureCompleteI32 : com.sun.jna.Callback {
502
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI32.UniffiByValue,)
503
+ }
504
+ @Structure.FieldOrder("returnValue", "callStatus")
505
+ internal open class UniffiForeignFutureResultU64(
506
+ @JvmField internal var `returnValue`: Long = 0.toLong(),
507
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
508
+ ) : Structure() {
509
+ class UniffiByValue(
510
+ `returnValue`: Long = 0.toLong(),
511
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
512
+ ): UniffiForeignFutureResultU64(`returnValue`,`callStatus`,), Structure.ByValue
513
+
514
+ internal fun uniffiSetValue(other: UniffiForeignFutureResultU64) {
515
+ `returnValue` = other.`returnValue`
516
+ `callStatus` = other.`callStatus`
517
+ }
518
+
519
+ }
520
+ internal interface UniffiForeignFutureCompleteU64 : com.sun.jna.Callback {
521
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultU64.UniffiByValue,)
522
+ }
523
+ @Structure.FieldOrder("returnValue", "callStatus")
524
+ internal open class UniffiForeignFutureResultI64(
525
+ @JvmField internal var `returnValue`: Long = 0.toLong(),
526
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
527
+ ) : Structure() {
528
+ class UniffiByValue(
529
+ `returnValue`: Long = 0.toLong(),
530
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
531
+ ): UniffiForeignFutureResultI64(`returnValue`,`callStatus`,), Structure.ByValue
532
+
533
+ internal fun uniffiSetValue(other: UniffiForeignFutureResultI64) {
534
+ `returnValue` = other.`returnValue`
535
+ `callStatus` = other.`callStatus`
536
+ }
537
+
538
+ }
539
+ internal interface UniffiForeignFutureCompleteI64 : com.sun.jna.Callback {
540
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultI64.UniffiByValue,)
541
+ }
542
+ @Structure.FieldOrder("returnValue", "callStatus")
543
+ internal open class UniffiForeignFutureResultF32(
544
+ @JvmField internal var `returnValue`: Float = 0.0f,
545
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
546
+ ) : Structure() {
547
+ class UniffiByValue(
548
+ `returnValue`: Float = 0.0f,
549
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
550
+ ): UniffiForeignFutureResultF32(`returnValue`,`callStatus`,), Structure.ByValue
551
+
552
+ internal fun uniffiSetValue(other: UniffiForeignFutureResultF32) {
553
+ `returnValue` = other.`returnValue`
554
+ `callStatus` = other.`callStatus`
555
+ }
556
+
557
+ }
558
+ internal interface UniffiForeignFutureCompleteF32 : com.sun.jna.Callback {
559
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultF32.UniffiByValue,)
560
+ }
561
+ @Structure.FieldOrder("returnValue", "callStatus")
562
+ internal open class UniffiForeignFutureResultF64(
563
+ @JvmField internal var `returnValue`: Double = 0.0,
564
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
565
+ ) : Structure() {
566
+ class UniffiByValue(
567
+ `returnValue`: Double = 0.0,
568
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
569
+ ): UniffiForeignFutureResultF64(`returnValue`,`callStatus`,), Structure.ByValue
570
+
571
+ internal fun uniffiSetValue(other: UniffiForeignFutureResultF64) {
572
+ `returnValue` = other.`returnValue`
573
+ `callStatus` = other.`callStatus`
574
+ }
575
+
576
+ }
577
+ internal interface UniffiForeignFutureCompleteF64 : com.sun.jna.Callback {
578
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultF64.UniffiByValue,)
579
+ }
580
+ @Structure.FieldOrder("returnValue", "callStatus")
581
+ internal open class UniffiForeignFutureResultRustBuffer(
582
+ @JvmField internal var `returnValue`: RustBuffer.ByValue = RustBuffer.ByValue(),
583
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
584
+ ) : Structure() {
585
+ class UniffiByValue(
586
+ `returnValue`: RustBuffer.ByValue = RustBuffer.ByValue(),
587
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
588
+ ): UniffiForeignFutureResultRustBuffer(`returnValue`,`callStatus`,), Structure.ByValue
589
+
590
+ internal fun uniffiSetValue(other: UniffiForeignFutureResultRustBuffer) {
591
+ `returnValue` = other.`returnValue`
592
+ `callStatus` = other.`callStatus`
593
+ }
594
+
595
+ }
596
+ internal interface UniffiForeignFutureCompleteRustBuffer : com.sun.jna.Callback {
597
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultRustBuffer.UniffiByValue,)
598
+ }
599
+ @Structure.FieldOrder("callStatus")
600
+ internal open class UniffiForeignFutureResultVoid(
601
+ @JvmField internal var `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
602
+ ) : Structure() {
603
+ class UniffiByValue(
604
+ `callStatus`: UniffiRustCallStatus.ByValue = UniffiRustCallStatus.ByValue(),
605
+ ): UniffiForeignFutureResultVoid(`callStatus`,), Structure.ByValue
606
+
607
+ internal fun uniffiSetValue(other: UniffiForeignFutureResultVoid) {
608
+ `callStatus` = other.`callStatus`
609
+ }
610
+
611
+ }
612
+ internal interface UniffiForeignFutureCompleteVoid : com.sun.jna.Callback {
613
+ fun callback(`callbackData`: Long,`result`: UniffiForeignFutureResultVoid.UniffiByValue,)
614
+ }
615
+
616
+ // A JNA Library to expose the extern-C FFI definitions.
617
+ // This is an implementation detail which will be called internally by the public API.
618
+
619
+ // For large crates we prevent `MethodTooLargeException` (see #2340)
620
+ // N.B. the name of the extension is very misleading, since it is
621
+ // rather `InterfaceTooLargeException`, caused by too many methods
622
+ // in the interface for large crates.
623
+ //
624
+ // By splitting the otherwise huge interface into two parts
625
+ // * UniffiLib (this)
626
+ // * IntegrityCheckingUniffiLib
627
+ // And all checksum methods are put into `IntegrityCheckingUniffiLib`
628
+ // we allow for ~2x as many methods in the UniffiLib interface.
629
+ //
630
+ // Note: above all written when we used JNA's `loadIndirect` etc.
631
+ // We now use JNA's "direct mapping" - unclear if same considerations apply exactly.
632
+ internal object IntegrityCheckingUniffiLib {
633
+ init {
634
+ Native.register(IntegrityCheckingUniffiLib::class.java, findLibraryName(componentName = "zkap_uniffi_bindings"))
635
+ uniffiCheckContractApiVersion(this)
636
+ uniffiCheckApiChecksums(this)
637
+ }
638
+ external fun uniffi_zkap_uniffi_bindings_checksum_func_generate_anchor(
639
+ ): Short
640
+ external fun uniffi_zkap_uniffi_bindings_checksum_func_generate_aud_hash(
641
+ ): Short
642
+ external fun uniffi_zkap_uniffi_bindings_checksum_func_generate_hash(
643
+ ): Short
644
+ external fun uniffi_zkap_uniffi_bindings_checksum_func_generate_leaf_hash(
645
+ ): Short
646
+ external fun uniffi_zkap_uniffi_bindings_checksum_func_prove(
647
+ ): Short
648
+ external fun ffi_zkap_uniffi_bindings_uniffi_contract_version(
649
+ ): Int
650
+
651
+
652
+ }
653
+
654
+ internal object UniffiLib {
655
+
656
+
657
+ init {
658
+ Native.register(UniffiLib::class.java, findLibraryName(componentName = "zkap_uniffi_bindings"))
659
+
660
+ }
661
+ external fun uniffi_zkap_uniffi_bindings_fn_func_generate_anchor(`config`: RustBuffer.ByValue,`secrets`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
662
+ ): RustBuffer.ByValue
663
+ external fun uniffi_zkap_uniffi_bindings_fn_func_generate_aud_hash(`config`: RustBuffer.ByValue,`audList`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
664
+ ): RustBuffer.ByValue
665
+ external fun uniffi_zkap_uniffi_bindings_fn_func_generate_hash(`messages`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
666
+ ): RustBuffer.ByValue
667
+ external fun uniffi_zkap_uniffi_bindings_fn_func_generate_leaf_hash(`config`: RustBuffer.ByValue,`iss`: RustBuffer.ByValue,`pkB64`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
668
+ ): RustBuffer.ByValue
669
+ external fun uniffi_zkap_uniffi_bindings_fn_func_prove(`config`: RustBuffer.ByValue,`request`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
670
+ ): RustBuffer.ByValue
671
+ external fun ffi_zkap_uniffi_bindings_rustbuffer_alloc(`size`: Long,uniffi_out_err: UniffiRustCallStatus,
672
+ ): RustBuffer.ByValue
673
+ external fun ffi_zkap_uniffi_bindings_rustbuffer_from_bytes(`bytes`: ForeignBytes.ByValue,uniffi_out_err: UniffiRustCallStatus,
674
+ ): RustBuffer.ByValue
675
+ external fun ffi_zkap_uniffi_bindings_rustbuffer_free(`buf`: RustBuffer.ByValue,uniffi_out_err: UniffiRustCallStatus,
676
+ ): Unit
677
+ external fun ffi_zkap_uniffi_bindings_rustbuffer_reserve(`buf`: RustBuffer.ByValue,`additional`: Long,uniffi_out_err: UniffiRustCallStatus,
678
+ ): RustBuffer.ByValue
679
+ external fun ffi_zkap_uniffi_bindings_rust_future_poll_u8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
680
+ ): Unit
681
+ external fun ffi_zkap_uniffi_bindings_rust_future_cancel_u8(`handle`: Long,
682
+ ): Unit
683
+ external fun ffi_zkap_uniffi_bindings_rust_future_free_u8(`handle`: Long,
684
+ ): Unit
685
+ external fun ffi_zkap_uniffi_bindings_rust_future_complete_u8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
686
+ ): Byte
687
+ external fun ffi_zkap_uniffi_bindings_rust_future_poll_i8(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
688
+ ): Unit
689
+ external fun ffi_zkap_uniffi_bindings_rust_future_cancel_i8(`handle`: Long,
690
+ ): Unit
691
+ external fun ffi_zkap_uniffi_bindings_rust_future_free_i8(`handle`: Long,
692
+ ): Unit
693
+ external fun ffi_zkap_uniffi_bindings_rust_future_complete_i8(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
694
+ ): Byte
695
+ external fun ffi_zkap_uniffi_bindings_rust_future_poll_u16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
696
+ ): Unit
697
+ external fun ffi_zkap_uniffi_bindings_rust_future_cancel_u16(`handle`: Long,
698
+ ): Unit
699
+ external fun ffi_zkap_uniffi_bindings_rust_future_free_u16(`handle`: Long,
700
+ ): Unit
701
+ external fun ffi_zkap_uniffi_bindings_rust_future_complete_u16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
702
+ ): Short
703
+ external fun ffi_zkap_uniffi_bindings_rust_future_poll_i16(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
704
+ ): Unit
705
+ external fun ffi_zkap_uniffi_bindings_rust_future_cancel_i16(`handle`: Long,
706
+ ): Unit
707
+ external fun ffi_zkap_uniffi_bindings_rust_future_free_i16(`handle`: Long,
708
+ ): Unit
709
+ external fun ffi_zkap_uniffi_bindings_rust_future_complete_i16(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
710
+ ): Short
711
+ external fun ffi_zkap_uniffi_bindings_rust_future_poll_u32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
712
+ ): Unit
713
+ external fun ffi_zkap_uniffi_bindings_rust_future_cancel_u32(`handle`: Long,
714
+ ): Unit
715
+ external fun ffi_zkap_uniffi_bindings_rust_future_free_u32(`handle`: Long,
716
+ ): Unit
717
+ external fun ffi_zkap_uniffi_bindings_rust_future_complete_u32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
718
+ ): Int
719
+ external fun ffi_zkap_uniffi_bindings_rust_future_poll_i32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
720
+ ): Unit
721
+ external fun ffi_zkap_uniffi_bindings_rust_future_cancel_i32(`handle`: Long,
722
+ ): Unit
723
+ external fun ffi_zkap_uniffi_bindings_rust_future_free_i32(`handle`: Long,
724
+ ): Unit
725
+ external fun ffi_zkap_uniffi_bindings_rust_future_complete_i32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
726
+ ): Int
727
+ external fun ffi_zkap_uniffi_bindings_rust_future_poll_u64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
728
+ ): Unit
729
+ external fun ffi_zkap_uniffi_bindings_rust_future_cancel_u64(`handle`: Long,
730
+ ): Unit
731
+ external fun ffi_zkap_uniffi_bindings_rust_future_free_u64(`handle`: Long,
732
+ ): Unit
733
+ external fun ffi_zkap_uniffi_bindings_rust_future_complete_u64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
734
+ ): Long
735
+ external fun ffi_zkap_uniffi_bindings_rust_future_poll_i64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
736
+ ): Unit
737
+ external fun ffi_zkap_uniffi_bindings_rust_future_cancel_i64(`handle`: Long,
738
+ ): Unit
739
+ external fun ffi_zkap_uniffi_bindings_rust_future_free_i64(`handle`: Long,
740
+ ): Unit
741
+ external fun ffi_zkap_uniffi_bindings_rust_future_complete_i64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
742
+ ): Long
743
+ external fun ffi_zkap_uniffi_bindings_rust_future_poll_f32(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
744
+ ): Unit
745
+ external fun ffi_zkap_uniffi_bindings_rust_future_cancel_f32(`handle`: Long,
746
+ ): Unit
747
+ external fun ffi_zkap_uniffi_bindings_rust_future_free_f32(`handle`: Long,
748
+ ): Unit
749
+ external fun ffi_zkap_uniffi_bindings_rust_future_complete_f32(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
750
+ ): Float
751
+ external fun ffi_zkap_uniffi_bindings_rust_future_poll_f64(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
752
+ ): Unit
753
+ external fun ffi_zkap_uniffi_bindings_rust_future_cancel_f64(`handle`: Long,
754
+ ): Unit
755
+ external fun ffi_zkap_uniffi_bindings_rust_future_free_f64(`handle`: Long,
756
+ ): Unit
757
+ external fun ffi_zkap_uniffi_bindings_rust_future_complete_f64(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
758
+ ): Double
759
+ external fun ffi_zkap_uniffi_bindings_rust_future_poll_rust_buffer(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
760
+ ): Unit
761
+ external fun ffi_zkap_uniffi_bindings_rust_future_cancel_rust_buffer(`handle`: Long,
762
+ ): Unit
763
+ external fun ffi_zkap_uniffi_bindings_rust_future_free_rust_buffer(`handle`: Long,
764
+ ): Unit
765
+ external fun ffi_zkap_uniffi_bindings_rust_future_complete_rust_buffer(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
766
+ ): RustBuffer.ByValue
767
+ external fun ffi_zkap_uniffi_bindings_rust_future_poll_void(`handle`: Long,`callback`: UniffiRustFutureContinuationCallback,`callbackData`: Long,
768
+ ): Unit
769
+ external fun ffi_zkap_uniffi_bindings_rust_future_cancel_void(`handle`: Long,
770
+ ): Unit
771
+ external fun ffi_zkap_uniffi_bindings_rust_future_free_void(`handle`: Long,
772
+ ): Unit
773
+ external fun ffi_zkap_uniffi_bindings_rust_future_complete_void(`handle`: Long,uniffi_out_err: UniffiRustCallStatus,
774
+ ): Unit
775
+
776
+
777
+ }
778
+
779
+ private fun uniffiCheckContractApiVersion(lib: IntegrityCheckingUniffiLib) {
780
+ // Get the bindings contract version from our ComponentInterface
781
+ val bindings_contract_version = 30
782
+ // Get the scaffolding contract version by calling the into the dylib
783
+ val scaffolding_contract_version = lib.ffi_zkap_uniffi_bindings_uniffi_contract_version()
784
+ if (bindings_contract_version != scaffolding_contract_version) {
785
+ throw RuntimeException("UniFFI contract version mismatch: try cleaning and rebuilding your project")
786
+ }
787
+ }
788
+ @Suppress("UNUSED_PARAMETER")
789
+ private fun uniffiCheckApiChecksums(lib: IntegrityCheckingUniffiLib) {
790
+ if (lib.uniffi_zkap_uniffi_bindings_checksum_func_generate_anchor() != 10088.toShort()) {
791
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
792
+ }
793
+ if (lib.uniffi_zkap_uniffi_bindings_checksum_func_generate_aud_hash() != 42467.toShort()) {
794
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
795
+ }
796
+ if (lib.uniffi_zkap_uniffi_bindings_checksum_func_generate_hash() != 6188.toShort()) {
797
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
798
+ }
799
+ if (lib.uniffi_zkap_uniffi_bindings_checksum_func_generate_leaf_hash() != 28430.toShort()) {
800
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
801
+ }
802
+ if (lib.uniffi_zkap_uniffi_bindings_checksum_func_prove() != 26090.toShort()) {
803
+ throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
804
+ }
805
+ }
806
+
807
+ /**
808
+ * @suppress
809
+ */
810
+ public fun uniffiEnsureInitialized() {
811
+ IntegrityCheckingUniffiLib
812
+ // UniffiLib() initialized as objects are used, but we still need to explicitly
813
+ // reference it so initialization across crates works as expected.
814
+ UniffiLib
815
+ }
816
+
817
+ // Async support
818
+
819
+ // Public interface members begin here.
820
+
821
+
822
+ // Interface implemented by anything that can contain an object reference.
823
+ //
824
+ // Such types expose a `destroy()` method that must be called to cleanly
825
+ // dispose of the contained objects. Failure to call this method may result
826
+ // in memory leaks.
827
+ //
828
+ // The easiest way to ensure this method is called is to use the `.use`
829
+ // helper method to execute a block and destroy the object at the end.
830
+ interface Disposable {
831
+ fun destroy()
832
+ companion object {
833
+ fun destroy(vararg args: Any?) {
834
+ for (arg in args) {
835
+ when (arg) {
836
+ is Disposable -> arg.destroy()
837
+ is ArrayList<*> -> {
838
+ for (idx in arg.indices) {
839
+ val element = arg[idx]
840
+ if (element is Disposable) {
841
+ element.destroy()
842
+ }
843
+ }
844
+ }
845
+ is Map<*, *> -> {
846
+ for (element in arg.values) {
847
+ if (element is Disposable) {
848
+ element.destroy()
849
+ }
850
+ }
851
+ }
852
+ is Iterable<*> -> {
853
+ for (element in arg) {
854
+ if (element is Disposable) {
855
+ element.destroy()
856
+ }
857
+ }
858
+ }
859
+ }
860
+ }
861
+ }
862
+ }
863
+ }
864
+
865
+ /**
866
+ * @suppress
867
+ */
868
+ inline fun <T : Disposable?, R> T.use(block: (T) -> R) =
869
+ try {
870
+ block(this)
871
+ } finally {
872
+ try {
873
+ // N.B. our implementation is on the nullable type `Disposable?`.
874
+ this?.destroy()
875
+ } catch (e: Throwable) {
876
+ // swallow
877
+ }
878
+ }
879
+
880
+ /**
881
+ * Placeholder object used to signal that we're constructing an interface with a FFI handle.
882
+ *
883
+ * This is the first argument for interface constructors that input a raw handle. It exists is that
884
+ * so we can avoid signature conflicts when an interface has a regular constructor than inputs a
885
+ * Long.
886
+ *
887
+ * @suppress
888
+ * */
889
+ object UniffiWithHandle
890
+
891
+ /**
892
+ * Used to instantiate an interface without an actual pointer, for fakes in tests, mostly.
893
+ *
894
+ * @suppress
895
+ * */
896
+ object NoHandle
897
+
898
+ /**
899
+ * @suppress
900
+ */
901
+ public object FfiConverterULong: FfiConverter<ULong, Long> {
902
+ override fun lift(value: Long): ULong {
903
+ return value.toULong()
904
+ }
905
+
906
+ override fun read(buf: ByteBuffer): ULong {
907
+ return lift(buf.getLong())
908
+ }
909
+
910
+ override fun lower(value: ULong): Long {
911
+ return value.toLong()
912
+ }
913
+
914
+ override fun allocationSize(value: ULong) = 8UL
915
+
916
+ override fun write(value: ULong, buf: ByteBuffer) {
917
+ buf.putLong(value.toLong())
918
+ }
919
+ }
920
+
921
+ /**
922
+ * @suppress
923
+ */
924
+ public object FfiConverterString: FfiConverter<String, RustBuffer.ByValue> {
925
+ // Note: we don't inherit from FfiConverterRustBuffer, because we use a
926
+ // special encoding when lowering/lifting. We can use `RustBuffer.len` to
927
+ // store our length and avoid writing it out to the buffer.
928
+ override fun lift(value: RustBuffer.ByValue): String {
929
+ try {
930
+ val byteArr = ByteArray(value.len.toInt())
931
+ value.asByteBuffer()!!.get(byteArr)
932
+ return byteArr.toString(Charsets.UTF_8)
933
+ } finally {
934
+ RustBuffer.free(value)
935
+ }
936
+ }
937
+
938
+ override fun read(buf: ByteBuffer): String {
939
+ val len = buf.getInt()
940
+ val byteArr = ByteArray(len)
941
+ buf.get(byteArr)
942
+ return byteArr.toString(Charsets.UTF_8)
943
+ }
944
+
945
+ fun toUtf8(value: String): ByteBuffer {
946
+ // Make sure we don't have invalid UTF-16, check for lone surrogates.
947
+ return Charsets.UTF_8.newEncoder().run {
948
+ onMalformedInput(CodingErrorAction.REPORT)
949
+ encode(CharBuffer.wrap(value))
950
+ }
951
+ }
952
+
953
+ override fun lower(value: String): RustBuffer.ByValue {
954
+ val byteBuf = toUtf8(value)
955
+ // Ideally we'd pass these bytes to `ffi_bytebuffer_from_bytes`, but doing so would require us
956
+ // to copy them into a JNA `Memory`. So we might as well directly copy them into a `RustBuffer`.
957
+ val rbuf = RustBuffer.alloc(byteBuf.limit().toULong())
958
+ rbuf.asByteBuffer()!!.put(byteBuf)
959
+ return rbuf
960
+ }
961
+
962
+ // We aren't sure exactly how many bytes our string will be once it's UTF-8
963
+ // encoded. Allocate 3 bytes per UTF-16 code unit which will always be
964
+ // enough.
965
+ override fun allocationSize(value: String): ULong {
966
+ val sizeForLength = 4UL
967
+ val sizeForString = value.length.toULong() * 3UL
968
+ return sizeForLength + sizeForString
969
+ }
970
+
971
+ override fun write(value: String, buf: ByteBuffer) {
972
+ val byteBuf = toUtf8(value)
973
+ buf.putInt(byteBuf.limit())
974
+ buf.put(byteBuf)
975
+ }
976
+ }
977
+
978
+
979
+
980
+ data class ZkapAnchorResult (
981
+ var `evaluations`: List<kotlin.String>
982
+
983
+ ){
984
+
985
+
986
+
987
+
988
+
989
+ companion object
990
+ }
991
+
992
+ /**
993
+ * @suppress
994
+ */
995
+ public object FfiConverterTypeZkapAnchorResult: FfiConverterRustBuffer<ZkapAnchorResult> {
996
+ override fun read(buf: ByteBuffer): ZkapAnchorResult {
997
+ return ZkapAnchorResult(
998
+ FfiConverterSequenceString.read(buf),
999
+ )
1000
+ }
1001
+
1002
+ override fun allocationSize(value: ZkapAnchorResult) = (
1003
+ FfiConverterSequenceString.allocationSize(value.`evaluations`)
1004
+ )
1005
+
1006
+ override fun write(value: ZkapAnchorResult, buf: ByteBuffer) {
1007
+ FfiConverterSequenceString.write(value.`evaluations`, buf)
1008
+ }
1009
+ }
1010
+
1011
+
1012
+
1013
+ data class ZkapAudHashResult (
1014
+ var `audHashes`: List<kotlin.String>
1015
+ ,
1016
+ var `hAudList`: kotlin.String
1017
+
1018
+ ){
1019
+
1020
+
1021
+
1022
+
1023
+
1024
+ companion object
1025
+ }
1026
+
1027
+ /**
1028
+ * @suppress
1029
+ */
1030
+ public object FfiConverterTypeZkapAudHashResult: FfiConverterRustBuffer<ZkapAudHashResult> {
1031
+ override fun read(buf: ByteBuffer): ZkapAudHashResult {
1032
+ return ZkapAudHashResult(
1033
+ FfiConverterSequenceString.read(buf),
1034
+ FfiConverterString.read(buf),
1035
+ )
1036
+ }
1037
+
1038
+ override fun allocationSize(value: ZkapAudHashResult) = (
1039
+ FfiConverterSequenceString.allocationSize(value.`audHashes`) +
1040
+ FfiConverterString.allocationSize(value.`hAudList`)
1041
+ )
1042
+
1043
+ override fun write(value: ZkapAudHashResult, buf: ByteBuffer) {
1044
+ FfiConverterSequenceString.write(value.`audHashes`, buf)
1045
+ FfiConverterString.write(value.`hAudList`, buf)
1046
+ }
1047
+ }
1048
+
1049
+
1050
+
1051
+ data class ZkapCircuitConfig (
1052
+ var `maxJwtB64Len`: kotlin.ULong
1053
+ ,
1054
+ var `maxPayloadB64Len`: kotlin.ULong
1055
+ ,
1056
+ var `maxAudLen`: kotlin.ULong
1057
+ ,
1058
+ var `maxExpLen`: kotlin.ULong
1059
+ ,
1060
+ var `maxIssLen`: kotlin.ULong
1061
+ ,
1062
+ var `maxNonceLen`: kotlin.ULong
1063
+ ,
1064
+ var `maxSubLen`: kotlin.ULong
1065
+ ,
1066
+ var `n`: kotlin.ULong
1067
+ ,
1068
+ var `k`: kotlin.ULong
1069
+ ,
1070
+ var `treeHeight`: kotlin.ULong
1071
+ ,
1072
+ var `numAudienceLimit`: kotlin.ULong
1073
+ ,
1074
+ var `claims`: List<kotlin.String>
1075
+ ,
1076
+ var `forbiddenString`: kotlin.String
1077
+
1078
+ ){
1079
+
1080
+
1081
+
1082
+
1083
+
1084
+ companion object
1085
+ }
1086
+
1087
+ /**
1088
+ * @suppress
1089
+ */
1090
+ public object FfiConverterTypeZkapCircuitConfig: FfiConverterRustBuffer<ZkapCircuitConfig> {
1091
+ override fun read(buf: ByteBuffer): ZkapCircuitConfig {
1092
+ return ZkapCircuitConfig(
1093
+ FfiConverterULong.read(buf),
1094
+ FfiConverterULong.read(buf),
1095
+ FfiConverterULong.read(buf),
1096
+ FfiConverterULong.read(buf),
1097
+ FfiConverterULong.read(buf),
1098
+ FfiConverterULong.read(buf),
1099
+ FfiConverterULong.read(buf),
1100
+ FfiConverterULong.read(buf),
1101
+ FfiConverterULong.read(buf),
1102
+ FfiConverterULong.read(buf),
1103
+ FfiConverterULong.read(buf),
1104
+ FfiConverterSequenceString.read(buf),
1105
+ FfiConverterString.read(buf),
1106
+ )
1107
+ }
1108
+
1109
+ override fun allocationSize(value: ZkapCircuitConfig) = (
1110
+ FfiConverterULong.allocationSize(value.`maxJwtB64Len`) +
1111
+ FfiConverterULong.allocationSize(value.`maxPayloadB64Len`) +
1112
+ FfiConverterULong.allocationSize(value.`maxAudLen`) +
1113
+ FfiConverterULong.allocationSize(value.`maxExpLen`) +
1114
+ FfiConverterULong.allocationSize(value.`maxIssLen`) +
1115
+ FfiConverterULong.allocationSize(value.`maxNonceLen`) +
1116
+ FfiConverterULong.allocationSize(value.`maxSubLen`) +
1117
+ FfiConverterULong.allocationSize(value.`n`) +
1118
+ FfiConverterULong.allocationSize(value.`k`) +
1119
+ FfiConverterULong.allocationSize(value.`treeHeight`) +
1120
+ FfiConverterULong.allocationSize(value.`numAudienceLimit`) +
1121
+ FfiConverterSequenceString.allocationSize(value.`claims`) +
1122
+ FfiConverterString.allocationSize(value.`forbiddenString`)
1123
+ )
1124
+
1125
+ override fun write(value: ZkapCircuitConfig, buf: ByteBuffer) {
1126
+ FfiConverterULong.write(value.`maxJwtB64Len`, buf)
1127
+ FfiConverterULong.write(value.`maxPayloadB64Len`, buf)
1128
+ FfiConverterULong.write(value.`maxAudLen`, buf)
1129
+ FfiConverterULong.write(value.`maxExpLen`, buf)
1130
+ FfiConverterULong.write(value.`maxIssLen`, buf)
1131
+ FfiConverterULong.write(value.`maxNonceLen`, buf)
1132
+ FfiConverterULong.write(value.`maxSubLen`, buf)
1133
+ FfiConverterULong.write(value.`n`, buf)
1134
+ FfiConverterULong.write(value.`k`, buf)
1135
+ FfiConverterULong.write(value.`treeHeight`, buf)
1136
+ FfiConverterULong.write(value.`numAudienceLimit`, buf)
1137
+ FfiConverterSequenceString.write(value.`claims`, buf)
1138
+ FfiConverterString.write(value.`forbiddenString`, buf)
1139
+ }
1140
+ }
1141
+
1142
+
1143
+
1144
+ data class ZkapProofOutput (
1145
+ /**
1146
+ * Solidity-compatible proof components per credential: [ax, ay, bx_c1, bx_c0, by_c1, by_c0, cx, cy]
1147
+ */
1148
+ var `proofs`: List<List<kotlin.String>>
1149
+ ,
1150
+ var `sharedInputs`: List<kotlin.String>
1151
+ ,
1152
+ var `partialRhsList`: List<kotlin.String>
1153
+ ,
1154
+ var `jwtExpList`: List<kotlin.String>
1155
+
1156
+ ){
1157
+
1158
+
1159
+
1160
+
1161
+
1162
+ companion object
1163
+ }
1164
+
1165
+ /**
1166
+ * @suppress
1167
+ */
1168
+ public object FfiConverterTypeZkapProofOutput: FfiConverterRustBuffer<ZkapProofOutput> {
1169
+ override fun read(buf: ByteBuffer): ZkapProofOutput {
1170
+ return ZkapProofOutput(
1171
+ FfiConverterSequenceSequenceString.read(buf),
1172
+ FfiConverterSequenceString.read(buf),
1173
+ FfiConverterSequenceString.read(buf),
1174
+ FfiConverterSequenceString.read(buf),
1175
+ )
1176
+ }
1177
+
1178
+ override fun allocationSize(value: ZkapProofOutput) = (
1179
+ FfiConverterSequenceSequenceString.allocationSize(value.`proofs`) +
1180
+ FfiConverterSequenceString.allocationSize(value.`sharedInputs`) +
1181
+ FfiConverterSequenceString.allocationSize(value.`partialRhsList`) +
1182
+ FfiConverterSequenceString.allocationSize(value.`jwtExpList`)
1183
+ )
1184
+
1185
+ override fun write(value: ZkapProofOutput, buf: ByteBuffer) {
1186
+ FfiConverterSequenceSequenceString.write(value.`proofs`, buf)
1187
+ FfiConverterSequenceString.write(value.`sharedInputs`, buf)
1188
+ FfiConverterSequenceString.write(value.`partialRhsList`, buf)
1189
+ FfiConverterSequenceString.write(value.`jwtExpList`, buf)
1190
+ }
1191
+ }
1192
+
1193
+
1194
+
1195
+ data class ZkapProofRequest (
1196
+ var `pkPath`: kotlin.String
1197
+ ,
1198
+ var `jwts`: List<kotlin.String>
1199
+ ,
1200
+ var `pkOps`: List<kotlin.String>
1201
+ ,
1202
+ var `merklePaths`: List<List<kotlin.String>>
1203
+ ,
1204
+ var `leafIndices`: List<kotlin.ULong>
1205
+ ,
1206
+ var `root`: kotlin.String
1207
+ ,
1208
+ var `anchorEvals`: List<kotlin.String>
1209
+ ,
1210
+ var `hanchor`: kotlin.String
1211
+ ,
1212
+ var `hSignUserOp`: kotlin.String
1213
+ ,
1214
+ var `random`: kotlin.String
1215
+ ,
1216
+ var `audHashList`: List<kotlin.String>
1217
+
1218
+ ){
1219
+
1220
+
1221
+
1222
+
1223
+
1224
+ companion object
1225
+ }
1226
+
1227
+ /**
1228
+ * @suppress
1229
+ */
1230
+ public object FfiConverterTypeZkapProofRequest: FfiConverterRustBuffer<ZkapProofRequest> {
1231
+ override fun read(buf: ByteBuffer): ZkapProofRequest {
1232
+ return ZkapProofRequest(
1233
+ FfiConverterString.read(buf),
1234
+ FfiConverterSequenceString.read(buf),
1235
+ FfiConverterSequenceString.read(buf),
1236
+ FfiConverterSequenceSequenceString.read(buf),
1237
+ FfiConverterSequenceULong.read(buf),
1238
+ FfiConverterString.read(buf),
1239
+ FfiConverterSequenceString.read(buf),
1240
+ FfiConverterString.read(buf),
1241
+ FfiConverterString.read(buf),
1242
+ FfiConverterString.read(buf),
1243
+ FfiConverterSequenceString.read(buf),
1244
+ )
1245
+ }
1246
+
1247
+ override fun allocationSize(value: ZkapProofRequest) = (
1248
+ FfiConverterString.allocationSize(value.`pkPath`) +
1249
+ FfiConverterSequenceString.allocationSize(value.`jwts`) +
1250
+ FfiConverterSequenceString.allocationSize(value.`pkOps`) +
1251
+ FfiConverterSequenceSequenceString.allocationSize(value.`merklePaths`) +
1252
+ FfiConverterSequenceULong.allocationSize(value.`leafIndices`) +
1253
+ FfiConverterString.allocationSize(value.`root`) +
1254
+ FfiConverterSequenceString.allocationSize(value.`anchorEvals`) +
1255
+ FfiConverterString.allocationSize(value.`hanchor`) +
1256
+ FfiConverterString.allocationSize(value.`hSignUserOp`) +
1257
+ FfiConverterString.allocationSize(value.`random`) +
1258
+ FfiConverterSequenceString.allocationSize(value.`audHashList`)
1259
+ )
1260
+
1261
+ override fun write(value: ZkapProofRequest, buf: ByteBuffer) {
1262
+ FfiConverterString.write(value.`pkPath`, buf)
1263
+ FfiConverterSequenceString.write(value.`jwts`, buf)
1264
+ FfiConverterSequenceString.write(value.`pkOps`, buf)
1265
+ FfiConverterSequenceSequenceString.write(value.`merklePaths`, buf)
1266
+ FfiConverterSequenceULong.write(value.`leafIndices`, buf)
1267
+ FfiConverterString.write(value.`root`, buf)
1268
+ FfiConverterSequenceString.write(value.`anchorEvals`, buf)
1269
+ FfiConverterString.write(value.`hanchor`, buf)
1270
+ FfiConverterString.write(value.`hSignUserOp`, buf)
1271
+ FfiConverterString.write(value.`random`, buf)
1272
+ FfiConverterSequenceString.write(value.`audHashList`, buf)
1273
+ }
1274
+ }
1275
+
1276
+
1277
+
1278
+ data class ZkapSecret (
1279
+ var `sub`: kotlin.String
1280
+ ,
1281
+ var `iss`: kotlin.String
1282
+ ,
1283
+ var `aud`: kotlin.String
1284
+
1285
+ ){
1286
+
1287
+
1288
+
1289
+
1290
+
1291
+ companion object
1292
+ }
1293
+
1294
+ /**
1295
+ * @suppress
1296
+ */
1297
+ public object FfiConverterTypeZkapSecret: FfiConverterRustBuffer<ZkapSecret> {
1298
+ override fun read(buf: ByteBuffer): ZkapSecret {
1299
+ return ZkapSecret(
1300
+ FfiConverterString.read(buf),
1301
+ FfiConverterString.read(buf),
1302
+ FfiConverterString.read(buf),
1303
+ )
1304
+ }
1305
+
1306
+ override fun allocationSize(value: ZkapSecret) = (
1307
+ FfiConverterString.allocationSize(value.`sub`) +
1308
+ FfiConverterString.allocationSize(value.`iss`) +
1309
+ FfiConverterString.allocationSize(value.`aud`)
1310
+ )
1311
+
1312
+ override fun write(value: ZkapSecret, buf: ByteBuffer) {
1313
+ FfiConverterString.write(value.`sub`, buf)
1314
+ FfiConverterString.write(value.`iss`, buf)
1315
+ FfiConverterString.write(value.`aud`, buf)
1316
+ }
1317
+ }
1318
+
1319
+
1320
+
1321
+
1322
+
1323
+ sealed class ZkapException: kotlin.Exception() {
1324
+
1325
+ class ApplicationException(
1326
+
1327
+ val errorMessage: kotlin.String
1328
+ ) : ZkapException() {
1329
+ override val message
1330
+ get() = "message=${ errorMessage }"
1331
+ }
1332
+
1333
+
1334
+
1335
+
1336
+
1337
+ companion object ErrorHandler : UniffiRustCallStatusErrorHandler<ZkapException> {
1338
+ override fun lift(error_buf: RustBuffer.ByValue): ZkapException = FfiConverterTypeZkapError.lift(error_buf)
1339
+ }
1340
+
1341
+
1342
+ }
1343
+
1344
+ /**
1345
+ * @suppress
1346
+ */
1347
+ public object FfiConverterTypeZkapError : FfiConverterRustBuffer<ZkapException> {
1348
+ override fun read(buf: ByteBuffer): ZkapException {
1349
+
1350
+
1351
+ return when(buf.getInt()) {
1352
+ 1 -> ZkapException.ApplicationException(
1353
+ FfiConverterString.read(buf),
1354
+ )
1355
+ else -> throw RuntimeException("invalid error enum value, something is very wrong!!")
1356
+ }
1357
+ }
1358
+
1359
+ override fun allocationSize(value: ZkapException): ULong {
1360
+ return when(value) {
1361
+ is ZkapException.ApplicationException -> (
1362
+ // Add the size for the Int that specifies the variant plus the size needed for all fields
1363
+ 4UL
1364
+ + FfiConverterString.allocationSize(value.errorMessage)
1365
+ )
1366
+ }
1367
+ }
1368
+
1369
+ override fun write(value: ZkapException, buf: ByteBuffer) {
1370
+ when(value) {
1371
+ is ZkapException.ApplicationException -> {
1372
+ buf.putInt(1)
1373
+ FfiConverterString.write(value.errorMessage, buf)
1374
+ Unit
1375
+ }
1376
+ }.let { /* this makes the `when` an expression, which ensures it is exhaustive */ }
1377
+ }
1378
+
1379
+ }
1380
+
1381
+
1382
+
1383
+
1384
+ /**
1385
+ * @suppress
1386
+ */
1387
+ public object FfiConverterSequenceULong: FfiConverterRustBuffer<List<kotlin.ULong>> {
1388
+ override fun read(buf: ByteBuffer): List<kotlin.ULong> {
1389
+ val len = buf.getInt()
1390
+ return List<kotlin.ULong>(len) {
1391
+ FfiConverterULong.read(buf)
1392
+ }
1393
+ }
1394
+
1395
+ override fun allocationSize(value: List<kotlin.ULong>): ULong {
1396
+ val sizeForLength = 4UL
1397
+ val sizeForItems = value.map { FfiConverterULong.allocationSize(it) }.sum()
1398
+ return sizeForLength + sizeForItems
1399
+ }
1400
+
1401
+ override fun write(value: List<kotlin.ULong>, buf: ByteBuffer) {
1402
+ buf.putInt(value.size)
1403
+ value.iterator().forEach {
1404
+ FfiConverterULong.write(it, buf)
1405
+ }
1406
+ }
1407
+ }
1408
+
1409
+
1410
+
1411
+
1412
+ /**
1413
+ * @suppress
1414
+ */
1415
+ public object FfiConverterSequenceString: FfiConverterRustBuffer<List<kotlin.String>> {
1416
+ override fun read(buf: ByteBuffer): List<kotlin.String> {
1417
+ val len = buf.getInt()
1418
+ return List<kotlin.String>(len) {
1419
+ FfiConverterString.read(buf)
1420
+ }
1421
+ }
1422
+
1423
+ override fun allocationSize(value: List<kotlin.String>): ULong {
1424
+ val sizeForLength = 4UL
1425
+ val sizeForItems = value.map { FfiConverterString.allocationSize(it) }.sum()
1426
+ return sizeForLength + sizeForItems
1427
+ }
1428
+
1429
+ override fun write(value: List<kotlin.String>, buf: ByteBuffer) {
1430
+ buf.putInt(value.size)
1431
+ value.iterator().forEach {
1432
+ FfiConverterString.write(it, buf)
1433
+ }
1434
+ }
1435
+ }
1436
+
1437
+
1438
+
1439
+
1440
+ /**
1441
+ * @suppress
1442
+ */
1443
+ public object FfiConverterSequenceTypeZkapSecret: FfiConverterRustBuffer<List<ZkapSecret>> {
1444
+ override fun read(buf: ByteBuffer): List<ZkapSecret> {
1445
+ val len = buf.getInt()
1446
+ return List<ZkapSecret>(len) {
1447
+ FfiConverterTypeZkapSecret.read(buf)
1448
+ }
1449
+ }
1450
+
1451
+ override fun allocationSize(value: List<ZkapSecret>): ULong {
1452
+ val sizeForLength = 4UL
1453
+ val sizeForItems = value.map { FfiConverterTypeZkapSecret.allocationSize(it) }.sum()
1454
+ return sizeForLength + sizeForItems
1455
+ }
1456
+
1457
+ override fun write(value: List<ZkapSecret>, buf: ByteBuffer) {
1458
+ buf.putInt(value.size)
1459
+ value.iterator().forEach {
1460
+ FfiConverterTypeZkapSecret.write(it, buf)
1461
+ }
1462
+ }
1463
+ }
1464
+
1465
+
1466
+
1467
+
1468
+ /**
1469
+ * @suppress
1470
+ */
1471
+ public object FfiConverterSequenceSequenceString: FfiConverterRustBuffer<List<List<kotlin.String>>> {
1472
+ override fun read(buf: ByteBuffer): List<List<kotlin.String>> {
1473
+ val len = buf.getInt()
1474
+ return List<List<kotlin.String>>(len) {
1475
+ FfiConverterSequenceString.read(buf)
1476
+ }
1477
+ }
1478
+
1479
+ override fun allocationSize(value: List<List<kotlin.String>>): ULong {
1480
+ val sizeForLength = 4UL
1481
+ val sizeForItems = value.map { FfiConverterSequenceString.allocationSize(it) }.sum()
1482
+ return sizeForLength + sizeForItems
1483
+ }
1484
+
1485
+ override fun write(value: List<List<kotlin.String>>, buf: ByteBuffer) {
1486
+ buf.putInt(value.size)
1487
+ value.iterator().forEach {
1488
+ FfiConverterSequenceString.write(it, buf)
1489
+ }
1490
+ }
1491
+ }
1492
+ /**
1493
+ * Generate a Poseidon threshold anchor from a list of JWT credential secrets.
1494
+ */
1495
+ @Throws(ZkapException::class) fun `generateAnchor`(`config`: ZkapCircuitConfig, `secrets`: List<ZkapSecret>): ZkapAnchorResult {
1496
+ return FfiConverterTypeZkapAnchorResult.lift(
1497
+ uniffiRustCallWithError(ZkapException) { _status ->
1498
+ UniffiLib.uniffi_zkap_uniffi_bindings_fn_func_generate_anchor(
1499
+
1500
+ FfiConverterTypeZkapCircuitConfig.lower(`config`),FfiConverterSequenceTypeZkapSecret.lower(`secrets`),_status)
1501
+ }
1502
+ )
1503
+ }
1504
+
1505
+
1506
+ /**
1507
+ * Compute per-audience hashes and the combined audience-list hash.
1508
+ */
1509
+ @Throws(ZkapException::class) fun `generateAudHash`(`config`: ZkapCircuitConfig, `audList`: List<kotlin.String>): ZkapAudHashResult {
1510
+ return FfiConverterTypeZkapAudHashResult.lift(
1511
+ uniffiRustCallWithError(ZkapException) { _status ->
1512
+ UniffiLib.uniffi_zkap_uniffi_bindings_fn_func_generate_aud_hash(
1513
+
1514
+ FfiConverterTypeZkapCircuitConfig.lower(`config`),FfiConverterSequenceString.lower(`audList`),_status)
1515
+ }
1516
+ )
1517
+ }
1518
+
1519
+
1520
+ /**
1521
+ * Compute a Poseidon hash of one or more field-element strings (hex or decimal).
1522
+ *
1523
+ * Returns the result as a 0x-prefixed hex string.
1524
+ */
1525
+ @Throws(ZkapException::class) fun `generateHash`(`messages`: List<kotlin.String>): kotlin.String {
1526
+ return FfiConverterString.lift(
1527
+ uniffiRustCallWithError(ZkapException) { _status ->
1528
+ UniffiLib.uniffi_zkap_uniffi_bindings_fn_func_generate_hash(
1529
+
1530
+ FfiConverterSequenceString.lower(`messages`),_status)
1531
+ }
1532
+ )
1533
+ }
1534
+
1535
+
1536
+ /**
1537
+ * Compute the Merkle leaf hash for an issuer + RSA public-key modulus (base64-encoded).
1538
+ *
1539
+ * Returns the leaf field element as a 0x-prefixed hex string.
1540
+ */
1541
+ @Throws(ZkapException::class) fun `generateLeafHash`(`config`: ZkapCircuitConfig, `iss`: kotlin.String, `pkB64`: kotlin.String): kotlin.String {
1542
+ return FfiConverterString.lift(
1543
+ uniffiRustCallWithError(ZkapException) { _status ->
1544
+ UniffiLib.uniffi_zkap_uniffi_bindings_fn_func_generate_leaf_hash(
1545
+
1546
+ FfiConverterTypeZkapCircuitConfig.lower(`config`),FfiConverterString.lower(`iss`),FfiConverterString.lower(`pkB64`),_status)
1547
+ }
1548
+ )
1549
+ }
1550
+
1551
+
1552
+ /**
1553
+ * Generate Groth16 proofs from raw user inputs.
1554
+ */
1555
+ @Throws(ZkapException::class) fun `prove`(`config`: ZkapCircuitConfig, `request`: ZkapProofRequest): ZkapProofOutput {
1556
+ return FfiConverterTypeZkapProofOutput.lift(
1557
+ uniffiRustCallWithError(ZkapException) { _status ->
1558
+ UniffiLib.uniffi_zkap_uniffi_bindings_fn_func_prove(
1559
+
1560
+ FfiConverterTypeZkapCircuitConfig.lower(`config`),FfiConverterTypeZkapProofRequest.lower(`request`),_status)
1561
+ }
1562
+ )
1563
+ }
1564
+
1565
+
1566
+