@baerae/zkap-zkp-react-native 0.1.4 → 0.1.6

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 (35) hide show
  1. package/README.md +24 -1
  2. package/ZkapReactNative.podspec +42 -0
  3. package/android/CMakeLists.txt +81 -0
  4. package/android/build.gradle +111 -14
  5. package/android/cpp-adapter.cpp +43 -0
  6. package/android/libs/arm64-v8a/libzkap_uniffi_bindings.so +0 -0
  7. package/android/libs/x86_64/libzkap_uniffi_bindings.so +0 -0
  8. package/android/proguard-rules.pro +2 -0
  9. package/android/src/main/AndroidManifest.xml +5 -0
  10. package/android/src/main/java/com/baerae/zkapreactnative/ZkapReactNativeModule.kt +51 -0
  11. package/android/src/main/java/com/baerae/zkapreactnative/ZkapReactNativePackage.kt +34 -0
  12. package/cpp/baerae-zkap-react-native.cpp +17 -0
  13. package/cpp/baerae-zkap-react-native.h +15 -0
  14. package/cpp/generated/zkap_uniffi_bindings.cpp +2154 -0
  15. package/cpp/generated/zkap_uniffi_bindings.hpp +66 -0
  16. package/ios/ZkapReactNative.h +16 -0
  17. package/ios/ZkapReactNative.mm +412 -0
  18. package/ios/ZkapZkp.xcframework/Info.plist +5 -5
  19. package/ios/ZkapZkp.xcframework/ios-arm64/libzkap_uniffi_bindings.a +0 -0
  20. package/ios/ZkapZkp.xcframework/ios-arm64_x86_64-simulator/libzkap_uniffi_bindings.a +0 -0
  21. package/package.json +37 -14
  22. package/src/NativeZkapReactNative.ts +11 -0
  23. package/src/generated/zkap_uniffi_bindings-ffi.ts +150 -0
  24. package/src/generated/zkap_uniffi_bindings.ts +1015 -0
  25. package/src/index.ts +250 -46
  26. package/ubrn.config.yaml +13 -0
  27. package/android/libs/armeabi-v7a/libzkap_uniffi_bindings.so +0 -0
  28. package/android/src/main/java/expo/modules/zkap/ZkapSdkModule.kt +0 -153
  29. package/android/src/main/java/uniffi/zkap_uniffi_bindings/zkap_uniffi_bindings.kt +0 -1566
  30. package/expo-module.config.json +0 -9
  31. package/ios/ZkapSdkModule.podspec +0 -35
  32. package/ios/ZkapSdkModule.swift +0 -147
  33. package/ios/uniffi/zkap_uniffi_bindings.swift +0 -1174
  34. package/ios/uniffi/zkap_uniffi_bindingsFFI.h +0 -567
  35. package/ios/uniffi/zkap_uniffi_bindingsFFI.modulemap +0 -7
