@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
@@ -1,9 +0,0 @@
1
- {
2
- "platforms": ["ios", "android"],
3
- "ios": {
4
- "modules": ["ZkapSdkModule"]
5
- },
6
- "android": {
7
- "modules": ["expo.modules.zkap.ZkapSdkModule"]
8
- }
9
- }
@@ -1,35 +0,0 @@
1
- require 'json'
2
-
3
- package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
4
-
5
- Pod::Spec.new do |s|
6
- s.name = 'ZkapSdkModule'
7
- s.version = package['version']
8
- s.summary = package['description']
9
- s.license = package['license']
10
- s.authors = package['author']
11
- s.homepage = package['homepage']
12
- s.platform = :ios, '15.0'
13
- s.swift_version = '5.9'
14
- s.source = { git: package['repository']['url'] }
15
-
16
- s.source_files = ['ZkapSdkModule.swift', 'uniffi/**/*.{swift,h,m}']
17
-
18
- # Pre-built Rust static libraries (generated by CI build-react-native.yml)
19
- s.vendored_frameworks = 'ZkapZkp.xcframework'
20
-
21
- # Expose C headers for the Rust FFI symbols (UniFFI-generated module)
22
- s.preserve_paths = 'uniffi/*.h'
23
- s.xcconfig = {
24
- 'OTHER_LDFLAGS' => '-lc++'
25
- }
26
-
27
- s.dependency 'ExpoModulesCore'
28
-
29
- s.pod_target_xcconfig = {
30
- 'DEFINES_MODULE' => 'YES',
31
- 'SWIFT_COMPILATION_MODE' => 'wholemodule',
32
- 'HEADER_SEARCH_PATHS' => '$(PODS_TARGET_SRCROOT)/uniffi',
33
- 'OTHER_CFLAGS' => '-fmodule-map-file=$(PODS_TARGET_SRCROOT)/uniffi/zkap_uniffi_bindingsFFI.modulemap'
34
- }
35
- end
@@ -1,147 +0,0 @@
1
- import ExpoModulesCore
2
-
3
- public class ZkapSdkModule: Module {
4
- public func definition() -> ModuleDefinition {
5
- Name("ZkapSdk")
6
-
7
- // ──────────────────────────────────────────
8
- // generateHash
9
- // ──────────────────────────────────────────
10
- AsyncFunction("generateHash") { (inputJson: String) -> String in
11
- let data = inputJson.data(using: .utf8)!
12
- let obj = try JSONSerialization.jsonObject(with: data) as! [String: Any]
13
- let messages = obj["messages"] as! [String]
14
-
15
- let result = try generateHash(messages: messages)
16
-
17
- let output: [String: Any] = ["result": result]
18
- let outData = try JSONSerialization.data(withJSONObject: output)
19
- return String(data: outData, encoding: .utf8)!
20
- }
21
-
22
- // ──────────────────────────────────────────
23
- // generateAudHash
24
- // ──────────────────────────────────────────
25
- AsyncFunction("generateAudHash") { (inputJson: String) -> String in
26
- let data = inputJson.data(using: .utf8)!
27
- let obj = try JSONSerialization.jsonObject(with: data) as! [String: Any]
28
- let config = parseConfig(obj["config"] as! [String: Any])
29
- let audList = obj["aud_list"] as! [String]
30
-
31
- let result = try generateAudHash(config: config, audList: audList)
32
-
33
- let output: [String: Any] = [
34
- "aud_hashes": result.audHashes,
35
- "h_aud_list": result.hAudList
36
- ]
37
- let outData = try JSONSerialization.data(withJSONObject: output)
38
- return String(data: outData, encoding: .utf8)!
39
- }
40
-
41
- // ──────────────────────────────────────────
42
- // generateLeafHash
43
- // ──────────────────────────────────────────
44
- AsyncFunction("generateLeafHash") { (inputJson: String) -> String in
45
- let data = inputJson.data(using: .utf8)!
46
- let obj = try JSONSerialization.jsonObject(with: data) as! [String: Any]
47
- let config = parseConfig(obj["config"] as! [String: Any])
48
- let iss = obj["iss"] as! String
49
- let pkB64 = obj["pk_b64"] as! String
50
-
51
- let result = try generateLeafHash(config: config, iss: iss, pkB64: pkB64)
52
-
53
- let output: [String: Any] = ["result": result]
54
- let outData = try JSONSerialization.data(withJSONObject: output)
55
- return String(data: outData, encoding: .utf8)!
56
- }
57
-
58
- // ──────────────────────────────────────────
59
- // generateAnchor
60
- // ──────────────────────────────────────────
61
- AsyncFunction("generateAnchor") { (inputJson: String) -> String in
62
- let data = inputJson.data(using: .utf8)!
63
- let obj = try JSONSerialization.jsonObject(with: data) as! [String: Any]
64
- let config = parseConfig(obj["config"] as! [String: Any])
65
- let rawSecrets = obj["secrets"] as! [[String: Any]]
66
- let secrets = rawSecrets.map { s in
67
- ZkapSecret(
68
- sub: s["sub"] as! String,
69
- iss: s["iss"] as! String,
70
- aud: s["aud"] as! String
71
- )
72
- }
73
-
74
- let result = try generateAnchor(config: config, secrets: secrets)
75
-
76
- let output: [String: Any] = ["evaluations": result.evaluations]
77
- let outData = try JSONSerialization.data(withJSONObject: output)
78
- return String(data: outData, encoding: .utf8)!
79
- }
80
-
81
- // ──────────────────────────────────────────
82
- // prove
83
- // ──────────────────────────────────────────
84
- AsyncFunction("prove") { (inputJson: String) -> String in
85
- let data = inputJson.data(using: .utf8)!
86
- let obj = try JSONSerialization.jsonObject(with: data) as! [String: Any]
87
- let config = parseConfig(obj["config"] as! [String: Any])
88
- let req = obj["request"] as! [String: Any]
89
-
90
- let rawLeafIndices = req["leaf_indices"] as! [Any]
91
- let leafIndices: [UInt64] = rawLeafIndices.map { v in
92
- if let n = v as? Int { return UInt64(n) }
93
- if let n = v as? UInt64 { return n }
94
- return UInt64(v as! NSNumber)
95
- }
96
-
97
- let request = ZkapProofRequest(
98
- pkPath: req["pk_path"] as! String,
99
- jwts: req["jwts"] as! [String],
100
- pkOps: req["pk_ops"] as! [String],
101
- merklePaths: req["merkle_paths"] as! [[String]],
102
- leafIndices: leafIndices,
103
- root: req["root"] as! String,
104
- anchorEvals: req["anchor_evals"] as! [String],
105
- hanchor: req["hanchor"] as! String,
106
- hSignUserOp: req["h_sign_user_op"] as! String,
107
- random: req["random"] as! String,
108
- audHashList: req["aud_hash_list"] as! [String]
109
- )
110
-
111
- let result = try prove(config: config, request: request)
112
-
113
- let output: [String: Any] = [
114
- "proofs": result.proofs,
115
- "shared_inputs": result.sharedInputs,
116
- "partial_rhs_list": result.partialRhsList,
117
- "jwt_exp_list": result.jwtExpList
118
- ]
119
- let outData = try JSONSerialization.data(withJSONObject: output)
120
- return String(data: outData, encoding: .utf8)!
121
- }
122
-
123
- }
124
- }
125
-
126
- // ──────────────────────────────────────────────────────────────────
127
- // Helpers
128
- // ──────────────────────────────────────────────────────────────────
129
-
130
- private func parseConfig(_ d: [String: Any]) -> ZkapCircuitConfig {
131
- ZkapCircuitConfig(
132
- maxJwtB64Len: UInt64(d["max_jwt_b64_len"] as! Int),
133
- maxPayloadB64Len: UInt64(d["max_payload_b64_len"] as! Int),
134
- maxAudLen: UInt64(d["max_aud_len"] as! Int),
135
- maxExpLen: UInt64(d["max_exp_len"] as! Int),
136
- maxIssLen: UInt64(d["max_iss_len"] as! Int),
137
- maxNonceLen: UInt64(d["max_nonce_len"] as! Int),
138
- maxSubLen: UInt64(d["max_sub_len"] as! Int),
139
- n: UInt64(d["n"] as! Int),
140
- k: UInt64(d["k"] as! Int),
141
- treeHeight: UInt64(d["tree_height"] as! Int),
142
- numAudienceLimit: UInt64(d["num_audience_limit"] as! Int),
143
- claims: d["claims"] as! [String],
144
- forbiddenString: d["forbidden_string"] as! String
145
- )
146
- }
147
-