diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..520cf7e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,192 @@ +name: Build + +on: + push: + branches: + - main + - cibuild + +jobs: + build-linux: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: install requirements + uses: awalsh128/cache-apt-pkgs-action@v1 + with: + packages: curl xz-utils build-essential cmake m4 nasm + version: 1.0 + + - name: Cache gmp build + uses: actions/cache@v3 + with: + path: | + depends/gmp + depends/gmp-6.2.1.tar.xz + key: ${{ runner.os }}-gmp-${{ hashFiles('build_gmp.sh') }}-2 + + - name: build gmp android arm64 + run: if [[ ! -d "depends/gmp/package_android_arm64" ]]; then ./build_gmp.sh android; fi + + - name: build gmp android x86_64 + run: if [[ ! -d "depends/gmp/package_android_x86_64" ]]; then ./build_gmp.sh android_x86_64; fi + + - name: build gmp android x86_64 + run: if [[ ! -d "depends/gmp/package" ]]; then ./build_gmp.sh host; fi + + - name: Build prover Android ARM64 + run: | + mkdir 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 + 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 + cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package + make -j4 && make install + + - name: upload Android ARM64 artifacts + uses: actions/upload-artifact@v3 + with: + name: rapidsnark-Android-arm64 + path: | + package_android + if-no-files-found: error + + - name: upload Android x86_64 artifacts + uses: actions/upload-artifact@v3 + with: + name: rapidsnark-Android-x86_64 + path: | + package_android_x86_64 + if-no-files-found: error + + - name: upload Linux x86_64 artifacts + uses: actions/upload-artifact@v3 + with: + name: rapidsnark-Linux-x86_64 + path: | + package + if-no-files-found: error + + build-apple-arm64: + runs-on: macos-13-xlarge + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: Cache gmp build + uses: actions/cache@v3 + with: + path: | + depends/gmp + depends/gmp-6.2.1.tar.xz + key: ${{ runner.os }}-gmp-arm64-${{ hashFiles('build_gmp.sh') }} + + - name: build + run: | + if [[ ! -d "depends/gmp/package_ios_arm64" ]]; then ./build_gmp.sh ios; fi + 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 + 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 + 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 + cmake .. -DTARGET_PLATFORM=macos_arm64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_macos_arm64 + make -j4 && make install + + - name: test prover + run: | + set -x + set -e + npm install -g snarkjs + 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 + 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 artifacts + 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 macOS arm64 artifacts + uses: actions/upload-artifact@v3 + with: + name: rapidsnark-macOS-arm64 + path: | + package_macos_arm64 + if-no-files-found: error + + build-apple-x86_64: + runs-on: macos-13 + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: Cache gmp build + uses: actions/cache@v3 + with: + path: | + depends/gmp + depends/gmp-6.2.1.tar.xz + key: ${{ runner.os }}-gmp-x86_64-${{ hashFiles('build_gmp.sh') }}-2 + + - name: install dependencies + run: | + brew install nasm + + - name: build + 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 + cmake .. -DTARGET_PLATFORM=macos_x86_64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_macos_x86_64 + make -j4 && make install + + - name: test prover + run: | + set -x + set -e + npm install -g snarkjs + 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 + uses: actions/upload-artifact@v3 + with: + name: rapidsnark-macOS-x86_64 + path: | + package_macos_x86_64 + if-no-files-found: error diff --git a/.gitignore b/.gitignore index b408aa0..179392b 100644 --- a/.gitignore +++ b/.gitignore @@ -75,3 +75,5 @@ package* build/fq_asm.o build/fr_asm.o + +.idea/ diff --git a/.gitmodules b/.gitmodules index efc8a54..59a3def 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,7 @@ url = https://github.com/nlohmann/json.git [submodule "depends/ffiasm"] path = depends/ffiasm - url = https://github.com/nixw4/ffiasm.git + url = https://github.com/0xPolygonID/ffiasm branch = master [submodule "depends/circom_runtime"] path = depends/circom_runtime diff --git a/README.md b/README.md index 882b51e..43958c9 100644 --- a/README.md +++ b/README.md @@ -8,55 +8,55 @@ You should have installed gcc, cmake, libsodium, and gmp (development) In ubuntu: -```` -sudo apt-get install build-essential cmake libgmp-dev libsodium-dev nasm -```` +``` +sudo apt-get install build-essential cmake libgmp-dev libsodium-dev nasm curl m4 +``` ## Compile prover in standalone mode ### Compile prover for x86_64 host machine -````sh +```sh git submodule init git submodule update ./build_gmp.sh host mkdir build_prover && cd build_prover cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package make -j4 && make install -```` +``` ### Compile prover for macOS arm64 host machine -````sh +```sh git submodule init git submodule update -./build_gmp.sh host_noasm -mkdir build_prover && cd build_prover -cmake .. -DTARGET_PLATFORM=arm64_host -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package +./build_gmp.sh macos_arm64 +mkdir 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 -```` +``` ### Compile prover for linux arm64 host machine -````sh +```sh git submodule init git submodule update ./build_gmp.sh host mkdir build_prover && cd build_prover cmake .. -DTARGET_PLATFORM=arm64_host -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package make -j4 && make install -```` +``` ### Compile prover for linux arm64 machine -````sh +```sh git submodule init git submodule update ./build_gmp.sh host mkdir build_prover && cd build_prover cmake .. -DTARGET_PLATFORM=aarch64 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_aarch64 make -j4 && make install -```` +``` ### Compile prover for Android @@ -66,73 +66,99 @@ Set the value of ANDROID_NDK environment variable to the absolute path of Androi Examples: -````sh +```sh export ANDROID_NDK=/home/test/Android/Sdk/ndk/23.1.7779620 # NDK is installed by "SDK Manager" in Android Studio. export ANDROID_NDK=/home/test/android-ndk-r23b # NDK is installed as a stand-alone package. -```` +``` + +Prerequisites if build on Ubuntu: + +```sh +apt-get install curl xz-utils build-essential cmake m4 nasm +``` Compilation: -````sh +```sh git submodule init git submodule update ./build_gmp.sh android mkdir build_prover_android && cd build_prover_android cmake .. -DTARGET_PLATFORM=ANDROID -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_android make -j4 && make install -```` +``` ### Compile prover for iOS -Install Xcode. +Install Xcode -````sh +```sh git submodule init git submodule update ./build_gmp.sh ios mkdir build_prover_ios && cd build_prover_ios -cmake .. -GXcode -DTARGET_PLATFORM=IOS -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../package_ios -```` +cmake .. -GXcode -DTARGET_PLATFORM=IOS -DCMAKE_INSTALL_PREFIX=../package_ios +xcodebuild -destination 'generic/platform=iOS' -scheme rapidsnarkStatic -project rapidsnark.xcodeproj -configuration Release +``` Open generated Xcode project and compile prover. +## Build for iOS emulator + +Install Xcode + +```sh +git submodule init +git submodule update +./build_gmp.sh ios_simulator +mkdir 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 +``` + +Files that you need to copy to your XCode project to link against Rapidsnark: +* build_prover_ios_simulator/src/Debug-iphonesimulator/librapidsnark.a +* build_prover_ios_simulator/src/Debug-iphonesimulator/libfq.a +* build_prover_ios_simulator/src/Debug-iphonesimulator/libfr.a +* depends/gmp/package_iphone_simulator/lib/libgmp.a + ## Building proof You have a full prover compiled in the build directory. So you can replace snarkjs command: -````sh +```sh snarkjs groth16 prove -```` +``` by this one -````sh +```sh ./package/bin/prover -```` +``` ## Compile prover in server mode -````sh +```sh npm install git submodule init git submodule update npx task createFieldSources npx task buildPistache npx task buildProverServer -```` +``` ## Launch prover in server mode -````sh +```sh ./build/proverServer ... -```` +``` 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. You have an example of the usage calling the server endpoints to generate the proof with Nodejs in `/tools/request.js`. To test a request you should pass an `input.json` as a parameter to the request call. -````sh +```sh node tools/request.js -```` +``` ## Benchmark diff --git a/build/fq.asm b/build/fq.asm index 7d044f8..1bed5c1 100644 --- a/build/fq.asm +++ b/build/fq.asm @@ -349,7 +349,11 @@ Fq_longNeg: Fq_longErr: push rdi mov rdi, 0 +%ifdef PIC call Fq_fail WRT ..plt +%else + call Fq_fail +%endif pop rdi mov rsp, rbp pop rdx diff --git a/build/fr.asm b/build/fr.asm index 720e159..37624f1 100644 --- a/build/fr.asm +++ b/build/fr.asm @@ -353,7 +353,11 @@ Fr_longNeg: Fr_longErr: push rdi mov rdi, 0 +%ifdef PIC call Fr_fail WRT ..plt +%else + call Fr_fail +%endif pop rdi mov rsp, rbp pop rdx diff --git a/build_gmp.sh b/build_gmp.sh index d154179..8f1b380 100755 --- a/build_gmp.sh +++ b/build_gmp.sh @@ -1,4 +1,6 @@ -#!/bin/sh +#!/usr/bin/env bash + +set -e NPROC=8 fetch_cmd=$( (type wget > /dev/null 2>&1 && echo "wget") || echo "curl -O" ) @@ -7,13 +9,16 @@ usage() { echo "USAGE: $0 " echo "where target is one of:" + echo " ios: build for iOS arm64" + echo " ios_simulator: build for iPhone Simulator for arm64/x86_64 (fat binary)" + echo " macos: build for macOS for arm64/x86_64 (fat binary)" + echo " macos_arm64: build for macOS arm64" + echo " macos_x86_64: build for macOS x86_64" echo " android: build for Android arm64" echo " android_x86_64: build for Android x86_64" - echo " aarch64: build for Linux aarch64" - echo " ios: build for iOS arm64" - echo " ios_x86_64: build for iOS simulator on x86_64" echo " host: build for this host" echo " host_noasm: build for this host without asm optimizations (e.g. needed for macOS)" + echo " aarch64: build for Linux aarch64" exit 1 } @@ -115,7 +120,7 @@ build_android() return 1 fi - if [ -z $ANDROID_NDK ]; then + if [ -z "$ANDROID_NDK" ]; then echo "ERROR: ANDROID_NDK environment variable is not set." echo " It must be an absolute path to the root directory of Android NDK." @@ -136,8 +141,8 @@ build_android() export RANLIB=$TOOLCHAIN/bin/llvm-ranlib export STRIP=$TOOLCHAIN/bin/llvm-strip - echo $TOOLCHAIN - echo $TARGET + echo "$TOOLCHAIN" + echo "$TARGET" rm -rf "$BUILD_DIR" mkdir "$BUILD_DIR" @@ -160,7 +165,7 @@ build_android_x86_64() return 1 fi - if [ -z $ANDROID_NDK ]; then + if [ -z "$ANDROID_NDK" ]; then echo "ERROR: ANDROID_NDK environment variable is not set." echo " It must be an absolute path to the root directory of Android NDK." @@ -181,7 +186,7 @@ build_android_x86_64() export RANLIB=$TOOLCHAIN/bin/llvm-ranlib export STRIP=$TOOLCHAIN/bin/llvm-strip - echo $TOOLCHAIN + echo "$TOOLCHAIN" echo $TARGET rm -rf "$BUILD_DIR" @@ -211,11 +216,14 @@ build_ios() export ARCH_FLAGS="-arch arm64 -arch arm64e" export OPT_FLAGS="-O3 -g3 -fembed-bitcode" - export HOST_FLAGS="${ARCH_FLAGS} -miphoneos-version-min=${MIN_IOS_VERSION} -isysroot $(xcrun --sdk ${SDK} --show-sdk-path)" - - export CC=$(xcrun --find --sdk "${SDK}" clang) - export CXX=$(xcrun --find --sdk "${SDK}" clang++) - export CPP=$(xcrun --find --sdk "${SDK}" cpp) + HOST_FLAGS="${ARCH_FLAGS} -miphoneos-version-min=${MIN_IOS_VERSION} -isysroot $(xcrun --sdk ${SDK} --show-sdk-path)" + + CC=$(xcrun --find --sdk "${SDK}" clang) + export CC + CXX=$(xcrun --find --sdk "${SDK}" clang++) + export CXX + CPP=$(xcrun --find --sdk "${SDK}" cpp) + export CPP export CFLAGS="${HOST_FLAGS} ${OPT_FLAGS}" export CXXFLAGS="${HOST_FLAGS} ${OPT_FLAGS}" export LDFLAGS="${HOST_FLAGS}" @@ -233,49 +241,110 @@ build_ios() cd .. } -build_ios_x86_64() +build_ios_simulator() { - PACKAGE_DIR="$GMP_DIR/package_ios_x86_64" - BUILD_DIR=build_ios_x86_64 - - if [ -d "$PACKAGE_DIR" ]; then - echo "iOS package is built already. See $PACKAGE_DIR" - return 1 - fi - - export SDK="iphonesimulator" - export TARGET=x86_64-apple-darwin - export MIN_IOS_VERSION=8.0 - - export ARCH_FLAGS="-arch x86_64" - export OPT_FLAGS="-O3 -g3 -fembed-bitcode" - export HOST_FLAGS="${ARCH_FLAGS} -miphoneos-version-min=${MIN_IOS_VERSION} -isysroot $(xcrun --sdk ${SDK} --show-sdk-path)" - - export CC=$(xcrun --find --sdk "${SDK}" clang) - export CXX=$(xcrun --find --sdk "${SDK}" clang++) - export CPP=$(xcrun --find --sdk "${SDK}" cpp) - export CFLAGS="${HOST_FLAGS} ${OPT_FLAGS}" - export CXXFLAGS="${HOST_FLAGS} ${OPT_FLAGS}" - export LDFLAGS="${HOST_FLAGS}" - - echo $TARGET - - rm -rf "$BUILD_DIR" - mkdir "$BUILD_DIR" - cd "$BUILD_DIR" + libs=() + for ARCH in "arm64" "x86_64"; do + case "$ARCH" in + "arm64" ) + echo "Building for iPhone Simulator arm64" + ARCH_FLAGS="-arch arm64 -arch arm64e" + ;; + "x86_64" ) + echo "Building for iPhone Simulator x86_64" + ARCH_FLAGS="-arch x86_64" + ;; + * ) + echo "Incorrect iPhone Simulator arch" + exit 1 + esac + + BUILD_DIR="build_iphone_simulator_${ARCH}" + PACKAGE_DIR="$GMP_DIR/package_iphone_simulator_${ARCH}" + libs+=("${PACKAGE_DIR}/lib/libgmp.a") + + if [ -d "$PACKAGE_DIR" ]; then + echo "iPhone Simulator ${ARCH} package is built already. See $PACKAGE_DIR. Skip building this ARCH." + continue + fi + + rm -rf "$BUILD_DIR" + mkdir "$BUILD_DIR" + cd "$BUILD_DIR" + + ../configure --prefix="${PACKAGE_DIR}" \ + CC="$(xcrun --sdk iphonesimulator --find clang)" \ + CFLAGS="-O3 -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path) ${ARCH_FLAGS} -fvisibility=hidden -mios-simulator-version-min=8.0" \ + LDFLAGS="" \ + --host ${ARCH}-apple-darwin --disable-assembly --enable-static --disable-shared --with-pic && + make -j${NPROC} && + make install + + cd .. + done + + mkdir -p "${GMP_DIR}/package_iphone_simulator/lib" + lipo "${libs[@]}" -create -output "${GMP_DIR}/package_iphone_simulator/lib/libgmp.a" + echo "Wrote universal fat library for iPhone Simulator arm64/x86_64 to ${GMP_DIR}/package_iphone_simulator/lib/libgmp.a" +} - ../configure --host $TARGET --prefix="$PACKAGE_DIR" --with-pic --disable-fft --disable-assembly && +build_macos_arch() +{ + ARCH="$1" + case "$ARCH" in + "arm64" ) + ARCH_FLAGS="-arch arm64 -arch arm64e" + ;; + "x86_64" ) + ARCH_FLAGS="-arch x86_64" + ;; + * ) + echo "Incorrect arch" + exit 1 + esac + + BUILD_DIR="build_macos_${ARCH}" + PACKAGE_DIR="$GMP_DIR/package_macos_${ARCH}" + if [ -d "$PACKAGE_DIR" ]; then + echo "macOS ${ARCH} package is built already. See $PACKAGE_DIR. Skip building this ARCH." + return + fi + rm -rf "$BUILD_DIR" + mkdir "$BUILD_DIR" + cd "$BUILD_DIR" + ../configure --prefix="${PACKAGE_DIR}" \ + CC="$(xcrun --sdk macosx --find clang)" \ + CFLAGS="-O3 -isysroot $(xcrun --sdk macosx --show-sdk-path) ${ARCH_FLAGS} -fvisibility=hidden -mmacos-version-min=14.0" \ + LDFLAGS="" \ + --host "${ARCH}-apple-darwin" --disable-assembly --enable-static --disable-shared --with-pic && make -j${NPROC} && make install + cd .. +} - cd .. +build_macos_fat() +{ + echo "Building for macOS arm64" + build_macos_arch "arm64" + echo "Building for macOS x86_64" + build_macos_arch "x86_64" + + gmp_lib_arm64="$GMP_DIR/package_macos_arm64/lib/libgmp.a" + gmp_lib_x86_64="$GMP_DIR/package_macos_x86_64/lib/libgmp.a" + gmp_lib_fat="$GMP_DIR/package_macos/lib/libgmp.a" + + mkdir -p "${GMP_DIR}/package_macos/lib" + lipo "${gmp_lib_arm64}" "${gmp_lib_x86_64}" -create -output "${gmp_lib_fat}" + mkdir -p "${GMP_DIR}/package_macos/include" + cp "${GMP_DIR}/package_macos_arm64/include/gmp.h" "${GMP_DIR}/package_macos/include/" + echo "Wrote universal fat library for macOS arm64/x86_64 to ${GMP_DIR}/package_macos/lib/libgmp.a" } if [ $# -ne 1 ]; then usage fi -TARGET_PLATFORM=`echo $1 | tr A-Z a-z` +TARGET_PLATFORM=$(echo "$1" | tr "[:upper:]" "[:lower:]") cd depends @@ -292,9 +361,24 @@ case "$TARGET_PLATFORM" in build_ios ;; - "ios_x86_64" ) - echo "Building for ios simulator on x86_64" - build_ios_x86_64 + "ios_simulator" ) + echo "Building for iPhone Simulator" + build_ios_simulator + ;; + + "macos" ) + echo "Building fat library for macOS" + build_macos_fat + ;; + + "macos_arm64" ) + echo "Building library for macOS arm64" + build_macos_arch "arm64" + ;; + + "macos_x86_64" ) + echo "Building library for macOS x86_64" + build_macos_arch "x86_64" ;; "android" ) diff --git a/cmake/platform.cmake b/cmake/platform.cmake index 9cd9eab..316e43e 100644 --- a/cmake/platform.cmake +++ b/cmake/platform.cmake @@ -56,7 +56,20 @@ elseif(TARGET_PLATFORM MATCHES "arm64_host") set(GMP_PREFIX ${GMP_ROOT}/package) set(ARCH arm64) +elseif(TARGET_PLATFORM MATCHES "macos_x86_64") + + set(CMAKE_OSX_ARCHITECTURES x86_64) + set(GMP_PREFIX ${GMP_ROOT}/package_macos_x86_64) + set(ARCH x86_64) + +elseif(TARGET_PLATFORM MATCHES "macos_arm64") + + set(CMAKE_OSX_ARCHITECTURES arm64) + set(GMP_PREFIX ${GMP_ROOT}/package_macos_arm64) + set(ARCH arm64) + else() + set(GMP_PREFIX ${GMP_ROOT}/package) set(ARCH x86_64) diff --git a/depends/ffiasm b/depends/ffiasm index 38eec22..23429cd 160000 --- a/depends/ffiasm +++ b/depends/ffiasm @@ -1 +1 @@ -Subproject commit 38eec22b86895333db80d9e6f9cfd920ddda53e9 +Subproject commit 23429cd1fe343a4f6af6e1fdfa4e9bb1c3ee983a diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0f82a3e..0313a22 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -13,9 +13,9 @@ endif() if(USE_ASM AND ARCH MATCHES "x86_64") if (CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin") - set(NASM_FLAGS "-fmacho64 --prefix _") + set(NASM_FLAGS -fmacho64 --prefix _) else() - set(NASM_FLAGS -felf64) + set(NASM_FLAGS -felf64 -DPIC) endif() add_custom_command(OUTPUT ${CMAKE_SOURCE_DIR}/build/fq_asm.o diff --git a/testdata/circuit_final.zkey b/testdata/circuit_final.zkey new file mode 100644 index 0000000..02c3a7f Binary files /dev/null and b/testdata/circuit_final.zkey differ diff --git a/testdata/verification_key.json b/testdata/verification_key.json new file mode 100644 index 0000000..de401dd --- /dev/null +++ b/testdata/verification_key.json @@ -0,0 +1,94 @@ +{ + "protocol": "groth16", + "curve": "bn128", + "nPublic": 1, + "vk_alpha_1": [ + "20491192805390485299153009773594534940189261866228447918068658471970481763042", + "9383485363053290200918347156157836566562967994039712273449902621266178545958", + "1" + ], + "vk_beta_2": [ + [ + "6375614351688725206403948262868962793625744043794305715222011528459656738731", + "4252822878758300859123897981450591353533073413197771768651442665752259397132" + ], + [ + "10505242626370262277552901082094356697409835680220590971873171140371331206856", + "21847035105528745403288232691147584728191162732299865338377159692350059136679" + ], + [ + "1", + "0" + ] + ], + "vk_gamma_2": [ + [ + "10857046999023057135944570762232829481370756359578518086990519993285655852781", + "11559732032986387107991004021392285783925812861821192530917403151452391805634" + ], + [ + "8495653923123431417604973247489272438418190587263600148770280649306958101930", + "4082367875863433681332203403145435568316851327593401208105741076214120093531" + ], + [ + "1", + "0" + ] + ], + "vk_delta_2": [ + [ + "10056322322891219854268402349413163241212310059164911282424429574909837055562", + "12530590306125500264744927194515711435185554567505632685219127544784956548143" + ], + [ + "3198185062701173616088252494763783302271691955806883740290181107756211891848", + "5935918403904311654026004102721758093545898651591152833499461744182771134433" + ], + [ + "1", + "0" + ] + ], + "vk_alphabeta_12": [ + [ + [ + "2029413683389138792403550203267699914886160938906632433982220835551125967885", + "21072700047562757817161031222997517981543347628379360635925549008442030252106" + ], + [ + "5940354580057074848093997050200682056184807770593307860589430076672439820312", + "12156638873931618554171829126792193045421052652279363021382169897324752428276" + ], + [ + "7898200236362823042373859371574133993780991612861777490112507062703164551277", + "7074218545237549455313236346927434013100842096812539264420499035217050630853" + ] + ], + [ + [ + "7077479683546002997211712695946002074877511277312570035766170199895071832130", + "10093483419865920389913245021038182291233451549023025229112148274109565435465" + ], + [ + "4595479056700221319381530156280926371456704509942304414423590385166031118820", + "19831328484489333784475432780421641293929726139240675179672856274388269393268" + ], + [ + "11934129596455521040620786944827826205713621633706285934057045369193958244500", + "8037395052364110730298837004334506829870972346962140206007064471173334027475" + ] + ] + ], + "IC": [ + [ + "11932556748928578545728995536027201108657542124050415478292462831771509095304", + "9149370873483970774321348444196634478850132879039205704924275954730380431457", + "1" + ], + [ + "17482596306642470706171849523416052476936601967698452358356767181693176975875", + "16875289648181723199466955981261105815550134487513330320459939834929279218791", + "1" + ] + ] +} \ No newline at end of file diff --git a/testdata/witness.wtns b/testdata/witness.wtns new file mode 100644 index 0000000..e0d8767 Binary files /dev/null and b/testdata/witness.wtns differ