@@ -0,0 +1,1015 @@
1
+ // This file was autogenerated by some hot garbage in the `uniffi-bindgen-react-native` crate.
2
+ // Trust me, you don't want to mess with it!
3
+
4
+ /* tslint:disable */
5
+ /* eslint-disable */
6
+ // @ts-nocheck
7
+ import nativeModule, {
8
+ type UniffiRustFutureContinuationCallback,
9
+ type UniffiForeignFutureDroppedCallback,
10
+ type UniffiForeignFutureDroppedCallbackStruct,
11
+ type UniffiForeignFutureResultU8,
12
+ type UniffiForeignFutureCompleteU8,
13
+ type UniffiForeignFutureResultI8,
14
+ type UniffiForeignFutureCompleteI8,
15
+ type UniffiForeignFutureResultU16,
16
+ type UniffiForeignFutureCompleteU16,
17
+ type UniffiForeignFutureResultI16,
18
+ type UniffiForeignFutureCompleteI16,
19
+ type UniffiForeignFutureResultU32,
20
+ type UniffiForeignFutureCompleteU32,
21
+ type UniffiForeignFutureResultI32,
22
+ type UniffiForeignFutureCompleteI32,
23
+ type UniffiForeignFutureResultU64,
24
+ type UniffiForeignFutureCompleteU64,
25
+ type UniffiForeignFutureResultI64,
26
+ type UniffiForeignFutureCompleteI64,
27
+ type UniffiForeignFutureResultF32,
28
+ type UniffiForeignFutureCompleteF32,
29
+ type UniffiForeignFutureResultF64,
30
+ type UniffiForeignFutureCompleteF64,
31
+ type UniffiForeignFutureResultRustBuffer,
32
+ type UniffiForeignFutureCompleteRustBuffer,
33
+ type UniffiForeignFutureResultVoid,
34
+ type UniffiForeignFutureCompleteVoid,
35
+ } from "./zkap_uniffi_bindings-ffi";
36
+ import {
37
+ type UniffiByteArray,
38
+ AbstractFfiConverterByteArray,
39
+ FfiConverterArray,
40
+ FfiConverterInt32,
41
+ FfiConverterUInt64,
42
+ RustBuffer,
43
+ UniffiError,
44
+ UniffiInternalError,
45
+ UniffiRustCaller,
46
+ uniffiCreateFfiConverterString,
47
+ uniffiCreateRecord,
48
+ uniffiTypeNameSymbol,
49
+ variantOrdinalSymbol } from "uniffi-bindgen-react-native";
50
+
51
+ // Get converters from the other files, if any.
52
+ const uniffiCaller = new UniffiRustCaller(() => ({ code: 0 }));
53
+
54
+ const uniffiIsDebug =
55
+ // @ts-ignore -- The process global might not be defined
56
+ typeof process !== "object" ||
57
+ // @ts-ignore -- The process global might not be defined
58
+ process?.env?.NODE_ENV !== "production" ||
59
+ false;
60
+ // Public interface members begin here.
61
+
62
+ /**
63
+ * Generate a Poseidon threshold anchor from a list of JWT credential secrets.
64
+ */
65
+ export function generateAnchor(config: ZkapCircuitConfig, secrets: Array<ZkapSecret>): ZkapAnchorResult /*throws*/ {
66
+ return FfiConverterTypeZkapAnchorResult.lift(
67
+ uniffiCaller.rustCallWithError(
68
+ /*liftError:*/ FfiConverterTypeZkapError.lift.bind(FfiConverterTypeZkapError),
69
+ /*caller:*/ (callStatus) => {
70
+ return nativeModule().ubrn_uniffi_zkap_uniffi_bindings_fn_func_generate_anchor(
71
+ FfiConverterTypeZkapCircuitConfig.lower(config),
72
+ FfiConverterArrayTypeZkapSecret.lower(secrets),
73
+ callStatus);
74
+ },
75
+ /*liftString:*/ FfiConverterString.lift,
76
+ ));
77
+ }
78
+ /**
79
+ * Compute per-audience hashes and the combined audience-list hash.
80
+ */
81
+ export function generateAudHash(config: ZkapCircuitConfig, audList: Array<string>): ZkapAudHashResult /*throws*/ {
82
+ return FfiConverterTypeZkapAudHashResult.lift(
83
+ uniffiCaller.rustCallWithError(
84
+ /*liftError:*/ FfiConverterTypeZkapError.lift.bind(FfiConverterTypeZkapError),
85
+ /*caller:*/ (callStatus) => {
86
+ return nativeModule().ubrn_uniffi_zkap_uniffi_bindings_fn_func_generate_aud_hash(
87
+ FfiConverterTypeZkapCircuitConfig.lower(config),
88
+ FfiConverterArrayString.lower(audList),
89
+ callStatus);
90
+ },
91
+ /*liftString:*/ FfiConverterString.lift,
92
+ ));
93
+ }
94
+ /**
95
+ * Compute a Poseidon hash of one or more field-element strings (hex or decimal).
96
+ *
97
+ * Returns the result as a 0x-prefixed hex string.
98
+ */
99
+ export function generateHash(messages: Array<string>): string /*throws*/ {
100
+ return FfiConverterString.lift(
101
+ uniffiCaller.rustCallWithError(
102
+ /*liftError:*/ FfiConverterTypeZkapError.lift.bind(FfiConverterTypeZkapError),
103
+ /*caller:*/ (callStatus) => {
104
+ return nativeModule().ubrn_uniffi_zkap_uniffi_bindings_fn_func_generate_hash(
105
+ FfiConverterArrayString.lower(messages),
106
+ callStatus);
107
+ },
108
+ /*liftString:*/ FfiConverterString.lift,
109
+ ));
110
+ }
111
+ /**
112
+ * Compute the Merkle leaf hash for an issuer + RSA public-key modulus (base64-encoded).
113
+ *
114
+ * Returns the leaf field element as a 0x-prefixed hex string.
115
+ */
116
+ export function generateLeafHash(config: ZkapCircuitConfig, iss: string, pkB64: string): string /*throws*/ {
117
+ return FfiConverterString.lift(
118
+ uniffiCaller.rustCallWithError(
119
+ /*liftError:*/ FfiConverterTypeZkapError.lift.bind(FfiConverterTypeZkapError),
120
+ /*caller:*/ (callStatus) => {
121
+ return nativeModule().ubrn_uniffi_zkap_uniffi_bindings_fn_func_generate_leaf_hash(
122
+ FfiConverterTypeZkapCircuitConfig.lower(config),
123
+ FfiConverterString.lower(iss),
124
+ FfiConverterString.lower(pkB64),
125
+ callStatus);
126
+ },
127
+ /*liftString:*/ FfiConverterString.lift,
128
+ ));
129
+ }
130
+ /**
131
+ * Prepare the manifest-verified inputs required by the iOS WKWebView
132
+ * witness runner. This does not synthesize a witness or generate a proof.
133
+ */
134
+ export function prepareWitnessInputs(config: ZkapCircuitConfig, request: ZkapProofRequest): ZkapPreparedWitnessInputs /*throws*/ {
135
+ return FfiConverterTypeZkapPreparedWitnessInputs.lift(
136
+ uniffiCaller.rustCallWithError(
137
+ /*liftError:*/ FfiConverterTypeZkapError.lift.bind(FfiConverterTypeZkapError),
138
+ /*caller:*/ (callStatus) => {
139
+ return nativeModule().ubrn_uniffi_zkap_uniffi_bindings_fn_func_prepare_witness_inputs(
140
+ FfiConverterTypeZkapCircuitConfig.lower(config),
141
+ FfiConverterTypeZkapProofRequest.lower(request),
142
+ callStatus);
143
+ },
144
+ /*liftString:*/ FfiConverterString.lift,
145
+ ));
146
+ }
147
+ /**
148
+ * Generate Groth16 proofs.
149
+ *
150
+ * Loads the manifest-validated CRS bundle from `request.manifest_dir`,
151
+ * runs witness synthesis inside the release-provided `witness_gen.wasm`,
152
+ * then runs the circuit-agnostic
153
+ * `ark_ar1cs::prove_with_mode(..., VerifyAfter)` against the bundled proving key.
154
+ */
155
+ export function prove(config: ZkapCircuitConfig, request: ZkapProofRequest): ZkapProofOutput /*throws*/ {
156
+ return FfiConverterTypeZkapProofOutput.lift(
157
+ uniffiCaller.rustCallWithError(
158
+ /*liftError:*/ FfiConverterTypeZkapError.lift.bind(FfiConverterTypeZkapError),
159
+ /*caller:*/ (callStatus) => {
160
+ return nativeModule().ubrn_uniffi_zkap_uniffi_bindings_fn_func_prove(
161
+ FfiConverterTypeZkapCircuitConfig.lower(config),
162
+ FfiConverterTypeZkapProofRequest.lower(request),
163
+ callStatus);
164
+ },
165
+ /*liftString:*/ FfiConverterString.lift,
166
+ ));
167
+ }
168
+ /**
169
+ * Generate Groth16 proofs from a canonical serialized `Vec<WitnessBundle>`
170
+ * file produced outside Rust. The file is removed after it is read.
171
+ */
172
+ export function proveFromWitnessBundleFile(config: ZkapCircuitConfig, request: ZkapProofRequest, witness: ZkapWitnessBundleFile): ZkapProofOutput /*throws*/ {
173
+ return FfiConverterTypeZkapProofOutput.lift(
174
+ uniffiCaller.rustCallWithError(
175
+ /*liftError:*/ FfiConverterTypeZkapError.lift.bind(FfiConverterTypeZkapError),
176
+ /*caller:*/ (callStatus) => {
177
+ return nativeModule().ubrn_uniffi_zkap_uniffi_bindings_fn_func_prove_from_witness_bundle_file(
178
+ FfiConverterTypeZkapCircuitConfig.lower(config),
179
+ FfiConverterTypeZkapProofRequest.lower(request),
180
+ FfiConverterTypeZkapWitnessBundleFile.lower(witness),
181
+ callStatus);
182
+ },
183
+ /*liftString:*/ FfiConverterString.lift,
184
+ ));
185
+ }
186
+ /**
187
+ * Generate Groth16 proofs from canonical serialized `Vec<WitnessBundle>`
188
+ * bytes produced outside Rust, e.g. by the iOS WKWebView witness runner.
189
+ */
190
+ export function proveFromWitnessBundles(config: ZkapCircuitConfig, request: ZkapProofRequest, witness: ZkapWitnessBundleBytes): ZkapProofOutput /*throws*/ {
191
+ return FfiConverterTypeZkapProofOutput.lift(
192
+ uniffiCaller.rustCallWithError(
193
+ /*liftError:*/ FfiConverterTypeZkapError.lift.bind(FfiConverterTypeZkapError),
194
+ /*caller:*/ (callStatus) => {
195
+ return nativeModule().ubrn_uniffi_zkap_uniffi_bindings_fn_func_prove_from_witness_bundles(
196
+ FfiConverterTypeZkapCircuitConfig.lower(config),
197
+ FfiConverterTypeZkapProofRequest.lower(request),
198
+ FfiConverterTypeZkapWitnessBundleBytes.lower(witness),
199
+ callStatus);
200
+ },
201
+ /*liftString:*/ FfiConverterString.lift,
202
+ ));
203
+ }
204
+
205
+
206
+
207
+
208
+ export type ZkapAnchorResult = {
209
+ evaluations: Array<string>
210
+ }
211
+
212
+ /**
213
+ * Generated factory for {@link ZkapAnchorResult} record objects.
214
+ */
215
+ export const ZkapAnchorResult = (() => {
216
+ const defaults = () => ({
217
+ });
218
+ const create = (() => {
219
+ return uniffiCreateRecord<ZkapAnchorResult, ReturnType<typeof defaults>>(defaults);
220
+ })();
221
+ return Object.freeze({
222
+ create,
223
+ new: create,
224
+ defaults: () => Object.freeze(defaults()) as Partial<ZkapAnchorResult>,
225
+
226
+ });
227
+ })();
228
+
229
+ const FfiConverterTypeZkapAnchorResult = (() => {
230
+ type TypeName = ZkapAnchorResult;
231
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
232
+ read(from: RustBuffer): TypeName {
233
+ return {
234
+ evaluations: FfiConverterArrayString.read(from)
235
+ };
236
+ }
237
+ write(value: TypeName, into: RustBuffer): void {
238
+ FfiConverterArrayString.write(value.evaluations, into);
239
+ }
240
+ allocationSize(value: TypeName): number {
241
+ return FfiConverterArrayString.allocationSize(value.evaluations);
242
+
243
+ }
244
+ };
245
+ return new FFIConverter();
246
+ })();
247
+
248
+
249
+ export type ZkapAudHashResult = {
250
+ audHashes: Array<string>,
251
+ hAudList: string
252
+ }
253
+
254
+ /**
255
+ * Generated factory for {@link ZkapAudHashResult} record objects.
256
+ */
257
+ export const ZkapAudHashResult = (() => {
258
+ const defaults = () => ({
259
+ });
260
+ const create = (() => {
261
+ return uniffiCreateRecord<ZkapAudHashResult, ReturnType<typeof defaults>>(defaults);
262
+ })();
263
+ return Object.freeze({
264
+ create,
265
+ new: create,
266
+ defaults: () => Object.freeze(defaults()) as Partial<ZkapAudHashResult>,
267
+
268
+ });
269
+ })();
270
+
271
+ const FfiConverterTypeZkapAudHashResult = (() => {
272
+ type TypeName = ZkapAudHashResult;
273
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
274
+ read(from: RustBuffer): TypeName {
275
+ return {
276
+ audHashes: FfiConverterArrayString.read(from),
277
+ hAudList: FfiConverterString.read(from)
278
+ };
279
+ }
280
+ write(value: TypeName, into: RustBuffer): void {
281
+ FfiConverterArrayString.write(value.audHashes, into);
282
+ FfiConverterString.write(value.hAudList, into);
283
+ }
284
+ allocationSize(value: TypeName): number {
285
+ return FfiConverterArrayString.allocationSize(value.audHashes) +
286
+ FfiConverterString.allocationSize(value.hAudList);
287
+
288
+ }
289
+ };
290
+ return new FFIConverter();
291
+ })();
292
+
293
+
294
+ export type ZkapCircuitConfig = {
295
+ maxJwtB64Len: /*u64*/bigint,
296
+ maxPayloadB64Len: /*u64*/bigint,
297
+ maxAudLen: /*u64*/bigint,
298
+ maxExpLen: /*u64*/bigint,
299
+ maxIssLen: /*u64*/bigint,
300
+ maxNonceLen: /*u64*/bigint,
301
+ maxSubLen: /*u64*/bigint,
302
+ n: /*u64*/bigint,
303
+ k: /*u64*/bigint,
304
+ treeHeight: /*u64*/bigint,
305
+ numAudienceLimit: /*u64*/bigint,
306
+ claims: Array<string>,
307
+ forbiddenString: string
308
+ }
309
+
310
+ /**
311
+ * Generated factory for {@link ZkapCircuitConfig} record objects.
312
+ */
313
+ export const ZkapCircuitConfig = (() => {
314
+ const defaults = () => ({
315
+ });
316
+ const create = (() => {
317
+ return uniffiCreateRecord<ZkapCircuitConfig, ReturnType<typeof defaults>>(defaults);
318
+ })();
319
+ return Object.freeze({
320
+ create,
321
+ new: create,
322
+ defaults: () => Object.freeze(defaults()) as Partial<ZkapCircuitConfig>,
323
+
324
+ });
325
+ })();
326
+
327
+ const FfiConverterTypeZkapCircuitConfig = (() => {
328
+ type TypeName = ZkapCircuitConfig;
329
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
330
+ read(from: RustBuffer): TypeName {
331
+ return {
332
+ maxJwtB64Len: FfiConverterUInt64.read(from),
333
+ maxPayloadB64Len: FfiConverterUInt64.read(from),
334
+ maxAudLen: FfiConverterUInt64.read(from),
335
+ maxExpLen: FfiConverterUInt64.read(from),
336
+ maxIssLen: FfiConverterUInt64.read(from),
337
+ maxNonceLen: FfiConverterUInt64.read(from),
338
+ maxSubLen: FfiConverterUInt64.read(from),
339
+ n: FfiConverterUInt64.read(from),
340
+ k: FfiConverterUInt64.read(from),
341
+ treeHeight: FfiConverterUInt64.read(from),
342
+ numAudienceLimit: FfiConverterUInt64.read(from),
343
+ claims: FfiConverterArrayString.read(from),
344
+ forbiddenString: FfiConverterString.read(from)
345
+ };
346
+ }
347
+ write(value: TypeName, into: RustBuffer): void {
348
+ FfiConverterUInt64.write(value.maxJwtB64Len, into);
349
+ FfiConverterUInt64.write(value.maxPayloadB64Len, into);
350
+ FfiConverterUInt64.write(value.maxAudLen, into);
351
+ FfiConverterUInt64.write(value.maxExpLen, into);
352
+ FfiConverterUInt64.write(value.maxIssLen, into);
353
+ FfiConverterUInt64.write(value.maxNonceLen, into);
354
+ FfiConverterUInt64.write(value.maxSubLen, into);
355
+ FfiConverterUInt64.write(value.n, into);
356
+ FfiConverterUInt64.write(value.k, into);
357
+ FfiConverterUInt64.write(value.treeHeight, into);
358
+ FfiConverterUInt64.write(value.numAudienceLimit, into);
359
+ FfiConverterArrayString.write(value.claims, into);
360
+ FfiConverterString.write(value.forbiddenString, into);
361
+ }
362
+ allocationSize(value: TypeName): number {
363
+ return FfiConverterUInt64.allocationSize(value.maxJwtB64Len) +
364
+ FfiConverterUInt64.allocationSize(value.maxPayloadB64Len) +
365
+ FfiConverterUInt64.allocationSize(value.maxAudLen) +
366
+ FfiConverterUInt64.allocationSize(value.maxExpLen) +
367
+ FfiConverterUInt64.allocationSize(value.maxIssLen) +
368
+ FfiConverterUInt64.allocationSize(value.maxNonceLen) +
369
+ FfiConverterUInt64.allocationSize(value.maxSubLen) +
370
+ FfiConverterUInt64.allocationSize(value.n) +
371
+ FfiConverterUInt64.allocationSize(value.k) +
372
+ FfiConverterUInt64.allocationSize(value.treeHeight) +
373
+ FfiConverterUInt64.allocationSize(value.numAudienceLimit) +
374
+ FfiConverterArrayString.allocationSize(value.claims) +
375
+ FfiConverterString.allocationSize(value.forbiddenString);
376
+
377
+ }
378
+ };
379
+ return new FFIConverter();
380
+ })();
381
+
382
+
383
+ export type ZkapPreparedWitnessInputs = {
384
+ manifestDir: string,
385
+ wasmBase64: string,
386
+ requestJsonBase64: string,
387
+ configJsonBase64: string,
388
+ witnessGenSha256: string,
389
+ requestJsonSha256: string,
390
+ configJsonSha256: string,
391
+ wasmByteLength: /*u64*/bigint,
392
+ requestJsonByteLength: /*u64*/bigint,
393
+ configJsonByteLength: /*u64*/bigint
394
+ }
395
+
396
+ /**
397
+ * Generated factory for {@link ZkapPreparedWitnessInputs} record objects.
398
+ */
399
+ export const ZkapPreparedWitnessInputs = (() => {
400
+ const defaults = () => ({
401
+ });
402
+ const create = (() => {
403
+ return uniffiCreateRecord<ZkapPreparedWitnessInputs, ReturnType<typeof defaults>>(defaults);
404
+ })();
405
+ return Object.freeze({
406
+ create,
407
+ new: create,
408
+ defaults: () => Object.freeze(defaults()) as Partial<ZkapPreparedWitnessInputs>,
409
+
410
+ });
411
+ })();
412
+
413
+ const FfiConverterTypeZkapPreparedWitnessInputs = (() => {
414
+ type TypeName = ZkapPreparedWitnessInputs;
415
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
416
+ read(from: RustBuffer): TypeName {
417
+ return {
418
+ manifestDir: FfiConverterString.read(from),
419
+ wasmBase64: FfiConverterString.read(from),
420
+ requestJsonBase64: FfiConverterString.read(from),
421
+ configJsonBase64: FfiConverterString.read(from),
422
+ witnessGenSha256: FfiConverterString.read(from),
423
+ requestJsonSha256: FfiConverterString.read(from),
424
+ configJsonSha256: FfiConverterString.read(from),
425
+ wasmByteLength: FfiConverterUInt64.read(from),
426
+ requestJsonByteLength: FfiConverterUInt64.read(from),
427
+ configJsonByteLength: FfiConverterUInt64.read(from)
428
+ };
429
+ }
430
+ write(value: TypeName, into: RustBuffer): void {
431
+ FfiConverterString.write(value.manifestDir, into);
432
+ FfiConverterString.write(value.wasmBase64, into);
433
+ FfiConverterString.write(value.requestJsonBase64, into);
434
+ FfiConverterString.write(value.configJsonBase64, into);
435
+ FfiConverterString.write(value.witnessGenSha256, into);
436
+ FfiConverterString.write(value.requestJsonSha256, into);
437
+ FfiConverterString.write(value.configJsonSha256, into);
438
+ FfiConverterUInt64.write(value.wasmByteLength, into);
439
+ FfiConverterUInt64.write(value.requestJsonByteLength, into);
440
+ FfiConverterUInt64.write(value.configJsonByteLength, into);
441
+ }
442
+ allocationSize(value: TypeName): number {
443
+ return FfiConverterString.allocationSize(value.manifestDir) +
444
+ FfiConverterString.allocationSize(value.wasmBase64) +
445
+ FfiConverterString.allocationSize(value.requestJsonBase64) +
446
+ FfiConverterString.allocationSize(value.configJsonBase64) +
447
+ FfiConverterString.allocationSize(value.witnessGenSha256) +
448
+ FfiConverterString.allocationSize(value.requestJsonSha256) +
449
+ FfiConverterString.allocationSize(value.configJsonSha256) +
450
+ FfiConverterUInt64.allocationSize(value.wasmByteLength) +
451
+ FfiConverterUInt64.allocationSize(value.requestJsonByteLength) +
452
+ FfiConverterUInt64.allocationSize(value.configJsonByteLength);
453
+
454
+ }
455
+ };
456
+ return new FFIConverter();
457
+ })();
458
+
459
+
460
+ export type ZkapProofOutput = {
461
+ /**
462
+ * Solidity-compatible proof components per credential: [ax, ay, bx_c1, bx_c0, by_c1, by_c0, cx, cy]
463
+ */
464
+ proofs: Array<Array<string>>,
465
+ sharedInputs: Array<string>,
466
+ partialRhsList: Array<string>,
467
+ jwtExpList: Array<string>
468
+ }
469
+
470
+ /**
471
+ * Generated factory for {@link ZkapProofOutput} record objects.
472
+ */
473
+ export const ZkapProofOutput = (() => {
474
+ const defaults = () => ({
475
+ });
476
+ const create = (() => {
477
+ return uniffiCreateRecord<ZkapProofOutput, ReturnType<typeof defaults>>(defaults);
478
+ })();
479
+ return Object.freeze({
480
+ create,
481
+ new: create,
482
+ defaults: () => Object.freeze(defaults()) as Partial<ZkapProofOutput>,
483
+
484
+ });
485
+ })();
486
+
487
+ const FfiConverterTypeZkapProofOutput = (() => {
488
+ type TypeName = ZkapProofOutput;
489
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
490
+ read(from: RustBuffer): TypeName {
491
+ return {
492
+ proofs: FfiConverterArrayArrayString.read(from),
493
+ sharedInputs: FfiConverterArrayString.read(from),
494
+ partialRhsList: FfiConverterArrayString.read(from),
495
+ jwtExpList: FfiConverterArrayString.read(from)
496
+ };
497
+ }
498
+ write(value: TypeName, into: RustBuffer): void {
499
+ FfiConverterArrayArrayString.write(value.proofs, into);
500
+ FfiConverterArrayString.write(value.sharedInputs, into);
501
+ FfiConverterArrayString.write(value.partialRhsList, into);
502
+ FfiConverterArrayString.write(value.jwtExpList, into);
503
+ }
504
+ allocationSize(value: TypeName): number {
505
+ return FfiConverterArrayArrayString.allocationSize(value.proofs) +
506
+ FfiConverterArrayString.allocationSize(value.sharedInputs) +
507
+ FfiConverterArrayString.allocationSize(value.partialRhsList) +
508
+ FfiConverterArrayString.allocationSize(value.jwtExpList);
509
+
510
+ }
511
+ };
512
+ return new FFIConverter();
513
+ })();
514
+
515
+
516
+ /**
517
+ * Inputs for [`prove`].
518
+ *
519
+ * Replaces the legacy `pk_path` + flat per-credential vectors with
520
+ * the post-migration shape: caller points us at the manifest-validated
521
+ * CRS bundle directory, then supplies the [`crate::ProveRequest`]
522
+ * fields. Hanchor and audience-list hashes are computed internally
523
+ * from `anchor` and the credentials.
524
+ */
525
+ export type ZkapProofRequest = {
526
+ /**
527
+ * Directory containing `manifest.json` + the CRS bundle. The
528
+ * manifest is sha256-validated by `ArtifactSet::load`; witness
529
+ * generation runs inside the release-provided `witness_gen.wasm`.
530
+ * `ar1cs_prove` always runs natively against the bundled proving key.
531
+ */
532
+ manifestDir: string,
533
+ /**
534
+ * Randomness salt — BN254 Fr (hex/decimal).
535
+ */
536
+ random: string,
537
+ /**
538
+ * Hash of the signed user-op payload — BN254 Fr (hex/decimal).
539
+ */
540
+ hSignUserOp: string,
541
+ /**
542
+ * Anchor polynomial evaluations (length = `config.n - config.k + 1`).
543
+ */
544
+ anchor: Array<string>,
545
+ /**
546
+ * Issuer-key Merkle tree root — BN254 Fr (hex/decimal).
547
+ */
548
+ merkleRoot: string,
549
+ /**
550
+ * One entry per JWT credential; length must equal `config.k`.
551
+ */
552
+ credentials: Array<ZkapProveCredential>
553
+ }
554
+
555
+ /**
556
+ * Generated factory for {@link ZkapProofRequest} record objects.
557
+ */
558
+ export const ZkapProofRequest = (() => {
559
+ const defaults = () => ({
560
+ });
561
+ const create = (() => {
562
+ return uniffiCreateRecord<ZkapProofRequest, ReturnType<typeof defaults>>(defaults);
563
+ })();
564
+ return Object.freeze({
565
+ create,
566
+ new: create,
567
+ defaults: () => Object.freeze(defaults()) as Partial<ZkapProofRequest>,
568
+
569
+ });
570
+ })();
571
+
572
+ const FfiConverterTypeZkapProofRequest = (() => {
573
+ type TypeName = ZkapProofRequest;
574
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
575
+ read(from: RustBuffer): TypeName {
576
+ return {
577
+ manifestDir: FfiConverterString.read(from),
578
+ random: FfiConverterString.read(from),
579
+ hSignUserOp: FfiConverterString.read(from),
580
+ anchor: FfiConverterArrayString.read(from),
581
+ merkleRoot: FfiConverterString.read(from),
582
+ credentials: FfiConverterArrayTypeZkapProveCredential.read(from)
583
+ };
584
+ }
585
+ write(value: TypeName, into: RustBuffer): void {
586
+ FfiConverterString.write(value.manifestDir, into);
587
+ FfiConverterString.write(value.random, into);
588
+ FfiConverterString.write(value.hSignUserOp, into);
589
+ FfiConverterArrayString.write(value.anchor, into);
590
+ FfiConverterString.write(value.merkleRoot, into);
591
+ FfiConverterArrayTypeZkapProveCredential.write(value.credentials, into);
592
+ }
593
+ allocationSize(value: TypeName): number {
594
+ return FfiConverterString.allocationSize(value.manifestDir) +
595
+ FfiConverterString.allocationSize(value.random) +
596
+ FfiConverterString.allocationSize(value.hSignUserOp) +
597
+ FfiConverterArrayString.allocationSize(value.anchor) +
598
+ FfiConverterString.allocationSize(value.merkleRoot) +
599
+ FfiConverterArrayTypeZkapProveCredential.allocationSize(value.credentials);
600
+
601
+ }
602
+ };
603
+ return new FFIConverter();
604
+ })();
605
+
606
+
607
+ /**
608
+ * Per-credential prove inputs (one per JWT participating in the batch).
609
+ */
610
+ export type ZkapProveCredential = {
611
+ /**
612
+ * JWT compact serialization (`header.payload.signature`).
613
+ */
614
+ jwt: string,
615
+ /**
616
+ * Base64 of the 256-byte RSA-2048 modulus of the issuer key.
617
+ */
618
+ rsaModulusB64: string,
619
+ /**
620
+ * Merkle authentication path siblings — BN254 Fr hex/decimal.
621
+ */
622
+ merklePath: Array<string>,
623
+ /**
624
+ * Leaf index in the issuer-key Merkle tree.
625
+ */
626
+ merkleLeafIdx: /*u64*/bigint
627
+ }
628
+
629
+ /**
630
+ * Generated factory for {@link ZkapProveCredential} record objects.
631
+ */
632
+ export const ZkapProveCredential = (() => {
633
+ const defaults = () => ({
634
+ });
635
+ const create = (() => {
636
+ return uniffiCreateRecord<ZkapProveCredential, ReturnType<typeof defaults>>(defaults);
637
+ })();
638
+ return Object.freeze({
639
+ create,
640
+ new: create,
641
+ defaults: () => Object.freeze(defaults()) as Partial<ZkapProveCredential>,
642
+
643
+ });
644
+ })();
645
+
646
+ const FfiConverterTypeZkapProveCredential = (() => {
647
+ type TypeName = ZkapProveCredential;
648
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
649
+ read(from: RustBuffer): TypeName {
650
+ return {
651
+ jwt: FfiConverterString.read(from),
652
+ rsaModulusB64: FfiConverterString.read(from),
653
+ merklePath: FfiConverterArrayString.read(from),
654
+ merkleLeafIdx: FfiConverterUInt64.read(from)
655
+ };
656
+ }
657
+ write(value: TypeName, into: RustBuffer): void {
658
+ FfiConverterString.write(value.jwt, into);
659
+ FfiConverterString.write(value.rsaModulusB64, into);
660
+ FfiConverterArrayString.write(value.merklePath, into);
661
+ FfiConverterUInt64.write(value.merkleLeafIdx, into);
662
+ }
663
+ allocationSize(value: TypeName): number {
664
+ return FfiConverterString.allocationSize(value.jwt) +
665
+ FfiConverterString.allocationSize(value.rsaModulusB64) +
666
+ FfiConverterArrayString.allocationSize(value.merklePath) +
667
+ FfiConverterUInt64.allocationSize(value.merkleLeafIdx);
668
+
669
+ }
670
+ };
671
+ return new FFIConverter();
672
+ })();
673
+
674
+
675
+ export type ZkapSecret = {
676
+ sub: string,
677
+ iss: string,
678
+ aud: string
679
+ }
680
+
681
+ /**
682
+ * Generated factory for {@link ZkapSecret} record objects.
683
+ */
684
+ export const ZkapSecret = (() => {
685
+ const defaults = () => ({
686
+ });
687
+ const create = (() => {
688
+ return uniffiCreateRecord<ZkapSecret, ReturnType<typeof defaults>>(defaults);
689
+ })();
690
+ return Object.freeze({
691
+ create,
692
+ new: create,
693
+ defaults: () => Object.freeze(defaults()) as Partial<ZkapSecret>,
694
+
695
+ });
696
+ })();
697
+
698
+ const FfiConverterTypeZkapSecret = (() => {
699
+ type TypeName = ZkapSecret;
700
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
701
+ read(from: RustBuffer): TypeName {
702
+ return {
703
+ sub: FfiConverterString.read(from),
704
+ iss: FfiConverterString.read(from),
705
+ aud: FfiConverterString.read(from)
706
+ };
707
+ }
708
+ write(value: TypeName, into: RustBuffer): void {
709
+ FfiConverterString.write(value.sub, into);
710
+ FfiConverterString.write(value.iss, into);
711
+ FfiConverterString.write(value.aud, into);
712
+ }
713
+ allocationSize(value: TypeName): number {
714
+ return FfiConverterString.allocationSize(value.sub) +
715
+ FfiConverterString.allocationSize(value.iss) +
716
+ FfiConverterString.allocationSize(value.aud);
717
+
718
+ }
719
+ };
720
+ return new FFIConverter();
721
+ })();
722
+
723
+
724
+ export type ZkapWitnessBundleBytes = {
725
+ witnessBundlesBase64: string,
726
+ sha256: string,
727
+ byteLength: /*u64*/bigint
728
+ }
729
+
730
+ /**
731
+ * Generated factory for {@link ZkapWitnessBundleBytes} record objects.
732
+ */
733
+ export const ZkapWitnessBundleBytes = (() => {
734
+ const defaults = () => ({
735
+ });
736
+ const create = (() => {
737
+ return uniffiCreateRecord<ZkapWitnessBundleBytes, ReturnType<typeof defaults>>(defaults);
738
+ })();
739
+ return Object.freeze({
740
+ create,
741
+ new: create,
742
+ defaults: () => Object.freeze(defaults()) as Partial<ZkapWitnessBundleBytes>,
743
+
744
+ });
745
+ })();
746
+
747
+ const FfiConverterTypeZkapWitnessBundleBytes = (() => {
748
+ type TypeName = ZkapWitnessBundleBytes;
749
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
750
+ read(from: RustBuffer): TypeName {
751
+ return {
752
+ witnessBundlesBase64: FfiConverterString.read(from),
753
+ sha256: FfiConverterString.read(from),
754
+ byteLength: FfiConverterUInt64.read(from)
755
+ };
756
+ }
757
+ write(value: TypeName, into: RustBuffer): void {
758
+ FfiConverterString.write(value.witnessBundlesBase64, into);
759
+ FfiConverterString.write(value.sha256, into);
760
+ FfiConverterUInt64.write(value.byteLength, into);
761
+ }
762
+ allocationSize(value: TypeName): number {
763
+ return FfiConverterString.allocationSize(value.witnessBundlesBase64) +
764
+ FfiConverterString.allocationSize(value.sha256) +
765
+ FfiConverterUInt64.allocationSize(value.byteLength);
766
+
767
+ }
768
+ };
769
+ return new FFIConverter();
770
+ })();
771
+
772
+
773
+ export type ZkapWitnessBundleFile = {
774
+ witnessBundlePath: string,
775
+ sha256: string,
776
+ byteLength: /*u64*/bigint
777
+ }
778
+
779
+ /**
780
+ * Generated factory for {@link ZkapWitnessBundleFile} record objects.
781
+ */
782
+ export const ZkapWitnessBundleFile = (() => {
783
+ const defaults = () => ({
784
+ });
785
+ const create = (() => {
786
+ return uniffiCreateRecord<ZkapWitnessBundleFile, ReturnType<typeof defaults>>(defaults);
787
+ })();
788
+ return Object.freeze({
789
+ create,
790
+ new: create,
791
+ defaults: () => Object.freeze(defaults()) as Partial<ZkapWitnessBundleFile>,
792
+
793
+ });
794
+ })();
795
+
796
+ const FfiConverterTypeZkapWitnessBundleFile = (() => {
797
+ type TypeName = ZkapWitnessBundleFile;
798
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
799
+ read(from: RustBuffer): TypeName {
800
+ return {
801
+ witnessBundlePath: FfiConverterString.read(from),
802
+ sha256: FfiConverterString.read(from),
803
+ byteLength: FfiConverterUInt64.read(from)
804
+ };
805
+ }
806
+ write(value: TypeName, into: RustBuffer): void {
807
+ FfiConverterString.write(value.witnessBundlePath, into);
808
+ FfiConverterString.write(value.sha256, into);
809
+ FfiConverterUInt64.write(value.byteLength, into);
810
+ }
811
+ allocationSize(value: TypeName): number {
812
+ return FfiConverterString.allocationSize(value.witnessBundlePath) +
813
+ FfiConverterString.allocationSize(value.sha256) +
814
+ FfiConverterUInt64.allocationSize(value.byteLength);
815
+
816
+ }
817
+ };
818
+ return new FFIConverter();
819
+ })();
820
+
821
+
822
+ const stringConverter = {
823
+ stringToBytes: (s: string) =>
824
+ uniffiCaller.rustCall((status) => nativeModule().ubrn_uniffi_internal_fn_func_ffi__string_to_arraybuffer(s, status)),
825
+ bytesToString: (ab: UniffiByteArray) =>
826
+ uniffiCaller.rustCall((status) => nativeModule().ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string(ab, status)),
827
+ stringByteLength: (s: string) =>
828
+ uniffiCaller.rustCall((status) => nativeModule().ubrn_uniffi_internal_fn_func_ffi__string_to_byte_length(s, status)),
829
+ };
830
+ const FfiConverterString = uniffiCreateFfiConverterString(stringConverter);
831
+
832
+
833
+
834
+
835
+ // Error type: ZkapError
836
+
837
+ // Enum: ZkapError
838
+ export enum ZkapError_Tags {
839
+ ApplicationError = "ApplicationError"
840
+ }
841
+ export const ZkapError = (() => {
842
+
843
+
844
+ type ApplicationError__interface = {
845
+ tag: ZkapError_Tags.ApplicationError;
846
+ inner: Readonly<{message: string}>
847
+ };
848
+
849
+
850
+ class ApplicationError_ extends UniffiError implements ApplicationError__interface {
851
+ /**
852
+ * @private
853
+ * This field is private and should not be used, use `tag` instead.
854
+ */
855
+ readonly [uniffiTypeNameSymbol] = "ZkapError";
856
+ readonly tag = ZkapError_Tags.ApplicationError;
857
+ readonly inner: Readonly<{message: string}>;
858
+ constructor(inner: { message: string }) {
859
+ super("ZkapError", "ApplicationError");
860
+ this.inner = Object.freeze(inner);
861
+ }
862
+
863
+ static new(inner: { message: string }): ApplicationError_ {
864
+ return new ApplicationError_(inner);
865
+ }
866
+
867
+ static instanceOf(obj: any): obj is ApplicationError_ {
868
+ return obj.tag === ZkapError_Tags.ApplicationError;
869
+ }
870
+
871
+
872
+
873
+ static hasInner(obj: any): obj is ApplicationError_ {
874
+ return ApplicationError_.instanceOf(obj);
875
+ }
876
+
877
+ static getInner(obj: ApplicationError_): Readonly<{message: string}> {
878
+ return obj.inner;
879
+ }
880
+
881
+ }
882
+
883
+ function instanceOf(obj: any): obj is ZkapError {
884
+ return obj[uniffiTypeNameSymbol] === "ZkapError";
885
+ }
886
+
887
+ return Object.freeze({
888
+ instanceOf,
889
+ ApplicationError: ApplicationError_
890
+ });
891
+
892
+ })();
893
+
894
+
895
+
896
+ export type ZkapError = InstanceType<
897
+ typeof ZkapError[keyof Omit<typeof ZkapError, 'instanceOf'>]
898
+ >;
899
+
900
+ // FfiConverter for enum ZkapError
901
+ const FfiConverterTypeZkapError = (() => {
902
+ const ordinalConverter = FfiConverterInt32;
903
+ type TypeName = ZkapError;
904
+ class FFIConverter extends AbstractFfiConverterByteArray<TypeName> {
905
+ read(from: RustBuffer): TypeName {
906
+ switch (ordinalConverter.read(from)) {
907
+ case 1: return new ZkapError.ApplicationError({message: FfiConverterString.read(from) });
908
+ default: throw new UniffiInternalError.UnexpectedEnumCase();
909
+ }
910
+ }
911
+ write(value: TypeName, into: RustBuffer): void {
912
+ switch (value.tag) {
913
+ case ZkapError_Tags.ApplicationError: {
914
+ ordinalConverter.write(1, into);
915
+ const inner = value.inner;
916
+ FfiConverterString.write(inner.message, into);
917
+ return;
918
+ }
919
+ default:
920
+ // Throwing from here means that ZkapError_Tags hasn't matched an ordinal.
921
+ throw new UniffiInternalError.UnexpectedEnumCase();
922
+ }
923
+ }
924
+ allocationSize(value: TypeName): number {
925
+ switch (value.tag) {
926
+ case ZkapError_Tags.ApplicationError: {
927
+ const inner = value.inner;
928
+ let size = ordinalConverter.allocationSize(1);
929
+ size += FfiConverterString.allocationSize(inner.message);
930
+ return size;
931
+ }
932
+ default: throw new UniffiInternalError.UnexpectedEnumCase();
933
+ }
934
+ }
935
+ }
936
+ return new FFIConverter();
937
+ })();
938
+
939
+
940
+ // FfiConverter for Array<ZkapProveCredential>
941
+ const FfiConverterArrayTypeZkapProveCredential = new FfiConverterArray(FfiConverterTypeZkapProveCredential);
942
+
943
+
944
+ // FfiConverter for Array<ZkapSecret>
945
+ const FfiConverterArrayTypeZkapSecret = new FfiConverterArray(FfiConverterTypeZkapSecret);
946
+
947
+
948
+ // FfiConverter for Array<string>
949
+ const FfiConverterArrayString = new FfiConverterArray(FfiConverterString);
950
+
951
+
952
+ // FfiConverter for Array<Array<string>>
953
+ const FfiConverterArrayArrayString = new FfiConverterArray(FfiConverterArrayString);
954
+
955
+ /**
956
+ * This should be called before anything else.
957
+ *
958
+ * It is likely that this is being done for you by the library's `index.ts`.
959
+ *
960
+ * It checks versions of uniffi between when the Rust scaffolding was generated
961
+ * and when the bindings were generated.
962
+ *
963
+ * It also initializes the machinery to enable Rust to talk back to Javascript.
964
+ */
965
+ function uniffiEnsureInitialized() {
966
+ // Get the bindings contract version from our ComponentInterface
967
+ const bindingsContractVersion = 30;
968
+ // Get the scaffolding contract version by calling the into the dylib
969
+ const scaffoldingContractVersion = nativeModule().ubrn_ffi_zkap_uniffi_bindings_uniffi_contract_version();
970
+ if (bindingsContractVersion !== scaffoldingContractVersion) {
971
+ throw new UniffiInternalError.ContractVersionMismatch(scaffoldingContractVersion, bindingsContractVersion);
972
+ }
973
+ if (nativeModule().ubrn_uniffi_zkap_uniffi_bindings_checksum_func_generate_anchor() !== 10088) {
974
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_zkap_uniffi_bindings_checksum_func_generate_anchor");
975
+ }
976
+ if (nativeModule().ubrn_uniffi_zkap_uniffi_bindings_checksum_func_generate_aud_hash() !== 42467) {
977
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_zkap_uniffi_bindings_checksum_func_generate_aud_hash");
978
+ }
979
+ if (nativeModule().ubrn_uniffi_zkap_uniffi_bindings_checksum_func_generate_hash() !== 6188) {
980
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_zkap_uniffi_bindings_checksum_func_generate_hash");
981
+ }
982
+ if (nativeModule().ubrn_uniffi_zkap_uniffi_bindings_checksum_func_generate_leaf_hash() !== 28430) {
983
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_zkap_uniffi_bindings_checksum_func_generate_leaf_hash");
984
+ }
985
+ if (nativeModule().ubrn_uniffi_zkap_uniffi_bindings_checksum_func_prepare_witness_inputs() !== 50971) {
986
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_zkap_uniffi_bindings_checksum_func_prepare_witness_inputs");
987
+ }
988
+ if (nativeModule().ubrn_uniffi_zkap_uniffi_bindings_checksum_func_prove() !== 35511) {
989
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_zkap_uniffi_bindings_checksum_func_prove");
990
+ }
991
+ if (nativeModule().ubrn_uniffi_zkap_uniffi_bindings_checksum_func_prove_from_witness_bundle_file() !== 12913) {
992
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_zkap_uniffi_bindings_checksum_func_prove_from_witness_bundle_file");
993
+ }
994
+ if (nativeModule().ubrn_uniffi_zkap_uniffi_bindings_checksum_func_prove_from_witness_bundles() !== 37306) {
995
+ throw new UniffiInternalError.ApiChecksumMismatch("uniffi_zkap_uniffi_bindings_checksum_func_prove_from_witness_bundles");
996
+ }
997
+
998
+ }
999
+
1000
+ export default Object.freeze({
1001
+ initialize: uniffiEnsureInitialized,
1002
+ converters: {
1003
+ FfiConverterTypeZkapAnchorResult,
1004
+ FfiConverterTypeZkapAudHashResult,
1005
+ FfiConverterTypeZkapCircuitConfig,
1006
+ FfiConverterTypeZkapError,
1007
+ FfiConverterTypeZkapPreparedWitnessInputs,
1008
+ FfiConverterTypeZkapProofOutput,
1009
+ FfiConverterTypeZkapProofRequest,
1010
+ FfiConverterTypeZkapProveCredential,
1011
+ FfiConverterTypeZkapSecret,
1012
+ FfiConverterTypeZkapWitnessBundleBytes,
1013
+ FfiConverterTypeZkapWitnessBundleFile,
1014
+ }
1015
+ });