Skip to content

Commit

Permalink
Merge pull request #10 from iden3/feature/exceptions_groth16_prover_z…
Browse files Browse the repository at this point in the history
…key_file

Exceptions + mmap + groth16_prover_zkey_file
  • Loading branch information
OBrezhniev authored Feb 6, 2024
2 parents 5af1b04 + 01518a8 commit 97c309c
Show file tree
Hide file tree
Showing 10 changed files with 222 additions and 59 deletions.
105 changes: 84 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ jobs:

- name: Build prover Android ARM64
run: |
mkdir build_prover_android && cd build_prover_android
mkdir -p build_prover_android && cd build_prover_android
cmake .. -DTARGET_PLATFORM=ANDROID -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_android
make -j4 && make install
- name: Build prover Android x86_64
run: |
mkdir build_prover_android_x86_64 && cd build_prover_android_x86_64
mkdir -p build_prover_android_x86_64 && cd build_prover_android_x86_64
cmake .. -DTARGET_PLATFORM=ANDROID_x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_android_x86_64
make -j4 && make install
- name: Build prover Linux
run: |
mkdir build_prover && cd build_prover
mkdir -p build_prover && cd build_prover
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package
make -j4 && make install
Expand All @@ -65,35 +65,62 @@ jobs:
package/bin/prover testdata/circuit_final.zkey testdata/witness.wtns proof.json public.json
snarkjs groth16 verify testdata/verification_key.json public.json proof.json
- name: upload Android ARM64 artifacts
- name: upload Linux amd64 dev artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v3
with:
name: rapidsnark-linux-amd64
path: |
package
if-no-files-found: error

- name: upload Android dev artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v3
with:
name: rapidsnark-Android
path: |
package_android
if-no-files-found: error

- name: upload Android x86_64 dev artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v3
with:
name: rapidsnark-Android-x86_64
path: |
package_android_x86_64
if-no-files-found: error

