Skip to content

Commit 7a4648f

Browse files
committed
feat: enhance proof generation with Gnark support and update configurations
- Added functions for generating and verifying Gnark proofs in the TypeScript and C++ layers. - Updated Android and iOS configurations to include new asset types and binary files for cubic circuit proofs. - Modified build.gradle and CMakeLists.txt to support additional architectures and shared libraries. - Enhanced asset management in link-assets-manifest.json for both Android and iOS platforms.
1 parent 3735ebf commit 7a4648f

18 files changed

Lines changed: 354 additions & 22 deletions

File tree

MoproReactNativeBindings/MoproFfiFramework.xcframework/Info.plist

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<key>BinaryPath</key>
99
<string>libmopro_example_app.a</string>
1010
<key>LibraryIdentifier</key>
11-
<string>ios-arm64-simulator</string>
11+
<string>ios-arm64</string>
1212
<key>LibraryPath</key>
1313
<string>libmopro_example_app.a</string>
1414
<key>SupportedArchitectures</key>
@@ -17,6 +17,21 @@
1717
</array>
1818
<key>SupportedPlatform</key>
1919
<string>ios</string>
20+
</dict>
21+
<dict>
22+
<key>BinaryPath</key>
23+
<string>libmopro_example_app.a</string>
24+
<key>LibraryIdentifier</key>
25+
<string>ios-arm64_x86_64-simulator</string>
26+
<key>LibraryPath</key>
27+
<string>libmopro_example_app.a</string>
28+
<key>SupportedArchitectures</key>
29+
<array>
30+
<string>arm64</string>
31+
<string>x86_64</string>
32+
</array>
33+
<key>SupportedPlatform</key>
34+
<string>ios</string>
2035
<key>SupportedPlatformVariant</key>
2136
<string>simulator</string>
2237
</dict>

MoproReactNativeBindings/MoproFfiFramework.xcframework/ios-arm64-simulator/libmopro_example_app.a renamed to MoproReactNativeBindings/MoproFfiFramework.xcframework/ios-arm64/libmopro_example_app.a

34.1 MB
Binary file not shown.

MoproReactNativeBindings/android/src/main/jniLibs/arm64-v8a/libmopro_example_app.a renamed to MoproReactNativeBindings/MoproFfiFramework.xcframework/ios-arm64_x86_64-simulator/libmopro_example_app.a

48.9 MB
Binary file not shown.

MoproReactNativeBindings/android/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,max-page-size
4242

4343
cmake_path(
4444
SET MY_RUST_LIB
45-
${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libmopro_example_app.a
45+
${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libmopro_example_app.so
4646
NORMALIZE
4747
)
48-
add_library(my_rust_lib STATIC IMPORTED)
49-
set_target_properties(my_rust_lib PROPERTIES IMPORTED_LOCATION ${MY_RUST_LIB})
48+
add_library(my_rust_lib SHARED IMPORTED)
49+
set_target_properties(my_rust_lib PROPERTIES IMPORTED_LOCATION ${MY_RUST_LIB} IMPORTED_NO_SONAME ON)
5050

5151
# Add ReactAndroid libraries, being careful to account for different versions.
5252
find_package(ReactAndroid REQUIRED CONFIG)

MoproReactNativeBindings/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ android {
7979
}
8080
}
8181
ndk {
82-
abiFilters "arm64-v8a"
82+
abiFilters "x86_64", "arm64-v8a"
8383
}
8484
}
8585

Binary file not shown.
Binary file not shown.

