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

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 (23) 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.swift +103 -63
  8. package/ios/ZkapZkp.xcframework/Info.plist +9 -9
  9. package/ios/ZkapZkp.xcframework/ios-arm64/Headers/zkap_uniffi_bindingsFFI.h +567 -0
  10. package/ios/ZkapZkp.xcframework/ios-arm64/{libzkap_zkp_rn.a → libzkap_uniffi_bindings.a} +0 -0
  11. package/ios/ZkapZkp.xcframework/ios-arm64_x86_64-simulator/Headers/zkap_uniffi_bindingsFFI.h +567 -0
  12. package/ios/ZkapZkp.xcframework/ios-arm64_x86_64-simulator/{libzkap_zkp_rn_sim.a → libzkap_uniffi_bindings_sim.a} +0 -0
  13. package/ios/uniffi/zkap_uniffi_bindings.swift +1174 -0
  14. package/ios/uniffi/zkap_uniffi_bindingsFFI.h +567 -0
  15. package/ios/uniffi/zkap_uniffi_bindingsFFI.modulemap +7 -0
  16. package/package.json +2 -2
  17. package/src/index.ts +10 -8
  18. package/android/libs/arm64-v8a/libzkap_zkp_rn.so +0 -0
  19. package/android/libs/armeabi-v7a/libzkap_zkp_rn.so +0 -0
  20. package/android/libs/x86_64/libzkap_zkp_rn.so +0 -0
  21. package/ios/ZkapZkp.xcframework/ios-arm64/Headers/zkap_zkp_rn.h +0 -15
  22. package/ios/ZkapZkp.xcframework/ios-arm64_x86_64-simulator/Headers/zkap_zkp_rn.h +0 -15
  23. package/ios/include/zkap_zkp_rn.h +0 -15
