@@ -8,55 +8,55 @@ You should have installed gcc, cmake, libsodium, and gmp (development)
8
8
9
9
In ubuntu:
10
10
11
- ````
11
+ ```
12
12
sudo apt-get install build-essential cmake libgmp-dev libsodium-dev nasm curl m4
13
- ````
13
+ ```
14
14
15
15
## Compile prover in standalone mode
16
16
17
17
### Compile prover for x86_64 host machine
18
18
19
- ```` sh
19
+ ``` sh
20
20
git submodule init
21
21
git submodule update
22
22
./build_gmp.sh host
23
23
mkdir build_prover && cd build_prover
24
24
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package
25
25
make -j4 && make install
26
- ````
26
+ ```
27
27
28
28
### Compile prover for macOS arm64 host machine
29
29
30
- ```` sh
30
+ ``` sh
31
31
git submodule init
32
32
git submodule update
33
33
./build_gmp.sh host_noasm
34
34
mkdir build_prover && cd build_prover
35
35
cmake .. -DTARGET_PLATFORM=arm64_host -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package
36
36
make -j4 && make install
37
- ````
37
+ ```
38
38
39
39
### Compile prover for linux arm64 host machine
40
40
41
- ```` sh
41
+ ``` sh
42
42
git submodule init
43
43
git submodule update
44
44
./build_gmp.sh host
45
45
mkdir build_prover && cd build_prover
46
46
cmake .. -DTARGET_PLATFORM=arm64_host -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package
47
47
make -j4 && make install
48
- ````
48
+ ```
49
49
50
50
### Compile prover for linux arm64 machine
51
51
52
- ```` sh
52
+ ``` sh
53
53
git submodule init
54
54
git submodule update
55
55
./build_gmp.sh host
56
56
mkdir build_prover && cd build_prover
57
57
cmake .. -DTARGET_PLATFORM=aarch64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_aarch64
58
58
make -j4 && make install
59
- ````
59
+ ```
60
60
61
61
### Compile prover for Android
62
62
@@ -66,10 +66,10 @@ Set the value of ANDROID_NDK environment variable to the absolute path of Androi
66
66
67
67
Examples:
68
68
69
- ```` sh
69
+ ``` sh
70
70
export ANDROID_NDK=/home/test/Android/Sdk/ndk/23.1.7779620 # NDK is installed by "SDK Manager" in Android Studio.
71
71
export ANDROID_NDK=/home/test/android-ndk-r23b # NDK is installed as a stand-alone package.
72
- ````
72
+ ```
73
73
74
74
Prerequisites if build on Ubuntu:
75
75
@@ -79,82 +79,86 @@ apt-get install curl xz-utils build-essential cmake m4 nasm
79
79
80
80
Compilation:
81
81
82
- ```` sh
82
+ ``` sh
83
83
git submodule init
84
84
git submodule update
85
85
./build_gmp.sh android
86
86
mkdir build_prover_android && cd build_prover_android
87
87
cmake .. -DTARGET_PLATFORM=ANDROID -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_android
88
88
make -j4 && make install
89
- ````
89
+ ```
90
90
91
91
### Compile prover for iOS
92
92
93
93
Install Xcode & homebrew.
94
94
95
- ```` sh
96
- brew install libomp
95
+ ``` sh
97
96
git submodule init
98
97
git submodule update
99
98
./build_gmp.sh ios
100
99
mkdir build_prover_ios && cd build_prover_ios
101
100
cmake .. -GXcode -DTARGET_PLATFORM=IOS -DCMAKE_INSTALL_PREFIX=../package_ios
102
101
xcodebuild -destination ' generic/platform=iOS' -scheme rapidsnarkStatic -project rapidsnark.xcodeproj -configuration Release
103
- ````
102
+ ```
104
103
Open generated Xcode project and compile prover.
105
104
106
105
## Build for iOS emulator
107
106
108
107
Install Xcode & homebrew.
109
108
110
- ```` sh
111
- brew install libomp
109
+ ``` sh
112
110
git submodule init
113
111
git submodule update
114
- ./build_gmp.sh ios
112
+ ./build_gmp.sh ios_simulator
115
113
mkdir build_prover_ios_simulator && cd build_prover_ios_simulator
116
114
cmake .. -GXcode -DTARGET_PLATFORM=IOS -DCMAKE_INSTALL_PREFIX=../package_ios_simulator -DUSE_ASM=NO
117
115
xcodebuild -destination ' generic/platform=iOS Simulator' -scheme rapidsnarkStatic -project rapidsnark.xcodeproj
118
- ````
116
+ ```
117
+
118
+ Files that you need to copy to your XCode project to link against Rapidsnark:
119
+ * build_prover_ios_simulator/src/Debug-iphonesimulator/librapidsnark.a
120
+ * build_prover_ios_simulator/src/Debug-iphonesimulator/libfq.a
121
+ * build_prover_ios_simulator/src/Debug-iphonesimulator/libfr.a
122
+ * depends/gmp/package_iphone_simulator/lib/libgmp.a
119
123
120
124
## Building proof
121
125
122
126
You have a full prover compiled in the build directory.
123
127
124
128
So you can replace snarkjs command:
125
129
126
- ```` sh
130
+ ``` sh
127
131
snarkjs groth16 prove < circuit.zkey> < witness.wtns> < proof.json> < public.json>
128
- ````
132
+ ```
129
133
130
134
by this one
131
- ```` sh
135
+ ``` sh
132
136
./package/bin/prover < circuit.zkey> < witness.wtns> < proof.json> < public.json>
133
- ````
137
+ ```
134
138
135
139
## Compile prover in server mode
136
140
137
- ```` sh
141
+ ``` sh
138
142
npm install
139
143
git submodule init
140
144
git submodule update
141
145
npx task createFieldSources
142
146
npx task buildPistache
143
147
npx task buildProverServer
144
- ````
148
+ ```
145
149
146
150
## Launch prover in server mode
147
- ```` sh
151
+ ``` sh
148
152
./build/proverServer < port> < circuit1_zkey> < circuit2_zkey> ... < circuitN_zkey>
149
- ````
153
+ ```
150
154
151
155
For every ` circuit.circom ` you have to generate with circom with --c option the ` circuit_cpp ` and after compilation you have to copy the executable into the ` build ` folder so the server can generate the witness and then the proof based on this witness.
152
156
You have an example of the usage calling the server endpoints to generate the proof with Nodejs in ` /tools/request.js ` .
153
157
154
158
To test a request you should pass an ` input.json ` as a parameter to the request call.
155
- ```` sh
159
+ ``` sh
156
160
node tools/request.js < input.json> < circuit>
157
- ````
161
+ ```
158
162
159
163
## Benchmark
160
164
0 commit comments