MoproReactNativeBindings/cpp/generated/mopro_example_app.cpp

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ typedef void (*UniffiForeignFutureCompleteVoid)(
103103
RustBuffer uniffi_mopro_example_app_fn_func_generate_circom_proof(
104104
RustBuffer zkey_path, RustBuffer circuit_inputs, RustBuffer proof_lib,
105105
RustCallStatus *uniffi_out_err);
106+
RustBuffer uniffi_mopro_example_app_fn_func_generate_gnark_proof(
107+
RustBuffer _r1cs_path, RustBuffer _pk_path, RustBuffer _witness_json,
108+
RustCallStatus *uniffi_out_err);
106109
RustBuffer uniffi_mopro_example_app_fn_func_generate_halo2_proof(
107110
RustBuffer _srs_path, RustBuffer _pk_path, RustBuffer _circuit_inputs,
108111
RustCallStatus *uniffi_out_err);
@@ -118,6 +121,9 @@ RustBuffer uniffi_mopro_example_app_fn_func_mopro_hello_world(
118121
int8_t uniffi_mopro_example_app_fn_func_verify_circom_proof(
119122
RustBuffer zkey_path, RustBuffer proof_result, RustBuffer proof_lib,
120123
RustCallStatus *uniffi_out_err);
124+
int8_t uniffi_mopro_example_app_fn_func_verify_gnark_proof(
125+
RustBuffer _r1cs_path, RustBuffer _vk_path, RustBuffer _proof_result,
126+
RustCallStatus *uniffi_out_err);
121127
int8_t uniffi_mopro_example_app_fn_func_verify_halo2_proof(
122128
RustBuffer _srs_path, RustBuffer _vk_path, RustBuffer _proof,
123129
RustBuffer _public_input, RustCallStatus *uniffi_out_err);
@@ -253,11 +259,13 @@ void ffi_mopro_example_app_rust_future_free_void(
253259
void ffi_mopro_example_app_rust_future_complete_void(
254260
/*handle*/ uint64_t handle, RustCallStatus *uniffi_out_err);
255261
uint16_t uniffi_mopro_example_app_checksum_func_generate_circom_proof();
262+
uint16_t uniffi_mopro_example_app_checksum_func_generate_gnark_proof();
256263
uint16_t uniffi_mopro_example_app_checksum_func_generate_halo2_proof();
257264
uint16_t uniffi_mopro_example_app_checksum_func_generate_noir_proof();
258265
uint16_t uniffi_mopro_example_app_checksum_func_get_noir_verification_key();
259266
uint16_t uniffi_mopro_example_app_checksum_func_mopro_hello_world();
260267
uint16_t uniffi_mopro_example_app_checksum_func_verify_circom_proof();
268+
uint16_t uniffi_mopro_example_app_checksum_func_verify_gnark_proof();
261269
uint16_t uniffi_mopro_example_app_checksum_func_verify_halo2_proof();
262270
uint16_t uniffi_mopro_example_app_checksum_func_verify_noir_proof();
263271
uint32_t ffi_mopro_example_app_uniffi_contract_version();
@@ -1700,6 +1708,18 @@ NativeMoproExampleApp::NativeMoproExampleApp(
17001708
->cpp_uniffi_mopro_example_app_fn_func_generate_circom_proof(
17011709
rt, thisVal, args, count);
17021710
});
1711+
props["ubrn_uniffi_mopro_example_app_fn_func_generate_gnark_proof"] =
1712+
jsi::Function::createFromHostFunction(
1713+
rt,
1714+
jsi::PropNameID::forAscii(
1715+
rt, "ubrn_uniffi_mopro_example_app_fn_func_generate_gnark_proof"),
1716+
3,
1717+
[this](jsi::Runtime &rt, const jsi::Value &thisVal,
1718+
const jsi::Value *args, size_t count) -> jsi::Value {
1719+
return this
1720+
->cpp_uniffi_mopro_example_app_fn_func_generate_gnark_proof(
1721+
rt, thisVal, args, count);
1722+
});
17031723
props["ubrn_uniffi_mopro_example_app_fn_func_generate_halo2_proof"] =
17041724
jsi::Function::createFromHostFunction(
17051725
rt,
@@ -1759,6 +1779,18 @@ NativeMoproExampleApp::NativeMoproExampleApp(
17591779
->cpp_uniffi_mopro_example_app_fn_func_verify_circom_proof(
17601780
rt, thisVal, args, count);
17611781
});
1782+
props["ubrn_uniffi_mopro_example_app_fn_func_verify_gnark_proof"] =
1783+
jsi::Function::createFromHostFunction(
1784+
rt,
1785+
jsi::PropNameID::forAscii(
1786+
rt, "ubrn_uniffi_mopro_example_app_fn_func_verify_gnark_proof"),
1787+
3,
1788+
[this](jsi::Runtime &rt, const jsi::Value &thisVal,
1789+
const jsi::Value *args, size_t count) -> jsi::Value {
1790+
return this
1791+
->cpp_uniffi_mopro_example_app_fn_func_verify_gnark_proof(
1792+
rt, thisVal, args, count);
1793+
});
17621794
props["ubrn_uniffi_mopro_example_app_fn_func_verify_halo2_proof"] =
17631795
jsi::Function::createFromHostFunction(
17641796
rt,
@@ -1794,6 +1826,18 @@ NativeMoproExampleApp::NativeMoproExampleApp(
17941826
->cpp_uniffi_mopro_example_app_checksum_func_generate_circom_proof(
17951827
rt, thisVal, args, count);
17961828
});
1829+
props["ubrn_uniffi_mopro_example_app_checksum_func_generate_gnark_proof"] =
1830+
jsi::Function::createFromHostFunction(
1831+
rt,
1832+
jsi::PropNameID::forAscii(rt, "ubrn_uniffi_mopro_example_app_"
1833+
"checksum_func_generate_gnark_proof"),
1834+
0,
1835+
[this](jsi::Runtime &rt, const jsi::Value &thisVal,
1836+
const jsi::Value *args, size_t count) -> jsi::Value {
1837+
return this
1838+
->cpp_uniffi_mopro_example_app_checksum_func_generate_gnark_proof(
1839+
rt, thisVal, args, count);
1840+
});
17971841
props["ubrn_uniffi_mopro_example_app_checksum_func_generate_halo2_proof"] =
17981842
jsi::Function::createFromHostFunction(
17991843
rt,
@@ -1855,6 +1899,19 @@ NativeMoproExampleApp::NativeMoproExampleApp(
18551899
->cpp_uniffi_mopro_example_app_checksum_func_verify_circom_proof(
18561900
rt, thisVal, args, count);
18571901
});
1902+
props["ubrn_uniffi_mopro_example_app_checksum_func_verify_gnark_proof"] =
1903+
jsi::Function::createFromHostFunction(
1904+
rt,
1905+
jsi::PropNameID::forAscii(
1906+
rt,
1907+
"ubrn_uniffi_mopro_example_app_checksum_func_verify_gnark_proof"),
1908+
0,
1909+
[this](jsi::Runtime &rt, const jsi::Value &thisVal,
1910+
const jsi::Value *args, size_t count) -> jsi::Value {
1911+
return this
1912+
->cpp_uniffi_mopro_example_app_checksum_func_verify_gnark_proof(
1913+
rt, thisVal, args, count);
1914+
});
18581915
props["ubrn_uniffi_mopro_example_app_checksum_func_verify_halo2_proof"] =
18591916
jsi::Function::createFromHostFunction(
18601917
rt,
@@ -1980,6 +2037,26 @@ jsi::Value NativeMoproExampleApp::
19802037
return uniffi::mopro_example_app::Bridging<RustBuffer>::toJs(rt, callInvoker,
19812038
value);
19822039
}
2040+
jsi::Value NativeMoproExampleApp::
2041+
cpp_uniffi_mopro_example_app_fn_func_generate_gnark_proof(
2042+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
2043+
size_t count) {
2044+
RustCallStatus status =
2045+
uniffi::mopro_example_app::Bridging<RustCallStatus>::rustSuccess(rt);
2046+
auto value = uniffi_mopro_example_app_fn_func_generate_gnark_proof(
2047+
uniffi::mopro_example_app::Bridging<RustBuffer>::fromJs(rt, callInvoker,
2048+
args[0]),
2049+
uniffi::mopro_example_app::Bridging<RustBuffer>::fromJs(rt, callInvoker,
2050+
args[1]),
2051+
uniffi::mopro_example_app::Bridging<RustBuffer>::fromJs(rt, callInvoker,
2052+
args[2]),
2053+
&status);
2054+
uniffi::mopro_example_app::Bridging<RustCallStatus>::copyIntoJs(
2055+
rt, callInvoker, status, args[count - 1]);
2056+
2057+
return uniffi::mopro_example_app::Bridging<RustBuffer>::toJs(rt, callInvoker,
2058+
value);
2059+
}
19832060
jsi::Value NativeMoproExampleApp::
19842061
cpp_uniffi_mopro_example_app_fn_func_generate_halo2_proof(
19852062
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
@@ -2075,6 +2152,25 @@ NativeMoproExampleApp::cpp_uniffi_mopro_example_app_fn_func_verify_circom_proof(
20752152
return uniffi_jsi::Bridging<int8_t>::toJs(rt, callInvoker, value);
20762153
}
20772154
jsi::Value
2155+
NativeMoproExampleApp::cpp_uniffi_mopro_example_app_fn_func_verify_gnark_proof(
2156+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
2157+
size_t count) {
2158+
RustCallStatus status =
2159+
uniffi::mopro_example_app::Bridging<RustCallStatus>::rustSuccess(rt);
2160+
auto value = uniffi_mopro_example_app_fn_func_verify_gnark_proof(
2161+
uniffi::mopro_example_app::Bridging<RustBuffer>::fromJs(rt, callInvoker,
2162+
args[0]),
2163+
uniffi::mopro_example_app::Bridging<RustBuffer>::fromJs(rt, callInvoker,
2164+
args[1]),
2165+
uniffi::mopro_example_app::Bridging<RustBuffer>::fromJs(rt, callInvoker,
2166+
args[2]),
2167+
&status);
2168+
uniffi::mopro_example_app::Bridging<RustCallStatus>::copyIntoJs(
2169+
rt, callInvoker, status, args[count - 1]);
2170+
2171+
return uniffi_jsi::Bridging<int8_t>::toJs(rt, callInvoker, value);
2172+
}
2173+
jsi::Value
20782174
NativeMoproExampleApp::cpp_uniffi_mopro_example_app_fn_func_verify_halo2_proof(
20792175
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
20802176
size_t count) {
@@ -2123,6 +2219,14 @@ jsi::Value NativeMoproExampleApp::
21232219

21242220
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
21252221
}
2222+
jsi::Value NativeMoproExampleApp::
2223+
cpp_uniffi_mopro_example_app_checksum_func_generate_gnark_proof(
2224+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
2225+
size_t count) {
2226+
auto value = uniffi_mopro_example_app_checksum_func_generate_gnark_proof();
2227+
2228+
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
2229+
}
21262230
jsi::Value NativeMoproExampleApp::
21272231
cpp_uniffi_mopro_example_app_checksum_func_generate_halo2_proof(
21282232
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
@@ -2164,6 +2268,14 @@ jsi::Value NativeMoproExampleApp::
21642268

21652269
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
21662270
}
2271+
jsi::Value NativeMoproExampleApp::
2272+
cpp_uniffi_mopro_example_app_checksum_func_verify_gnark_proof(
2273+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
2274+
size_t count) {
2275+
auto value = uniffi_mopro_example_app_checksum_func_verify_gnark_proof();
2276+
2277+
return uniffi_jsi::Bridging<uint16_t>::toJs(rt, callInvoker, value);
2278+
}
21672279
jsi::Value NativeMoproExampleApp::
21682280
cpp_uniffi_mopro_example_app_checksum_func_verify_halo2_proof(
21692281
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,

MoproReactNativeBindings/cpp/generated/mopro_example_app.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class NativeMoproExampleApp : public jsi::HostObject {
3131
jsi::Value cpp_uniffi_mopro_example_app_fn_func_generate_circom_proof(
3232
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
3333
size_t count);
34+
jsi::Value cpp_uniffi_mopro_example_app_fn_func_generate_gnark_proof(
35+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
36+
size_t count);
3437
jsi::Value cpp_uniffi_mopro_example_app_fn_func_generate_halo2_proof(
3538
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
3639
size_t count);
@@ -46,6 +49,9 @@ class NativeMoproExampleApp : public jsi::HostObject {
4649
jsi::Value cpp_uniffi_mopro_example_app_fn_func_verify_circom_proof(
4750
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
4851
size_t count);
52+
jsi::Value cpp_uniffi_mopro_example_app_fn_func_verify_gnark_proof(
53+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
54+
size_t count);
4955
jsi::Value cpp_uniffi_mopro_example_app_fn_func_verify_halo2_proof(
5056
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
5157
size_t count);
@@ -55,6 +61,9 @@ class NativeMoproExampleApp : public jsi::HostObject {
5561
jsi::Value cpp_uniffi_mopro_example_app_checksum_func_generate_circom_proof(
5662
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
5763
size_t count);
64+
jsi::Value cpp_uniffi_mopro_example_app_checksum_func_generate_gnark_proof(
65+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
66+
size_t count);
5867
jsi::Value cpp_uniffi_mopro_example_app_checksum_func_generate_halo2_proof(
5968
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
6069
size_t count);
@@ -71,6 +80,9 @@ class NativeMoproExampleApp : public jsi::HostObject {
7180
jsi::Value cpp_uniffi_mopro_example_app_checksum_func_verify_circom_proof(
7281
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
7382
size_t count);
83+
jsi::Value cpp_uniffi_mopro_example_app_checksum_func_verify_gnark_proof(
84+
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
85+
size_t count);
7486
jsi::Value cpp_uniffi_mopro_example_app_checksum_func_verify_halo2_proof(
7587
jsi::Runtime &rt, const jsi::Value &thisVal, const jsi::Value *args,
7688
size_t count);

MoproReactNativeBindings/src/generated/mopro_example_app-ffi.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,23 @@ interface NativeModuleInterface {
1919
ubrn_uniffi_internal_fn_func_ffi__string_to_arraybuffer(string: string, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
2020
ubrn_uniffi_internal_fn_func_ffi__arraybuffer_to_string(buffer: Uint8Array, uniffi_out_err: UniffiRustCallStatus): string;
2121
ubrn_uniffi_mopro_example_app_fn_func_generate_circom_proof(zkeyPath: Uint8Array, circuitInputs: Uint8Array, proofLib: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
22+
ubrn_uniffi_mopro_example_app_fn_func_generate_gnark_proof(r1csPath: Uint8Array, pkPath: Uint8Array, witnessJson: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
2223
ubrn_uniffi_mopro_example_app_fn_func_generate_halo2_proof(srsPath: Uint8Array, pkPath: Uint8Array, circuitInputs: Uint8Array, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
2324
ubrn_uniffi_mopro_example_app_fn_func_generate_noir_proof(circuitPath: Uint8Array, srsPath: Uint8Array, inputs: Uint8Array, onChain: number, vk: Uint8Array, lowMemoryMode: number, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
2425
ubrn_uniffi_mopro_example_app_fn_func_get_noir_verification_key(circuitPath: Uint8Array, srsPath: Uint8Array, onChain: number, lowMemoryMode: number, uniffi_out_err: UniffiRustCallStatus): Uint8Array;
2526
ubrn_uniffi_mopro_example_app_fn_func_mopro_hello_world(uniffi_out_err: UniffiRustCallStatus): Uint8Array;
2627
ubrn_uniffi_mopro_example_app_fn_func_verify_circom_proof(zkeyPath: Uint8Array, proofResult: Uint8Array, proofLib: Uint8Array, uniffi_out_err: UniffiRustCallStatus): number;
28+
ubrn_uniffi_mopro_example_app_fn_func_verify_gnark_proof(r1csPath: Uint8Array, vkPath: Uint8Array, proofResult: Uint8Array, uniffi_out_err: UniffiRustCallStatus): number;
2729
ubrn_uniffi_mopro_example_app_fn_func_verify_halo2_proof(srsPath: Uint8Array, vkPath: Uint8Array, proof: Uint8Array, publicInput: Uint8Array, uniffi_out_err: UniffiRustCallStatus): number;
2830
ubrn_uniffi_mopro_example_app_fn_func_verify_noir_proof(circuitPath: Uint8Array, proof: Uint8Array, onChain: number, vk: Uint8Array, lowMemoryMode: number, uniffi_out_err: UniffiRustCallStatus): number;
2931
ubrn_uniffi_mopro_example_app_checksum_func_generate_circom_proof(): number;
32+
ubrn_uniffi_mopro_example_app_checksum_func_generate_gnark_proof(): number;
3033
ubrn_uniffi_mopro_example_app_checksum_func_generate_halo2_proof(): number;
3134
ubrn_uniffi_mopro_example_app_checksum_func_generate_noir_proof(): number;
3235
ubrn_uniffi_mopro_example_app_checksum_func_get_noir_verification_key(): number;
3336
ubrn_uniffi_mopro_example_app_checksum_func_mopro_hello_world(): number;
3437
ubrn_uniffi_mopro_example_app_checksum_func_verify_circom_proof(): number;
38+
ubrn_uniffi_mopro_example_app_checksum_func_verify_gnark_proof(): number;
3539
ubrn_uniffi_mopro_example_app_checksum_func_verify_halo2_proof(): number;
3640
ubrn_uniffi_mopro_example_app_checksum_func_verify_noir_proof(): number;
3741
ubrn_ffi_mopro_example_app_uniffi_contract_version(): number;

0 commit comments

Comments
 (0)