Skip to content

Commit 97c309c

Browse files
authored
Merge pull request #10 from iden3/feature/exceptions_groth16_prover_zkey_file
Exceptions + mmap + groth16_prover_zkey_file
2 parents 5af1b04 + 01518a8 commit 97c309c

10 files changed

+222
-59
lines changed

.github/workflows/build.yml

+84-21
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ jobs:
4141

4242
- name: Build prover Android ARM64
4343
run: |
44-
mkdir build_prover_android && cd build_prover_android
44+
mkdir -p build_prover_android && cd build_prover_android
4545
cmake .. -DTARGET_PLATFORM=ANDROID -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_android
4646
make -j4 && make install
4747
4848
- name: Build prover Android x86_64
4949
run: |
50-
mkdir build_prover_android_x86_64 && cd build_prover_android_x86_64
50+
mkdir -p build_prover_android_x86_64 && cd build_prover_android_x86_64
5151
cmake .. -DTARGET_PLATFORM=ANDROID_x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_android_x86_64
5252
make -j4 && make install
5353
5454
- name: Build prover Linux
5555
run: |
56-
mkdir build_prover && cd build_prover
56+
mkdir -p build_prover && cd build_prover
5757
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package
5858
make -j4 && make install
5959
@@ -65,35 +65,62 @@ jobs:
6565
package/bin/prover testdata/circuit_final.zkey testdata/witness.wtns proof.json public.json
6666
snarkjs groth16 verify testdata/verification_key.json public.json proof.json
6767
68-
- name: upload Android ARM64 artifacts
68+
- name: upload Linux amd64 dev artifacts
69+
if: github.event_name != 'release'
70+
uses: actions/upload-artifact@v3
71+
with:
72+
name: rapidsnark-linux-amd64
73+
path: |
74+
package
75+
if-no-files-found: error
76+
77+
- name: upload Android dev artifacts
78+
if: github.event_name != 'release'
79+
uses: actions/upload-artifact@v3
80+
with:
81+
name: rapidsnark-Android
82+
path: |
83+
package_android
84+
if-no-files-found: error
85+
86+
- name: upload Android x86_64 dev artifacts
87+
if: github.event_name != 'release'
88+
uses: actions/upload-artifact@v3
89+
with:
90+
name: rapidsnark-Android-x86_64
91+
path: |
92+
package_android_x86_64
93+
if-no-files-found: error
94+
95+
- name: upload Android ARM64 release artifacts
6996
if: github.event_name == 'release'
7097
env:
7198
GH_TOKEN: ${{ github.token }}
7299
run: |
73100
set -x
74-
mkdir rapidsnark-android-arm64-${{ github.ref_name }}
101+
mkdir -p rapidsnark-android-arm64-${{ github.ref_name }}
75102
cp -r package_android/* rapidsnark-android-arm64-${{ github.ref_name }}/
76103
zip -r rapidsnark-android-arm64-${{ github.ref_name }}.zip rapidsnark-android-arm64-${{ github.ref_name }}
77104
gh release upload ${{ github.event.release.tag_name }} rapidsnark-android-arm64-${{ github.ref_name }}.zip
78105
79-
- name: upload Android x86_64 artifacts
106+
- name: upload Android x86_64 release artifacts
80107
if: github.event_name == 'release'
81108
env:
82109
GH_TOKEN: ${{ github.token }}
83110
run: |
84111
set -x
85-
mkdir rapidsnark-android-x86_64-${{ github.ref_name }}
112+
mkdir -p rapidsnark-android-x86_64-${{ github.ref_name }}
86113
cp -r package_android_x86_64/* rapidsnark-android-x86_64-${{ github.ref_name }}/
87114
zip -r rapidsnark-android-x86_64-${{ github.ref_name }}.zip rapidsnark-android-x86_64-${{ github.ref_name }}
88115
gh release upload ${{ github.event.release.tag_name }} rapidsnark-android-x86_64-${{ github.ref_name }}.zip
89116
90-
- name: upload Linux x86_64 artifacts
117+
- name: upload Linux x86_64 release artifacts
91118
if: github.event_name == 'release'
92119
env:
93120
GH_TOKEN: ${{ github.token }}
94121
run: |
95122
set -x
96-
mkdir rapidsnark-linux-x86_64-${{ github.ref_name }}
123+
mkdir -p rapidsnark-linux-x86_64-${{ github.ref_name }}
97124
cp -r package/* rapidsnark-linux-x86_64-${{ github.ref_name }}/
98125
zip -r rapidsnark-linux-x86_64-${{ github.ref_name }}.zip rapidsnark-linux-x86_64-${{ github.ref_name }}
99126
gh release upload ${{ github.event.release.tag_name }} rapidsnark-linux-x86_64-${{ github.ref_name }}.zip
@@ -119,19 +146,19 @@ jobs:
119146
if [[ ! -d "depends/gmp/package_iphone_simulator" ]]; then ./build_gmp.sh ios_simulator; fi
120147
if [[ ! -d "depends/gmp/package_macos_arm64" ]]; then ./build_gmp.sh macos_arm64; fi
121148
122-
mkdir build_prover_ios && cd build_prover_ios
149+
mkdir -p build_prover_ios && cd build_prover_ios
123150
cmake .. -GXcode -DTARGET_PLATFORM=IOS -DCMAKE_INSTALL_PREFIX=../package_ios
124151
xcodebuild -destination 'generic/platform=iOS' -scheme rapidsnarkStatic -project rapidsnark.xcodeproj -configuration Release
125152
cp ../depends/gmp/package_ios_arm64/lib/libgmp.a src/Release-iphoneos
126153
cd ../
127154
128-
mkdir build_prover_ios_simulator && cd build_prover_ios_simulator
155+
mkdir -p build_prover_ios_simulator && cd build_prover_ios_simulator
129156
cmake .. -GXcode -DTARGET_PLATFORM=IOS -DCMAKE_INSTALL_PREFIX=../package_ios_simulator -DUSE_ASM=NO
130157
xcodebuild -destination 'generic/platform=iOS Simulator' -scheme rapidsnarkStatic -project rapidsnark.xcodeproj
131158
cp ../depends/gmp/package_iphone_simulator/lib/libgmp.a src/Debug-iphonesimulator
132159
cd ../
133160
134-
mkdir build_prover_macos_arm64 && cd build_prover_macos_arm64
161+
mkdir -p build_prover_macos_arm64 && cd build_prover_macos_arm64
135162
cmake .. -DTARGET_PLATFORM=macos_arm64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_macos_arm64
136163
make -j4 && make install
137164
@@ -143,35 +170,62 @@ jobs:
143170
package_macos_arm64/bin/prover testdata/circuit_final.zkey testdata/witness.wtns proof.json public.json
144171
snarkjs groth16 verify testdata/verification_key.json public.json proof.json
145172
146-
- name: upload iOS artifacts
173+
- name: upload macOS arm64 dev artifacts
174+
if: github.event_name != 'release'
175+
uses: actions/upload-artifact@v3
176+
with:
177+
name: rapidsnark-macOS-arm64
178+
path: |
179+
package_macos_arm64
180+
if-no-files-found: error
181+
182+
- name: upload iOS dev artifacts
183+
if: github.event_name != 'release'
184+
uses: actions/upload-artifact@v3
185+
with:
186+
name: rapidsnark-iOS
187+
path: |
188+
build_prover_ios/src/Release-iphoneos
189+
if-no-files-found: error
190+
191+
- name: upload iOS Simulator dev artifacts
192+
if: github.event_name != 'release'
193+
uses: actions/upload-artifact@v3
194+
with:
195+
name: rapidsnark-iOS-Simulator
196+
path: |
197+
build_prover_ios_simulator/src/Debug-iphonesimulator
198+
if-no-files-found: error
199+
200+
- name: upload iOS release artifacts
147201
if: github.event_name == 'release'
148202
env:
149203
GH_TOKEN: ${{ github.token }}
150204
run: |
151205
set -x
152-
mkdir rapidsnark-iOS-${{ github.ref_name }}
206+
mkdir -p rapidsnark-iOS-${{ github.ref_name }}
153207
cp -r build_prover_ios/src/Release-iphoneos/* rapidsnark-iOS-${{ github.ref_name }}/
154208
zip -r rapidsnark-iOS-${{ github.ref_name }}.zip rapidsnark-iOS-${{ github.ref_name }}
155209
gh release upload ${{ github.event.release.tag_name }} rapidsnark-iOS-${{ github.ref_name }}.zip
156210
157-
- name: upload iOS Simulator artifacts
211+
- name: upload iOS Simulator release artifacts
158212
if: github.event_name == 'release'
159213
env:
160214
GH_TOKEN: ${{ github.token }}
161215
run: |
162216
set -x
163-
mkdir rapidsnark-iOS-Simulator-${{ github.ref_name }}
217+
mkdir -p rapidsnark-iOS-Simulator-${{ github.ref_name }}
164218
cp -r build_prover_ios_simulator/src/Debug-iphonesimulator/* rapidsnark-iOS-Simulator-${{ github.ref_name }}/
165219
zip -r rapidsnark-iOS-Simulator-${{ github.ref_name }}.zip rapidsnark-iOS-Simulator-${{ github.ref_name }}
166220
gh release upload ${{ github.event.release.tag_name }} rapidsnark-iOS-Simulator-${{ github.ref_name }}.zip
167221
168-
- name: upload macOS arm64 artifacts
222+
- name: upload macOS arm64 release artifacts
169223
if: github.event_name == 'release'
170224
env:
171225
GH_TOKEN: ${{ github.token }}
172226
run: |
173227
set -x
174-
mkdir rapidsnark-macOS-arm64-${{ github.ref_name }}
228+
mkdir -p rapidsnark-macOS-arm64-${{ github.ref_name }}
175229
cp -r package_macos_arm64/* rapidsnark-macOS-arm64-${{ github.ref_name }}/
176230
zip -r rapidsnark-macOS-arm64-${{ github.ref_name }}.zip rapidsnark-macOS-arm64-${{ github.ref_name }}
177231
gh release upload ${{ github.event.release.tag_name }} rapidsnark-macOS-arm64-${{ github.ref_name }}.zip
@@ -199,7 +253,7 @@ jobs:
199253
run: |
200254
if [[ ! -d "depends/gmp/package_macos_x86_64" ]]; then ./build_gmp.sh macos_x86_64; fi
201255
202-
mkdir build_prover_macos_x86_64 && cd build_prover_macos_x86_64
256+
mkdir -p build_prover_macos_x86_64 && cd build_prover_macos_x86_64
203257
cmake .. -DTARGET_PLATFORM=macos_x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_macos_x86_64
204258
make -j4 && make install
205259
@@ -211,13 +265,22 @@ jobs:
211265
package_macos_x86_64/bin/prover testdata/circuit_final.zkey testdata/witness.wtns proof.json public.json
212266
snarkjs groth16 verify testdata/verification_key.json public.json proof.json
213267
214-
- name: upload macOS x86_64 artifacts
268+
- name: upload macOS x86_64 dev artifacts
269+
if: github.event_name != 'release'
270+
uses: actions/upload-artifact@v3
271+
with:
272+
name: rapidsnark-macOS-x86_64
273+
path: |
274+
package_macos_x86_64
275+
if-no-files-found: error
276+
277+
- name: upload macOS x86_64 release artifacts
215278
if: github.event_name == 'release'
216279
env:
217280
GH_TOKEN: ${{ github.token }}
218281
run: |
219282
set -x
220-
mkdir rapidsnark-macOS-x86_64-${{ github.ref_name }}
283+
mkdir -p rapidsnark-macOS-x86_64-${{ github.ref_name }}
221284
cp -r package_macos_x86_64/* rapidsnark-macOS-x86_64-${{ github.ref_name }}/
222285
zip -r rapidsnark-macOS-x86_64-${{ github.ref_name }}.zip rapidsnark-macOS-x86_64-${{ github.ref_name }}
223286
gh release upload ${{ github.event.release.tag_name }} rapidsnark-macOS-x86_64-${{ github.ref_name }}.zip

build/fq.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#include <stdio.h>
33
#include <stdlib.h>
44
#include <gmp.h>
5-
#include <assert.h>
65
#include <string>
6+
#include <stdexcept>
77

88

99
static mpz_t q;
@@ -162,7 +162,7 @@ void Fq_div(PFqElement r, PFqElement a, PFqElement b) {
162162
}
163163

164164
void Fq_fail() {
165-
assert(false);
165+
throw std::runtime_error("Fq error");
166166
}
167167

168168
void Fq_longErr()

build/fq_generic.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "fq.hpp"
22
#include <cstdint>
33
#include <cstring>
4-
#include <cassert>
54

65
FqElement Fq_q = {0, 0x80000000, {0x3c208c16d87cfd47,0x97816a916871ca8d,0xb85045b68181585d,0x30644e72e131a029}};
76
FqElement Fq_R2 = {0, 0x80000000, {0xf32cfc5b538afa89,0xb5e71911d44501fb,0x47ab1eff0a417ff6,0x06d89f71cab8351f}};

build/fr.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#include <stdio.h>
33
#include <stdlib.h>
44
#include <gmp.h>
5-
#include <assert.h>
65
#include <string>
6+
#include <stdexcept>
77

88

99
static mpz_t q;
@@ -162,7 +162,7 @@ void Fr_div(PFrElement r, PFrElement a, PFrElement b) {
162162
}
163163

164164
void Fr_fail() {
165-
assert(false);
165+
throw std::runtime_error("Fr error");
166166
}
167167

168168
void Fr_longErr()

build/fr_generic.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#include "fr.hpp"
22
#include <cstdint>
33
#include <cstring>
4-
#include <cassert>
54

65
FrElement Fr_q = {0, 0x80000000, {0x43e1f593f0000001,0x2833e84879b97091,0xb85045b68181585d,0x30644e72e131a029}};
76
FrElement Fr_R2 = {0, 0x80000000, {0x1bb8e645ae216da7,0x53fe3ab1e35c59e3,0x8c49833d53bb8085,0x0216d0b17f4e44a5}};

0 commit comments

Comments
 (0)