@@ -0,0 +1,1174 @@
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
+ // swiftlint:disable all
5
+ import Foundation
6
+
7
+ // Depending on the consumer's build setup, the low-level FFI code
8
+ // might be in a separate module, or it might be compiled inline into
9
+ // this module. This is a bit of light hackery to work with both.
10
+ #if canImport(zkap_uniffi_bindingsFFI)
11
+ import zkap_uniffi_bindingsFFI
12
+ #endif
13
+
14
+ fileprivate extension RustBuffer {
15
+ // Allocate a new buffer, copying the contents of a `UInt8` array.
16
+ init(bytes: [UInt8]) {
17
+ let rbuf = bytes.withUnsafeBufferPointer { ptr in
18
+ RustBuffer.from(ptr)
19
+ }
20
+ self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data)
21
+ }
22
+
23
+ static func empty() -> RustBuffer {
24
+ RustBuffer(capacity: 0, len:0, data: nil)
25
+ }
26
+
27
+ static func from(_ ptr: UnsafeBufferPointer<UInt8>) -> RustBuffer {
28
+ try! rustCall { ffi_zkap_uniffi_bindings_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) }
29
+ }
30
+
31
+ // Frees the buffer in place.
32
+ // The buffer must not be used after this is called.
33
+ func deallocate() {
34
+ try! rustCall { ffi_zkap_uniffi_bindings_rustbuffer_free(self, $0) }
35
+ }
36
+ }
37
+
38
+ fileprivate extension ForeignBytes {
39
+ init(bufferPointer: UnsafeBufferPointer<UInt8>) {
40
+ self.init(len: Int32(bufferPointer.count), data: bufferPointer.baseAddress)
41
+ }
42
+ }
43
+
44
+ // For every type used in the interface, we provide helper methods for conveniently
45
+ // lifting and lowering that type from C-compatible data, and for reading and writing
46
+ // values of that type in a buffer.
47
+
48
+ // Helper classes/extensions that don't change.
49
+ // Someday, this will be in a library of its own.
50
+
51
+ fileprivate extension Data {
52
+ init(rustBuffer: RustBuffer) {
53
+ self.init(
54
+ bytesNoCopy: rustBuffer.data!,
55
+ count: Int(rustBuffer.len),
56
+ deallocator: .none
57
+ )
58
+ }
59
+ }
60
+
61
+ // Define reader functionality. Normally this would be defined in a class or
62
+ // struct, but we use standalone functions instead in order to make external
63
+ // types work.
64
+ //
65
+ // With external types, one swift source file needs to be able to call the read
66
+ // method on another source file's FfiConverter, but then what visibility
67
+ // should Reader have?
68
+ // - If Reader is fileprivate, then this means the read() must also
69
+ // be fileprivate, which doesn't work with external types.
70
+ // - If Reader is internal/public, we'll get compile errors since both source
71
+ // files will try define the same type.
72
+ //
73
+ // Instead, the read() method and these helper functions input a tuple of data
74
+
75
+ fileprivate func createReader(data: Data) -> (data: Data, offset: Data.Index) {
76
+ (data: data, offset: 0)
77
+ }
78
+
79
+ // Reads an integer at the current offset, in big-endian order, and advances
80
+ // the offset on success. Throws if reading the integer would move the
81
+ // offset past the end of the buffer.
82
+ fileprivate func readInt<T: FixedWidthInteger>(_ reader: inout (data: Data, offset: Data.Index)) throws -> T {
83
+ let range = reader.offset..<reader.offset + MemoryLayout<T>.size
84
+ guard reader.data.count >= range.upperBound else {
85
+ throw UniffiInternalError.bufferOverflow
86
+ }
87
+ if T.self == UInt8.self {
88
+ let value = reader.data[reader.offset]
89
+ reader.offset += 1
90
+ return value as! T
91
+ }
92
+ var value: T = 0
93
+ let _ = withUnsafeMutableBytes(of: &value, { reader.data.copyBytes(to: $0, from: range)})
94
+ reader.offset = range.upperBound
95
+ return value.bigEndian
96
+ }
97
+
98
+ // Reads an arbitrary number of bytes, to be used to read
99
+ // raw bytes, this is useful when lifting strings
100
+ fileprivate func readBytes(_ reader: inout (data: Data, offset: Data.Index), count: Int) throws -> Array<UInt8> {
101
+ let range = reader.offset..<(reader.offset+count)
102
+ guard reader.data.count >= range.upperBound else {
103
+ throw UniffiInternalError.bufferOverflow
104
+ }
105
+ var value = [UInt8](repeating: 0, count: count)
106
+ value.withUnsafeMutableBufferPointer({ buffer in
107
+ reader.data.copyBytes(to: buffer, from: range)
108
+ })
109
+ reader.offset = range.upperBound
110
+ return value
111
+ }
112
+
113
+ // Reads a float at the current offset.
114
+ fileprivate func readFloat(_ reader: inout (data: Data, offset: Data.Index)) throws -> Float {
115
+ return Float(bitPattern: try readInt(&reader))
116
+ }
117
+
118
+ // Reads a float at the current offset.
119
+ fileprivate func readDouble(_ reader: inout (data: Data, offset: Data.Index)) throws -> Double {
120
+ return Double(bitPattern: try readInt(&reader))
121
+ }
122
+
123
+ // Indicates if the offset has reached the end of the buffer.
124
+ fileprivate func hasRemaining(_ reader: (data: Data, offset: Data.Index)) -> Bool {
125
+ return reader.offset < reader.data.count
126
+ }
127
+
128
+ // Define writer functionality. Normally this would be defined in a class or
129
+ // struct, but we use standalone functions instead in order to make external
130
+ // types work. See the above discussion on Readers for details.
131
+
132
+ fileprivate func createWriter() -> [UInt8] {
133
+ return []
134
+ }
135
+
136
+ fileprivate func writeBytes<S>(_ writer: inout [UInt8], _ byteArr: S) where S: Sequence, S.Element == UInt8 {
137
+ writer.append(contentsOf: byteArr)
138
+ }
139
+
140
+ // Writes an integer in big-endian order.
141
+ //
142
+ // Warning: make sure what you are trying to write
143
+ // is in the correct type!
144
+ fileprivate func writeInt<T: FixedWidthInteger>(_ writer: inout [UInt8], _ value: T) {
145
+ var value = value.bigEndian
146
+ withUnsafeBytes(of: &value) { writer.append(contentsOf: $0) }
147
+ }
148
+
149
+ fileprivate func writeFloat(_ writer: inout [UInt8], _ value: Float) {
150
+ writeInt(&writer, value.bitPattern)
151
+ }
152
+
153
+ fileprivate func writeDouble(_ writer: inout [UInt8], _ value: Double) {
154
+ writeInt(&writer, value.bitPattern)
155
+ }
156
+
157
+ // Protocol for types that transfer other types across the FFI. This is
158
+ // analogous to the Rust trait of the same name.
159
+ fileprivate protocol FfiConverter {
160
+ associatedtype FfiType
161
+ associatedtype SwiftType
162
+
163
+ static func lift(_ value: FfiType) throws -> SwiftType
164
+ static func lower(_ value: SwiftType) -> FfiType
165
+ static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType
166
+ static func write(_ value: SwiftType, into buf: inout [UInt8])
167
+ }
168
+
169
+ // Types conforming to `Primitive` pass themselves directly over the FFI.
170
+ fileprivate protocol FfiConverterPrimitive: FfiConverter where FfiType == SwiftType { }
171
+
172
+ extension FfiConverterPrimitive {
173
+ #if swift(>=5.8)
174
+ @_documentation(visibility: private)
175
+ #endif
176
+ public static func lift(_ value: FfiType) throws -> SwiftType {
177
+ return value
178
+ }
179
+
180
+ #if swift(>=5.8)
181
+ @_documentation(visibility: private)
182
+ #endif
183
+ public static func lower(_ value: SwiftType) -> FfiType {
184
+ return value
185
+ }
186
+ }
187
+
188
+ // Types conforming to `FfiConverterRustBuffer` lift and lower into a `RustBuffer`.
189
+ // Used for complex types where it's hard to write a custom lift/lower.
190
+ fileprivate protocol FfiConverterRustBuffer: FfiConverter where FfiType == RustBuffer {}
191
+
192
+ extension FfiConverterRustBuffer {
193
+ #if swift(>=5.8)
194
+ @_documentation(visibility: private)
195
+ #endif
196
+ public static func lift(_ buf: RustBuffer) throws -> SwiftType {
197
+ var reader = createReader(data: Data(rustBuffer: buf))
198
+ let value = try read(from: &reader)
199
+ if hasRemaining(reader) {
200
+ throw UniffiInternalError.incompleteData
201
+ }
202
+ buf.deallocate()
203
+ return value
204
+ }
205
+
206
+ #if swift(>=5.8)
207
+ @_documentation(visibility: private)
208
+ #endif
209
+ public static func lower(_ value: SwiftType) -> RustBuffer {
210
+ var writer = createWriter()
211
+ write(value, into: &writer)
212
+ return RustBuffer(bytes: writer)
213
+ }
214
+ }
215
+ // An error type for FFI errors. These errors occur at the UniFFI level, not
216
+ // the library level.
217
+ fileprivate enum UniffiInternalError: LocalizedError {
218
+ case bufferOverflow
219
+ case incompleteData
220
+ case unexpectedOptionalTag
221
+ case unexpectedEnumCase
222
+ case unexpectedNullPointer
223
+ case unexpectedRustCallStatusCode
224
+ case unexpectedRustCallError
225
+ case unexpectedStaleHandle
226
+ case rustPanic(_ message: String)
227
+
228
+ public var errorDescription: String? {
229
+ switch self {
230
+ case .bufferOverflow: return "Reading the requested value would read past the end of the buffer"
231
+ case .incompleteData: return "The buffer still has data after lifting its containing value"
232
+ case .unexpectedOptionalTag: return "Unexpected optional tag; should be 0 or 1"
233
+ case .unexpectedEnumCase: return "Raw enum value doesn't match any cases"
234
+ case .unexpectedNullPointer: return "Raw pointer value was null"
235
+ case .unexpectedRustCallStatusCode: return "Unexpected RustCallStatus code"
236
+ case .unexpectedRustCallError: return "CALL_ERROR but no errorClass specified"
237
+ case .unexpectedStaleHandle: return "The object in the handle map has been dropped already"
238
+ case let .rustPanic(message): return message
239
+ }
240
+ }
241
+ }
242
+
243
+ fileprivate extension NSLock {
244
+ func withLock<T>(f: () throws -> T) rethrows -> T {
245
+ self.lock()
246
+ defer { self.unlock() }
247
+ return try f()
248
+ }
249
+ }
250
+
251
+ fileprivate let CALL_SUCCESS: Int8 = 0
252
+ fileprivate let CALL_ERROR: Int8 = 1
253
+ fileprivate let CALL_UNEXPECTED_ERROR: Int8 = 2
254
+ fileprivate let CALL_CANCELLED: Int8 = 3
255
+
256
+ fileprivate extension RustCallStatus {
257
+ init() {
258
+ self.init(
259
+ code: CALL_SUCCESS,
260
+ errorBuf: RustBuffer.init(
261
+ capacity: 0,
262
+ len: 0,
263
+ data: nil
264
+ )
265
+ )
266
+ }
267
+ }
268
+
269
+ private func rustCall<T>(_ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
270
+ let neverThrow: ((RustBuffer) throws -> Never)? = nil
271
+ return try makeRustCall(callback, errorHandler: neverThrow)
272
+ }
273
+
274
+ private func rustCallWithError<T, E: Swift.Error>(
275
+ _ errorHandler: @escaping (RustBuffer) throws -> E,
276
+ _ callback: (UnsafeMutablePointer<RustCallStatus>) -> T) throws -> T {
277
+ try makeRustCall(callback, errorHandler: errorHandler)
278
+ }
279
+
280
+ private func makeRustCall<T, E: Swift.Error>(
281
+ _ callback: (UnsafeMutablePointer<RustCallStatus>) -> T,
282
+ errorHandler: ((RustBuffer) throws -> E)?
283
+ ) throws -> T {
284
+ uniffiEnsureZkapUniffiBindingsInitialized()
285
+ var callStatus = RustCallStatus.init()
286
+ let returnedVal = callback(&callStatus)
287
+ try uniffiCheckCallStatus(callStatus: callStatus, errorHandler: errorHandler)
288
+ return returnedVal
289
+ }
290
+
291
+ private func uniffiCheckCallStatus<E: Swift.Error>(
292
+ callStatus: RustCallStatus,
293
+ errorHandler: ((RustBuffer) throws -> E)?
294
+ ) throws {
295
+ switch callStatus.code {
296
+ case CALL_SUCCESS:
297
+ return
298
+
299
+ case CALL_ERROR:
300
+ if let errorHandler = errorHandler {
301
+ throw try errorHandler(callStatus.errorBuf)
302
+ } else {
303
+ callStatus.errorBuf.deallocate()
304
+ throw UniffiInternalError.unexpectedRustCallError
305
+ }
306
+
307
+ case CALL_UNEXPECTED_ERROR:
308
+ // When the rust code sees a panic, it tries to construct a RustBuffer
309
+ // with the message. But if that code panics, then it just sends back
310
+ // an empty buffer.
311
+ if callStatus.errorBuf.len > 0 {
312
+ throw UniffiInternalError.rustPanic(try FfiConverterString.lift(callStatus.errorBuf))
313
+ } else {
314
+ callStatus.errorBuf.deallocate()
315
+ throw UniffiInternalError.rustPanic("Rust panic")
316
+ }
317
+
318
+ case CALL_CANCELLED:
319
+ fatalError("Cancellation not supported yet")
320
+
321
+ default:
322
+ throw UniffiInternalError.unexpectedRustCallStatusCode
323
+ }
324
+ }
325
+
326
+ private func uniffiTraitInterfaceCall<T>(
327
+ callStatus: UnsafeMutablePointer<RustCallStatus>,
328
+ makeCall: () throws -> T,
329
+ writeReturn: (T) -> ()
330
+ ) {
331
+ do {
332
+ try writeReturn(makeCall())
333
+ } catch let error {
334
+ callStatus.pointee.code = CALL_UNEXPECTED_ERROR
335
+ callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error))
336
+ }
337
+ }
338
+
339
+ private func uniffiTraitInterfaceCallWithError<T, E>(
340
+ callStatus: UnsafeMutablePointer<RustCallStatus>,
341
+ makeCall: () throws -> T,
342
+ writeReturn: (T) -> (),
343
+ lowerError: (E) -> RustBuffer
344
+ ) {
345
+ do {
346
+ try writeReturn(makeCall())
347
+ } catch let error as E {
348
+ callStatus.pointee.code = CALL_ERROR
349
+ callStatus.pointee.errorBuf = lowerError(error)
350
+ } catch {
351
+ callStatus.pointee.code = CALL_UNEXPECTED_ERROR
352
+ callStatus.pointee.errorBuf = FfiConverterString.lower(String(describing: error))
353
+ }
354
+ }
355
+ // Initial value and increment amount for handles.
356
+ // These ensure that SWIFT handles always have the lowest bit set
357
+ fileprivate let UNIFFI_HANDLEMAP_INITIAL: UInt64 = 1
358
+ fileprivate let UNIFFI_HANDLEMAP_DELTA: UInt64 = 2
359
+
360
+ fileprivate final class UniffiHandleMap<T>: @unchecked Sendable {
361
+ // All mutation happens with this lock held, which is why we implement @unchecked Sendable.
362
+ private let lock = NSLock()
363
+ private var map: [UInt64: T] = [:]
364
+ private var currentHandle: UInt64 = UNIFFI_HANDLEMAP_INITIAL
365
+
366
+ func insert(obj: T) -> UInt64 {
367
+ lock.withLock {
368
+ return doInsert(obj)
369
+ }
370
+ }
371
+
372
+ // Low-level insert function, this assumes `lock` is held.
373
+ private func doInsert(_ obj: T) -> UInt64 {
374
+ let handle = currentHandle
375
+ currentHandle += UNIFFI_HANDLEMAP_DELTA
376
+ map[handle] = obj
377
+ return handle
378
+ }
379
+
380
+ func get(handle: UInt64) throws -> T {
381
+ try lock.withLock {
382
+ guard let obj = map[handle] else {
383
+ throw UniffiInternalError.unexpectedStaleHandle
384
+ }
385
+ return obj
386
+ }
387
+ }
388
+
389
+ func clone(handle: UInt64) throws -> UInt64 {
390
+ try lock.withLock {
391
+ guard let obj = map[handle] else {
392
+ throw UniffiInternalError.unexpectedStaleHandle
393
+ }
394
+ return doInsert(obj)
395
+ }
396
+ }
397
+
398
+ @discardableResult
399
+ func remove(handle: UInt64) throws -> T {
400
+ try lock.withLock {
401
+ guard let obj = map.removeValue(forKey: handle) else {
402
+ throw UniffiInternalError.unexpectedStaleHandle
403
+ }
404
+ return obj
405
+ }
406
+ }
407
+
408
+ var count: Int {
409
+ get {
410
+ map.count
411
+ }
412
+ }
413
+ }
414
+
415
+
416
+ // Public interface members begin here.
417
+
418
+
419
+ #if swift(>=5.8)
420
+ @_documentation(visibility: private)
421
+ #endif
422
+ fileprivate struct FfiConverterUInt64: FfiConverterPrimitive {
423
+ typealias FfiType = UInt64
424
+ typealias SwiftType = UInt64
425
+
426
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> UInt64 {
427
+ return try lift(readInt(&buf))
428
+ }
429
+
430
+ public static func write(_ value: SwiftType, into buf: inout [UInt8]) {
431
+ writeInt(&buf, lower(value))
432
+ }
433
+ }
434
+
435
+ #if swift(>=5.8)
436
+ @_documentation(visibility: private)
437
+ #endif
438
+ fileprivate struct FfiConverterString: FfiConverter {
439
+ typealias SwiftType = String
440
+ typealias FfiType = RustBuffer
441
+
442
+ public static func lift(_ value: RustBuffer) throws -> String {
443
+ defer {
444
+ value.deallocate()
445
+ }
446
+ if value.data == nil {
447
+ return String()
448
+ }
449
+ let bytes = UnsafeBufferPointer<UInt8>(start: value.data!, count: Int(value.len))
450
+ return String(bytes: bytes, encoding: String.Encoding.utf8)!
451
+ }
452
+
453
+ public static func lower(_ value: String) -> RustBuffer {
454
+ return value.utf8CString.withUnsafeBufferPointer { ptr in
455
+ // The swift string gives us int8_t, we want uint8_t.
456
+ ptr.withMemoryRebound(to: UInt8.self) { ptr in
457
+ // The swift string gives us a trailing null byte, we don't want it.
458
+ let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1))
459
+ return RustBuffer.from(buf)
460
+ }
461
+ }
462
+ }
463
+
464
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> String {
465
+ let len: Int32 = try readInt(&buf)
466
+ return String(bytes: try readBytes(&buf, count: Int(len)), encoding: String.Encoding.utf8)!
467
+ }
468
+
469
+ public static func write(_ value: String, into buf: inout [UInt8]) {
470
+ let len = Int32(value.utf8.count)
471
+ writeInt(&buf, len)
472
+ writeBytes(&buf, value.utf8)
473
+ }
474
+ }
475
+
476
+
477
+ public struct ZkapAnchorResult: Equatable, Hashable {
478
+ public var evaluations: [String]
479
+
480
+ // Default memberwise initializers are never public by default, so we
481
+ // declare one manually.
482
+ public init(evaluations: [String]) {
483
+ self.evaluations = evaluations
484
+ }
485
+
486
+
487
+
488
+
489
+ }
490
+
491
+ #if compiler(>=6)
492
+ extension ZkapAnchorResult: Sendable {}
493
+ #endif
494
+
495
+ #if swift(>=5.8)
496
+ @_documentation(visibility: private)
497
+ #endif
498
+ public struct FfiConverterTypeZkapAnchorResult: FfiConverterRustBuffer {
499
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ZkapAnchorResult {
500
+ return
501
+ try ZkapAnchorResult(
502
+ evaluations: FfiConverterSequenceString.read(from: &buf)
503
+ )
504
+ }
505
+
506
+ public static func write(_ value: ZkapAnchorResult, into buf: inout [UInt8]) {
507
+ FfiConverterSequenceString.write(value.evaluations, into: &buf)
508
+ }
509
+ }
510
+
511
+
512
+ #if swift(>=5.8)
513
+ @_documentation(visibility: private)
514
+ #endif
515
+ public func FfiConverterTypeZkapAnchorResult_lift(_ buf: RustBuffer) throws -> ZkapAnchorResult {
516
+ return try FfiConverterTypeZkapAnchorResult.lift(buf)
517
+ }
518
+
519
+ #if swift(>=5.8)
520
+ @_documentation(visibility: private)
521
+ #endif
522
+ public func FfiConverterTypeZkapAnchorResult_lower(_ value: ZkapAnchorResult) -> RustBuffer {
523
+ return FfiConverterTypeZkapAnchorResult.lower(value)
524
+ }
525
+
526
+
527
+ public struct ZkapAudHashResult: Equatable, Hashable {
528
+ public var audHashes: [String]
529
+ public var hAudList: String
530
+
531
+ // Default memberwise initializers are never public by default, so we
532
+ // declare one manually.
533
+ public init(audHashes: [String], hAudList: String) {
534
+ self.audHashes = audHashes
535
+ self.hAudList = hAudList
536
+ }
537
+
538
+
539
+
540
+
541
+ }
542
+
543
+ #if compiler(>=6)
544
+ extension ZkapAudHashResult: Sendable {}
545
+ #endif
546
+
547
+ #if swift(>=5.8)
548
+ @_documentation(visibility: private)
549
+ #endif
550
+ public struct FfiConverterTypeZkapAudHashResult: FfiConverterRustBuffer {
551
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ZkapAudHashResult {
552
+ return
553
+ try ZkapAudHashResult(
554
+ audHashes: FfiConverterSequenceString.read(from: &buf),
555
+ hAudList: FfiConverterString.read(from: &buf)
556
+ )
557
+ }
558
+
559
+ public static func write(_ value: ZkapAudHashResult, into buf: inout [UInt8]) {
560
+ FfiConverterSequenceString.write(value.audHashes, into: &buf)
561
+ FfiConverterString.write(value.hAudList, into: &buf)
562
+ }
563
+ }
564
+
565
+
566
+ #if swift(>=5.8)
567
+ @_documentation(visibility: private)
568
+ #endif
569
+ public func FfiConverterTypeZkapAudHashResult_lift(_ buf: RustBuffer) throws -> ZkapAudHashResult {
570
+ return try FfiConverterTypeZkapAudHashResult.lift(buf)
571
+ }
572
+
573
+ #if swift(>=5.8)
574
+ @_documentation(visibility: private)
575
+ #endif
576
+ public func FfiConverterTypeZkapAudHashResult_lower(_ value: ZkapAudHashResult) -> RustBuffer {
577
+ return FfiConverterTypeZkapAudHashResult.lower(value)
578
+ }
579
+
580
+
581
+ public struct ZkapCircuitConfig: Equatable, Hashable {
582
+ public var maxJwtB64Len: UInt64
583
+ public var maxPayloadB64Len: UInt64
584
+ public var maxAudLen: UInt64
585
+ public var maxExpLen: UInt64
586
+ public var maxIssLen: UInt64
587
+ public var maxNonceLen: UInt64
588
+ public var maxSubLen: UInt64
589
+ public var n: UInt64
590
+ public var k: UInt64
591
+ public var treeHeight: UInt64
592
+ public var numAudienceLimit: UInt64
593
+ public var claims: [String]
594
+ public var forbiddenString: String
595
+
596
+ // Default memberwise initializers are never public by default, so we
597
+ // declare one manually.
598
+ public init(maxJwtB64Len: UInt64, maxPayloadB64Len: UInt64, maxAudLen: UInt64, maxExpLen: UInt64, maxIssLen: UInt64, maxNonceLen: UInt64, maxSubLen: UInt64, n: UInt64, k: UInt64, treeHeight: UInt64, numAudienceLimit: UInt64, claims: [String], forbiddenString: String) {
599
+ self.maxJwtB64Len = maxJwtB64Len
600
+ self.maxPayloadB64Len = maxPayloadB64Len
601
+ self.maxAudLen = maxAudLen
602
+ self.maxExpLen = maxExpLen
603
+ self.maxIssLen = maxIssLen
604
+ self.maxNonceLen = maxNonceLen
605
+ self.maxSubLen = maxSubLen
606
+ self.n = n
607
+ self.k = k
608
+ self.treeHeight = treeHeight
609
+ self.numAudienceLimit = numAudienceLimit
610
+ self.claims = claims
611
+ self.forbiddenString = forbiddenString
612
+ }
613
+
614
+
615
+
616
+
617
+ }
618
+
619
+ #if compiler(>=6)
620
+ extension ZkapCircuitConfig: Sendable {}
621
+ #endif
622
+
623
+ #if swift(>=5.8)
624
+ @_documentation(visibility: private)
625
+ #endif
626
+ public struct FfiConverterTypeZkapCircuitConfig: FfiConverterRustBuffer {
627
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ZkapCircuitConfig {
628
+ return
629
+ try ZkapCircuitConfig(
630
+ maxJwtB64Len: FfiConverterUInt64.read(from: &buf),
631
+ maxPayloadB64Len: FfiConverterUInt64.read(from: &buf),
632
+ maxAudLen: FfiConverterUInt64.read(from: &buf),
633
+ maxExpLen: FfiConverterUInt64.read(from: &buf),
634
+ maxIssLen: FfiConverterUInt64.read(from: &buf),
635
+ maxNonceLen: FfiConverterUInt64.read(from: &buf),
636
+ maxSubLen: FfiConverterUInt64.read(from: &buf),
637
+ n: FfiConverterUInt64.read(from: &buf),
638
+ k: FfiConverterUInt64.read(from: &buf),
639
+ treeHeight: FfiConverterUInt64.read(from: &buf),
640
+ numAudienceLimit: FfiConverterUInt64.read(from: &buf),
641
+ claims: FfiConverterSequenceString.read(from: &buf),
642
+ forbiddenString: FfiConverterString.read(from: &buf)
643
+ )
644
+ }
645
+
646
+ public static func write(_ value: ZkapCircuitConfig, into buf: inout [UInt8]) {
647
+ FfiConverterUInt64.write(value.maxJwtB64Len, into: &buf)
648
+ FfiConverterUInt64.write(value.maxPayloadB64Len, into: &buf)
649
+ FfiConverterUInt64.write(value.maxAudLen, into: &buf)
650
+ FfiConverterUInt64.write(value.maxExpLen, into: &buf)
651
+ FfiConverterUInt64.write(value.maxIssLen, into: &buf)
652
+ FfiConverterUInt64.write(value.maxNonceLen, into: &buf)
653
+ FfiConverterUInt64.write(value.maxSubLen, into: &buf)
654
+ FfiConverterUInt64.write(value.n, into: &buf)
655
+ FfiConverterUInt64.write(value.k, into: &buf)
656
+ FfiConverterUInt64.write(value.treeHeight, into: &buf)
657
+ FfiConverterUInt64.write(value.numAudienceLimit, into: &buf)
658
+ FfiConverterSequenceString.write(value.claims, into: &buf)
659
+ FfiConverterString.write(value.forbiddenString, into: &buf)
660
+ }
661
+ }
662
+
663
+
664
+ #if swift(>=5.8)
665
+ @_documentation(visibility: private)
666
+ #endif
667
+ public func FfiConverterTypeZkapCircuitConfig_lift(_ buf: RustBuffer) throws -> ZkapCircuitConfig {
668
+ return try FfiConverterTypeZkapCircuitConfig.lift(buf)
669
+ }
670
+
671
+ #if swift(>=5.8)
672
+ @_documentation(visibility: private)
673
+ #endif
674
+ public func FfiConverterTypeZkapCircuitConfig_lower(_ value: ZkapCircuitConfig) -> RustBuffer {
675
+ return FfiConverterTypeZkapCircuitConfig.lower(value)
676
+ }
677
+
678
+
679
+ public struct ZkapProofOutput: Equatable, Hashable {
680
+ /**
681
+ * Solidity-compatible proof components per credential: [ax, ay, bx_c1, bx_c0, by_c1, by_c0, cx, cy]
682
+ */
683
+ public var proofs: [[String]]
684
+ public var sharedInputs: [String]
685
+ public var partialRhsList: [String]
686
+ public var jwtExpList: [String]
687
+
688
+ // Default memberwise initializers are never public by default, so we
689
+ // declare one manually.
690
+ public init(
691
+ /**
692
+ * Solidity-compatible proof components per credential: [ax, ay, bx_c1, bx_c0, by_c1, by_c0, cx, cy]
693
+ */proofs: [[String]], sharedInputs: [String], partialRhsList: [String], jwtExpList: [String]) {
694
+ self.proofs = proofs
695
+ self.sharedInputs = sharedInputs
696
+ self.partialRhsList = partialRhsList
697
+ self.jwtExpList = jwtExpList
698
+ }
699
+
700
+
701
+
702
+
703
+ }
704
+
705
+ #if compiler(>=6)
706
+ extension ZkapProofOutput: Sendable {}
707
+ #endif
708
+
709
+ #if swift(>=5.8)
710
+ @_documentation(visibility: private)
711
+ #endif
712
+ public struct FfiConverterTypeZkapProofOutput: FfiConverterRustBuffer {
713
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ZkapProofOutput {
714
+ return
715
+ try ZkapProofOutput(
716
+ proofs: FfiConverterSequenceSequenceString.read(from: &buf),
717
+ sharedInputs: FfiConverterSequenceString.read(from: &buf),
718
+ partialRhsList: FfiConverterSequenceString.read(from: &buf),
719
+ jwtExpList: FfiConverterSequenceString.read(from: &buf)
720
+ )
721
+ }
722
+
723
+ public static func write(_ value: ZkapProofOutput, into buf: inout [UInt8]) {
724
+ FfiConverterSequenceSequenceString.write(value.proofs, into: &buf)
725
+ FfiConverterSequenceString.write(value.sharedInputs, into: &buf)
726
+ FfiConverterSequenceString.write(value.partialRhsList, into: &buf)
727
+ FfiConverterSequenceString.write(value.jwtExpList, into: &buf)
728
+ }
729
+ }
730
+
731
+
732
+ #if swift(>=5.8)
733
+ @_documentation(visibility: private)
734
+ #endif
735
+ public func FfiConverterTypeZkapProofOutput_lift(_ buf: RustBuffer) throws -> ZkapProofOutput {
736
+ return try FfiConverterTypeZkapProofOutput.lift(buf)
737
+ }
738
+
739
+ #if swift(>=5.8)
740
+ @_documentation(visibility: private)
741
+ #endif
742
+ public func FfiConverterTypeZkapProofOutput_lower(_ value: ZkapProofOutput) -> RustBuffer {
743
+ return FfiConverterTypeZkapProofOutput.lower(value)
744
+ }
745
+
746
+
747
+ public struct ZkapProofRequest: Equatable, Hashable {
748
+ public var pkPath: String
749
+ public var jwts: [String]
750
+ public var pkOps: [String]
751
+ public var merklePaths: [[String]]
752
+ public var leafIndices: [UInt64]
753
+ public var root: String
754
+ public var anchorEvals: [String]
755
+ public var hanchor: String
756
+ public var hSignUserOp: String
757
+ public var random: String
758
+ public var audHashList: [String]
759
+
760
+ // Default memberwise initializers are never public by default, so we
761
+ // declare one manually.
762
+ public init(pkPath: String, jwts: [String], pkOps: [String], merklePaths: [[String]], leafIndices: [UInt64], root: String, anchorEvals: [String], hanchor: String, hSignUserOp: String, random: String, audHashList: [String]) {
763
+ self.pkPath = pkPath
764
+ self.jwts = jwts
765
+ self.pkOps = pkOps
766
+ self.merklePaths = merklePaths
767
+ self.leafIndices = leafIndices
768
+ self.root = root
769
+ self.anchorEvals = anchorEvals
770
+ self.hanchor = hanchor
771
+ self.hSignUserOp = hSignUserOp
772
+ self.random = random
773
+ self.audHashList = audHashList
774
+ }
775
+
776
+
777
+
778
+
779
+ }
780
+
781
+ #if compiler(>=6)
782
+ extension ZkapProofRequest: Sendable {}
783
+ #endif
784
+
785
+ #if swift(>=5.8)
786
+ @_documentation(visibility: private)
787
+ #endif
788
+ public struct FfiConverterTypeZkapProofRequest: FfiConverterRustBuffer {
789
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ZkapProofRequest {
790
+ return
791
+ try ZkapProofRequest(
792
+ pkPath: FfiConverterString.read(from: &buf),
793
+ jwts: FfiConverterSequenceString.read(from: &buf),
794
+ pkOps: FfiConverterSequenceString.read(from: &buf),
795
+ merklePaths: FfiConverterSequenceSequenceString.read(from: &buf),
796
+ leafIndices: FfiConverterSequenceUInt64.read(from: &buf),
797
+ root: FfiConverterString.read(from: &buf),
798
+ anchorEvals: FfiConverterSequenceString.read(from: &buf),
799
+ hanchor: FfiConverterString.read(from: &buf),
800
+ hSignUserOp: FfiConverterString.read(from: &buf),
801
+ random: FfiConverterString.read(from: &buf),
802
+ audHashList: FfiConverterSequenceString.read(from: &buf)
803
+ )
804
+ }
805
+
806
+ public static func write(_ value: ZkapProofRequest, into buf: inout [UInt8]) {
807
+ FfiConverterString.write(value.pkPath, into: &buf)
808
+ FfiConverterSequenceString.write(value.jwts, into: &buf)
809
+ FfiConverterSequenceString.write(value.pkOps, into: &buf)
810
+ FfiConverterSequenceSequenceString.write(value.merklePaths, into: &buf)
811
+ FfiConverterSequenceUInt64.write(value.leafIndices, into: &buf)
812
+ FfiConverterString.write(value.root, into: &buf)
813
+ FfiConverterSequenceString.write(value.anchorEvals, into: &buf)
814
+ FfiConverterString.write(value.hanchor, into: &buf)
815
+ FfiConverterString.write(value.hSignUserOp, into: &buf)
816
+ FfiConverterString.write(value.random, into: &buf)
817
+ FfiConverterSequenceString.write(value.audHashList, into: &buf)
818
+ }
819
+ }
820
+
821
+
822
+ #if swift(>=5.8)
823
+ @_documentation(visibility: private)
824
+ #endif
825
+ public func FfiConverterTypeZkapProofRequest_lift(_ buf: RustBuffer) throws -> ZkapProofRequest {
826
+ return try FfiConverterTypeZkapProofRequest.lift(buf)
827
+ }
828
+
829
+ #if swift(>=5.8)
830
+ @_documentation(visibility: private)
831
+ #endif
832
+ public func FfiConverterTypeZkapProofRequest_lower(_ value: ZkapProofRequest) -> RustBuffer {
833
+ return FfiConverterTypeZkapProofRequest.lower(value)
834
+ }
835
+
836
+
837
+ public struct ZkapSecret: Equatable, Hashable {
838
+ public var sub: String
839
+ public var iss: String
840
+ public var aud: String
841
+
842
+ // Default memberwise initializers are never public by default, so we
843
+ // declare one manually.
844
+ public init(sub: String, iss: String, aud: String) {
845
+ self.sub = sub
846
+ self.iss = iss
847
+ self.aud = aud
848
+ }
849
+
850
+
851
+
852
+
853
+ }
854
+
855
+ #if compiler(>=6)
856
+ extension ZkapSecret: Sendable {}
857
+ #endif
858
+
859
+ #if swift(>=5.8)
860
+ @_documentation(visibility: private)
861
+ #endif
862
+ public struct FfiConverterTypeZkapSecret: FfiConverterRustBuffer {
863
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ZkapSecret {
864
+ return
865
+ try ZkapSecret(
866
+ sub: FfiConverterString.read(from: &buf),
867
+ iss: FfiConverterString.read(from: &buf),
868
+ aud: FfiConverterString.read(from: &buf)
869
+ )
870
+ }
871
+
872
+ public static func write(_ value: ZkapSecret, into buf: inout [UInt8]) {
873
+ FfiConverterString.write(value.sub, into: &buf)
874
+ FfiConverterString.write(value.iss, into: &buf)
875
+ FfiConverterString.write(value.aud, into: &buf)
876
+ }
877
+ }
878
+
879
+
880
+ #if swift(>=5.8)
881
+ @_documentation(visibility: private)
882
+ #endif
883
+ public func FfiConverterTypeZkapSecret_lift(_ buf: RustBuffer) throws -> ZkapSecret {
884
+ return try FfiConverterTypeZkapSecret.lift(buf)
885
+ }
886
+
887
+ #if swift(>=5.8)
888
+ @_documentation(visibility: private)
889
+ #endif
890
+ public func FfiConverterTypeZkapSecret_lower(_ value: ZkapSecret) -> RustBuffer {
891
+ return FfiConverterTypeZkapSecret.lower(value)
892
+ }
893
+
894
+
895
+ public enum ZkapError: Swift.Error, Equatable, Hashable, Foundation.LocalizedError {
896
+
897
+
898
+
899
+ case ApplicationError(message: String
900
+ )
901
+
902
+
903
+
904
+
905
+
906
+
907
+ public var errorDescription: String? {
908
+ String(reflecting: self)
909
+ }
910
+
911
+ }
912
+
913
+ #if compiler(>=6)
914
+ extension ZkapError: Sendable {}
915
+ #endif
916
+
917
+ #if swift(>=5.8)
918
+ @_documentation(visibility: private)
919
+ #endif
920
+ public struct FfiConverterTypeZkapError: FfiConverterRustBuffer {
921
+ typealias SwiftType = ZkapError
922
+
923
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> ZkapError {
924
+ let variant: Int32 = try readInt(&buf)
925
+ switch variant {
926
+
927
+
928
+
929
+
930
+ case 1: return .ApplicationError(
931
+ message: try FfiConverterString.read(from: &buf)
932
+ )
933
+
934
+ default: throw UniffiInternalError.unexpectedEnumCase
935
+ }
936
+ }
937
+
938
+ public static func write(_ value: ZkapError, into buf: inout [UInt8]) {
939
+ switch value {
940
+
941
+
942
+
943
+
944
+
945
+ case let .ApplicationError(message):
946
+ writeInt(&buf, Int32(1))
947
+ FfiConverterString.write(message, into: &buf)
948
+
949
+ }
950
+ }
951
+ }
952
+
953
+
954
+ #if swift(>=5.8)
955
+ @_documentation(visibility: private)
956
+ #endif
957
+ public func FfiConverterTypeZkapError_lift(_ buf: RustBuffer) throws -> ZkapError {
958
+ return try FfiConverterTypeZkapError.lift(buf)
959
+ }
960
+
961
+ #if swift(>=5.8)
962
+ @_documentation(visibility: private)
963
+ #endif
964
+ public func FfiConverterTypeZkapError_lower(_ value: ZkapError) -> RustBuffer {
965
+ return FfiConverterTypeZkapError.lower(value)
966
+ }
967
+
968
+ #if swift(>=5.8)
969
+ @_documentation(visibility: private)
970
+ #endif
971
+ fileprivate struct FfiConverterSequenceUInt64: FfiConverterRustBuffer {
972
+ typealias SwiftType = [UInt64]
973
+
974
+ public static func write(_ value: [UInt64], into buf: inout [UInt8]) {
975
+ let len = Int32(value.count)
976
+ writeInt(&buf, len)
977
+ for item in value {
978
+ FfiConverterUInt64.write(item, into: &buf)
979
+ }
980
+ }
981
+
982
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [UInt64] {
983
+ let len: Int32 = try readInt(&buf)
984
+ var seq = [UInt64]()
985
+ seq.reserveCapacity(Int(len))
986
+ for _ in 0 ..< len {
987
+ seq.append(try FfiConverterUInt64.read(from: &buf))
988
+ }
989
+ return seq
990
+ }
991
+ }
992
+
993
+ #if swift(>=5.8)
994
+ @_documentation(visibility: private)
995
+ #endif
996
+ fileprivate struct FfiConverterSequenceString: FfiConverterRustBuffer {
997
+ typealias SwiftType = [String]
998
+
999
+ public static func write(_ value: [String], into buf: inout [UInt8]) {
1000
+ let len = Int32(value.count)
1001
+ writeInt(&buf, len)
1002
+ for item in value {
1003
+ FfiConverterString.write(item, into: &buf)
1004
+ }
1005
+ }
1006
+
1007
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [String] {
1008
+ let len: Int32 = try readInt(&buf)
1009
+ var seq = [String]()
1010
+ seq.reserveCapacity(Int(len))
1011
+ for _ in 0 ..< len {
1012
+ seq.append(try FfiConverterString.read(from: &buf))
1013
+ }
1014
+ return seq
1015
+ }
1016
+ }
1017
+
1018
+ #if swift(>=5.8)
1019
+ @_documentation(visibility: private)
1020
+ #endif
1021
+ fileprivate struct FfiConverterSequenceTypeZkapSecret: FfiConverterRustBuffer {
1022
+ typealias SwiftType = [ZkapSecret]
1023
+
1024
+ public static func write(_ value: [ZkapSecret], into buf: inout [UInt8]) {
1025
+ let len = Int32(value.count)
1026
+ writeInt(&buf, len)
1027
+ for item in value {
1028
+ FfiConverterTypeZkapSecret.write(item, into: &buf)
1029
+ }
1030
+ }
1031
+
1032
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [ZkapSecret] {
1033
+ let len: Int32 = try readInt(&buf)
1034
+ var seq = [ZkapSecret]()
1035
+ seq.reserveCapacity(Int(len))
1036
+ for _ in 0 ..< len {
1037
+ seq.append(try FfiConverterTypeZkapSecret.read(from: &buf))
1038
+ }
1039
+ return seq
1040
+ }
1041
+ }
1042
+
1043
+ #if swift(>=5.8)
1044
+ @_documentation(visibility: private)
1045
+ #endif
1046
+ fileprivate struct FfiConverterSequenceSequenceString: FfiConverterRustBuffer {
1047
+ typealias SwiftType = [[String]]
1048
+
1049
+ public static func write(_ value: [[String]], into buf: inout [UInt8]) {
1050
+ let len = Int32(value.count)
1051
+ writeInt(&buf, len)
1052
+ for item in value {
1053
+ FfiConverterSequenceString.write(item, into: &buf)
1054
+ }
1055
+ }
1056
+
1057
+ public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> [[String]] {
1058
+ let len: Int32 = try readInt(&buf)
1059
+ var seq = [[String]]()
1060
+ seq.reserveCapacity(Int(len))
1061
+ for _ in 0 ..< len {
1062
+ seq.append(try FfiConverterSequenceString.read(from: &buf))
1063
+ }
1064
+ return seq
1065
+ }
1066
+ }
1067
+ /**
1068
+ * Generate a Poseidon threshold anchor from a list of JWT credential secrets.
1069
+ */
1070
+ public func generateAnchor(config: ZkapCircuitConfig, secrets: [ZkapSecret])throws -> ZkapAnchorResult {
1071
+ return try FfiConverterTypeZkapAnchorResult_lift(try rustCallWithError(FfiConverterTypeZkapError_lift) {
1072
+ uniffi_zkap_uniffi_bindings_fn_func_generate_anchor(
1073
+ FfiConverterTypeZkapCircuitConfig_lower(config),
1074
+ FfiConverterSequenceTypeZkapSecret.lower(secrets),$0
1075
+ )
1076
+ })
1077
+ }
1078
+ /**
1079
+ * Compute per-audience hashes and the combined audience-list hash.
1080
+ */
1081
+ public func generateAudHash(config: ZkapCircuitConfig, audList: [String])throws -> ZkapAudHashResult {
1082
+ return try FfiConverterTypeZkapAudHashResult_lift(try rustCallWithError(FfiConverterTypeZkapError_lift) {
1083
+ uniffi_zkap_uniffi_bindings_fn_func_generate_aud_hash(
1084
+ FfiConverterTypeZkapCircuitConfig_lower(config),
1085
+ FfiConverterSequenceString.lower(audList),$0
1086
+ )
1087
+ })
1088
+ }
1089
+ /**
1090
+ * Compute a Poseidon hash of one or more field-element strings (hex or decimal).
1091
+ *
1092
+ * Returns the result as a 0x-prefixed hex string.
1093
+ */
1094
+ public func generateHash(messages: [String])throws -> String {
1095
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeZkapError_lift) {
1096
+ uniffi_zkap_uniffi_bindings_fn_func_generate_hash(
1097
+ FfiConverterSequenceString.lower(messages),$0
1098
+ )
1099
+ })
1100
+ }
1101
+ /**
1102
+ * Compute the Merkle leaf hash for an issuer + RSA public-key modulus (base64-encoded).
1103
+ *
1104
+ * Returns the leaf field element as a 0x-prefixed hex string.
1105
+ */
1106
+ public func generateLeafHash(config: ZkapCircuitConfig, iss: String, pkB64: String)throws -> String {
1107
+ return try FfiConverterString.lift(try rustCallWithError(FfiConverterTypeZkapError_lift) {
1108
+ uniffi_zkap_uniffi_bindings_fn_func_generate_leaf_hash(
1109
+ FfiConverterTypeZkapCircuitConfig_lower(config),
1110
+ FfiConverterString.lower(iss),
1111
+ FfiConverterString.lower(pkB64),$0
1112
+ )
1113
+ })
1114
+ }
1115
+ /**
1116
+ * Generate Groth16 proofs from raw user inputs.
1117
+ */
1118
+ public func prove(config: ZkapCircuitConfig, request: ZkapProofRequest)throws -> ZkapProofOutput {
1119
+ return try FfiConverterTypeZkapProofOutput_lift(try rustCallWithError(FfiConverterTypeZkapError_lift) {
1120
+ uniffi_zkap_uniffi_bindings_fn_func_prove(
1121
+ FfiConverterTypeZkapCircuitConfig_lower(config),
1122
+ FfiConverterTypeZkapProofRequest_lower(request),$0
1123
+ )
1124
+ })
1125
+ }
1126
+
1127
+ private enum InitializationResult {
1128
+ case ok
1129
+ case contractVersionMismatch
1130
+ case apiChecksumMismatch
1131
+ }
1132
+ // Use a global variable to perform the versioning checks. Swift ensures that
1133
+ // the code inside is only computed once.
1134
+ private let initializationResult: InitializationResult = {
1135
+ // Get the bindings contract version from our ComponentInterface
1136
+ let bindings_contract_version = 30
1137
+ // Get the scaffolding contract version by calling the into the dylib
1138
+ let scaffolding_contract_version = ffi_zkap_uniffi_bindings_uniffi_contract_version()
1139
+ if bindings_contract_version != scaffolding_contract_version {
1140
+ return InitializationResult.contractVersionMismatch
1141
+ }
1142
+ if (uniffi_zkap_uniffi_bindings_checksum_func_generate_anchor() != 10088) {
1143
+ return InitializationResult.apiChecksumMismatch
1144
+ }
1145
+ if (uniffi_zkap_uniffi_bindings_checksum_func_generate_aud_hash() != 42467) {
1146
+ return InitializationResult.apiChecksumMismatch
1147
+ }
1148
+ if (uniffi_zkap_uniffi_bindings_checksum_func_generate_hash() != 6188) {
1149
+ return InitializationResult.apiChecksumMismatch
1150
+ }
1151
+ if (uniffi_zkap_uniffi_bindings_checksum_func_generate_leaf_hash() != 28430) {
1152
+ return InitializationResult.apiChecksumMismatch
1153
+ }
1154
+ if (uniffi_zkap_uniffi_bindings_checksum_func_prove() != 26090) {
1155
+ return InitializationResult.apiChecksumMismatch
1156
+ }
1157
+
1158
+ return InitializationResult.ok
1159
+ }()
1160
+
1161
+ // Make the ensure init function public so that other modules which have external type references to
1162
+ // our types can call it.
1163
+ public func uniffiEnsureZkapUniffiBindingsInitialized() {
1164
+ switch initializationResult {
1165
+ case .ok:
1166
+ break
1167
+ case .contractVersionMismatch:
1168
+ fatalError("UniFFI contract version mismatch: try cleaning and rebuilding your project")
1169
+ case .apiChecksumMismatch:
1170
+ fatalError("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
1171
+ }
1172
+ }
1173
+
1174
+ // swiftlint:enable all