- name: upload Android ARM64 release artifacts
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -x
mkdir rapidsnark-android-arm64-${{ github.ref_name }}
mkdir -p rapidsnark-android-arm64-${{ github.ref_name }}
cp -r package_android/* rapidsnark-android-arm64-${{ github.ref_name }}/
zip -r rapidsnark-android-arm64-${{ github.ref_name }}.zip rapidsnark-android-arm64-${{ github.ref_name }}
gh release upload ${{ github.event.release.tag_name }} rapidsnark-android-arm64-${{ github.ref_name }}.zip
- name: upload Android x86_64 artifacts
- name: upload Android x86_64 release artifacts
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -x
mkdir rapidsnark-android-x86_64-${{ github.ref_name }}
mkdir -p rapidsnark-android-x86_64-${{ github.ref_name }}
cp -r package_android_x86_64/* rapidsnark-android-x86_64-${{ github.ref_name }}/
zip -r rapidsnark-android-x86_64-${{ github.ref_name }}.zip rapidsnark-android-x86_64-${{ github.ref_name }}
gh release upload ${{ github.event.release.tag_name }} rapidsnark-android-x86_64-${{ github.ref_name }}.zip
- name: upload Linux x86_64 artifacts
- name: upload Linux x86_64 release artifacts
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -x
mkdir rapidsnark-linux-x86_64-${{ github.ref_name }}
mkdir -p rapidsnark-linux-x86_64-${{ github.ref_name }}
cp -r package/* rapidsnark-linux-x86_64-${{ github.ref_name }}/
zip -r rapidsnark-linux-x86_64-${{ github.ref_name }}.zip rapidsnark-linux-x86_64-${{ github.ref_name }}
gh release upload ${{ github.event.release.tag_name }} rapidsnark-linux-x86_64-${{ github.ref_name }}.zip
Expand All @@ -119,19 +146,19 @@ jobs:
if [[ ! -d "depends/gmp/package_iphone_simulator" ]]; then ./build_gmp.sh ios_simulator; fi
if [[ ! -d "depends/gmp/package_macos_arm64" ]]; then ./build_gmp.sh macos_arm64; fi
mkdir build_prover_ios && cd build_prover_ios
mkdir -p build_prover_ios && cd build_prover_ios
cmake .. -GXcode -DTARGET_PLATFORM=IOS -DCMAKE_INSTALL_PREFIX=../package_ios
xcodebuild -destination 'generic/platform=iOS' -scheme rapidsnarkStatic -project rapidsnark.xcodeproj -configuration Release
cp ../depends/gmp/package_ios_arm64/lib/libgmp.a src/Release-iphoneos
cd ../
mkdir build_prover_ios_simulator && cd build_prover_ios_simulator
mkdir -p build_prover_ios_simulator && cd build_prover_ios_simulator
cmake .. -GXcode -DTARGET_PLATFORM=IOS -DCMAKE_INSTALL_PREFIX=../package_ios_simulator -DUSE_ASM=NO
xcodebuild -destination 'generic/platform=iOS Simulator' -scheme rapidsnarkStatic -project rapidsnark.xcodeproj
cp ../depends/gmp/package_iphone_simulator/lib/libgmp.a src/Debug-iphonesimulator
cd ../
mkdir build_prover_macos_arm64 && cd build_prover_macos_arm64
mkdir -p build_prover_macos_arm64 && cd build_prover_macos_arm64
cmake .. -DTARGET_PLATFORM=macos_arm64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_macos_arm64
make -j4 && make install
Expand All @@ -143,35 +170,62 @@ jobs:
package_macos_arm64/bin/prover testdata/circuit_final.zkey testdata/witness.wtns proof.json public.json
snarkjs groth16 verify testdata/verification_key.json public.json proof.json
- name: upload iOS artifacts
- name: upload macOS arm64 dev artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v3
with:
name: rapidsnark-macOS-arm64
path: |
package_macos_arm64
if-no-files-found: error

- name: upload iOS dev artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v3
with:
name: rapidsnark-iOS
path: |
build_prover_ios/src/Release-iphoneos
if-no-files-found: error

- name: upload iOS Simulator dev artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v3
with:
name: rapidsnark-iOS-Simulator
path: |
build_prover_ios_simulator/src/Debug-iphonesimulator
if-no-files-found: error

- name: upload iOS release artifacts
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -x
mkdir rapidsnark-iOS-${{ github.ref_name }}
mkdir -p rapidsnark-iOS-${{ github.ref_name }}
cp -r build_prover_ios/src/Release-iphoneos/* rapidsnark-iOS-${{ github.ref_name }}/
zip -r rapidsnark-iOS-${{ github.ref_name }}.zip rapidsnark-iOS-${{ github.ref_name }}
gh release upload ${{ github.event.release.tag_name }} rapidsnark-iOS-${{ github.ref_name }}.zip
- name: upload iOS Simulator artifacts
- name: upload iOS Simulator release artifacts
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -x
mkdir rapidsnark-iOS-Simulator-${{ github.ref_name }}
mkdir -p rapidsnark-iOS-Simulator-${{ github.ref_name }}
cp -r build_prover_ios_simulator/src/Debug-iphonesimulator/* rapidsnark-iOS-Simulator-${{ github.ref_name }}/
zip -r rapidsnark-iOS-Simulator-${{ github.ref_name }}.zip rapidsnark-iOS-Simulator-${{ github.ref_name }}
gh release upload ${{ github.event.release.tag_name }} rapidsnark-iOS-Simulator-${{ github.ref_name }}.zip
- name: upload macOS arm64 artifacts
- name: upload macOS arm64 release artifacts
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -x
mkdir rapidsnark-macOS-arm64-${{ github.ref_name }}
mkdir -p rapidsnark-macOS-arm64-${{ github.ref_name }}
cp -r package_macos_arm64/* rapidsnark-macOS-arm64-${{ github.ref_name }}/
zip -r rapidsnark-macOS-arm64-${{ github.ref_name }}.zip rapidsnark-macOS-arm64-${{ github.ref_name }}
gh release upload ${{ github.event.release.tag_name }} rapidsnark-macOS-arm64-${{ github.ref_name }}.zip
Expand Down Expand Up @@ -199,7 +253,7 @@ jobs:
run: |
if [[ ! -d "depends/gmp/package_macos_x86_64" ]]; then ./build_gmp.sh macos_x86_64; fi
mkdir build_prover_macos_x86_64 && cd build_prover_macos_x86_64
mkdir -p build_prover_macos_x86_64 && cd build_prover_macos_x86_64
cmake .. -DTARGET_PLATFORM=macos_x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_macos_x86_64
make -j4 && make install
Expand All @@ -211,13 +265,22 @@ jobs:
package_macos_x86_64/bin/prover testdata/circuit_final.zkey testdata/witness.wtns proof.json public.json
snarkjs groth16 verify testdata/verification_key.json public.json proof.json
- name: upload macOS x86_64 artifacts
- name: upload macOS x86_64 dev artifacts
if: github.event_name != 'release'
uses: actions/upload-artifact@v3
with:
name: rapidsnark-macOS-x86_64
path: |
package_macos_x86_64
if-no-files-found: error

- name: upload macOS x86_64 release artifacts
if: github.event_name == 'release'
env:
GH_TOKEN: ${{ github.token }}
run: |
set -x
mkdir rapidsnark-macOS-x86_64-${{ github.ref_name }}
mkdir -p rapidsnark-macOS-x86_64-${{ github.ref_name }}
cp -r package_macos_x86_64/* rapidsnark-macOS-x86_64-${{ github.ref_name }}/
zip -r rapidsnark-macOS-x86_64-${{ github.ref_name }}.zip rapidsnark-macOS-x86_64-${{ github.ref_name }}
gh release upload ${{ github.event.release.tag_name }} rapidsnark-macOS-x86_64-${{ github.ref_name }}.zip
4 changes: 2 additions & 2 deletions build/fq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
#include <assert.h>
#include <string>
#include <stdexcept>


static mpz_t q;
Expand Down Expand Up @@ -162,7 +162,7 @@ void Fq_div(PFqElement r, PFqElement a, PFqElement b) {
}

void Fq_fail() {
assert(false);
throw std::runtime_error("Fq error");
}

void Fq_longErr()
Expand Down
1 change: 0 additions & 1 deletion build/fq_generic.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "fq.hpp"
#include <cstdint>
#include <cstring>
#include <cassert>

FqElement Fq_q = {0, 0x80000000, {0x3c208c16d87cfd47,0x97816a916871ca8d,0xb85045b68181585d,0x30644e72e131a029}};
FqElement Fq_R2 = {0, 0x80000000, {0xf32cfc5b538afa89,0xb5e71911d44501fb,0x47ab1eff0a417ff6,0x06d89f71cab8351f}};
Expand Down
4 changes: 2 additions & 2 deletions build/fr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
#include <assert.h>
#include <string>
#include <stdexcept>


static mpz_t q;
Expand Down Expand Up @@ -162,7 +162,7 @@ void Fr_div(PFrElement r, PFrElement a, PFrElement b) {
}

void Fr_fail() {
assert(false);
throw std::runtime_error("Fr error");
}

void Fr_longErr()
Expand Down
1 change: 0 additions & 1 deletion build/fr_generic.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "fr.hpp"
#include <cstdint>
#include <cstring>
#include <cassert>

FrElement Fr_q = {0, 0x80000000, {0x43e1f593f0000001,0x2833e84879b97091,0xb85045b68181585d,0x30644e72e131a029}};
FrElement Fr_R2 = {0, 0x80000000, {0x1bb8e645ae216da7,0x53fe3ab1e35c59e3,0x8c49833d53bb8085,0x0216d0b17f4e44a5}};
Expand Down
Loading

0 comments on commit 97c309c

Please sign in to comment.