name: Build Circuits on: push: tags: - "circom_circuits-v*.*.*" workflow_dispatch: inputs: tag: description: "Tag to release. Must follow the format of 'circom_circuits-vX.Y.Z'." required: true jobs: setup: name: Configure Environment runs-on: ubuntu-latest outputs: version: ${{ steps.define-version.outputs.version }} tag: ${{ steps.define-version.outputs.tag }} steps: - name: Define version id: define-version env: # Use the tag name if it is available, otherwise use the input version. # If neither is available, default to the commit hash. TAG: ${{ (github.ref_type == 'tag' && github.ref_name) || inputs.tag || '' }} run: | if [ -z "$TAG" ]; then echo "Could not determine tag." exit 1 elif [[ ! "$TAG" =~ ^circom_circuits-v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "TAG must follow the format of 'circom_circuits-vX.Y.Z'. Value: '$VERSION'." exit 2 fi # Parse Version: Take only the vX.Y.Z part. VERSION=$(echo $TAG | cut -d'-' -f2) # Export the tag and version. echo "tag=$TAG" >> $GITHUB_OUTPUT echo "version=$VERSION" >> $GITHUB_OUTPUT build-linux: name: Build Linux Binaries (Native) runs-on: ubuntu-latest needs: - setup env: VERSION: ${{ needs.setup.outputs.version }} OS: linux ARCH: x86_64 steps: - name: Install Rust Toolchain uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 with: toolchain: stable cache: false - name: Install Circom run: | git clone https://github.com/iden3/circom.git cd circom RUSTFLAGS="-A dead_code" cargo build --release RUSTFLAGS="-A dead_code" cargo install --path circom circom --version - name: Checkout uses: actions/checkout@8edcb1bdb4e267140fa742c62e395cd74f332709 - name: Initialise Submodules run: git submodule update --init --recursive - name: Setup Dependencies working-directory: circom_circuits/rapidsnark run: sudo apt update -y - name: Install Dependencies [Prover] run: sudo apt install -y build-essential cmake libgmp-dev libsodium-dev nasm curl m4 - name: Install Dependencies [Witness Generator] run: sudo apt install nlohmann-json3-dev - name: Replace Prover Makefile # TODO: Make a fork generate the appropriate Linux Makefile run: cp .github/resources/prover/Makefile circom_circuits/rapidsnark/Makefile - name: Compile Prover and Verifier working-directory: circom_circuits/rapidsnark run: | ./build_gmp.sh host make host_linux_x86_64_static - name: Bundle Rapidsnark Prover env: BINARY_NAME: prover BUNDLE_NAME: prover-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }} RAPIDSNARK_DIR: circom_circuits/rapidsnark/package run: | BUNDLE_DIR="${BUNDLE_NAME}/${BINARY_NAME}" mkdir -p "$BUNDLE_DIR" mv "${RAPIDSNARK_DIR}"/bin/${BINARY_NAME} "$BUNDLE_DIR/" tar -czf "${BUNDLE_NAME}.tar.gz" "${BUNDLE_NAME}" - name: Bundle Rapidsnark Verifier env: BINARY_NAME: verifier BUNDLE_NAME: verifier-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }} RAPIDSNARK_DIR: circom_circuits/rapidsnark/package run: | BUNDLE_DIR="${BUNDLE_NAME}/${BINARY_NAME}" mkdir -p "$BUNDLE_DIR" mv "${RAPIDSNARK_DIR}"/bin/${BINARY_NAME} "$BUNDLE_DIR/" tar -czf "${BUNDLE_NAME}.tar.gz" "${BUNDLE_NAME}" - name: Upload Rapidsnark Prover uses: actions/upload-artifact@de65e23aa2b7e23d713bb51fbfcb6d502f8667d8 with: name: prover-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz path: prover-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz - name: Upload Rapidsnark Verifier uses: actions/upload-artifact@de65e23aa2b7e23d713bb51fbfcb6d502f8667d8 with: name: verifier-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz path: verifier-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz - name: Compile and Bundle PoL uses: ./.github/actions/compile-and-bundle with: circuit-name-display: "PoL" circuit-name-binary: "pol" circuit-path: "circom_circuits/Mantle/pol.circom" version: ${{ env.VERSION }} os: ${{ env.OS }} arch: ${{ env.ARCH }} - name: Compile and Bundle PoQ uses: ./.github/actions/compile-and-bundle with: circuit-name-display: "PoQ" circuit-name-binary: "poq" circuit-path: "circom_circuits/Blend/poq.circom" version: ${{ env.VERSION }} os: ${{ env.OS }} arch: ${{ env.ARCH }} - name: Compile and Bundle ZKSign uses: ./.github/actions/compile-and-bundle with: circuit-name-display: "ZKSign" circuit-name-binary: "zksign" circuit-path: "circom_circuits/Mantle/signature.circom" version: ${{ env.VERSION }} os: ${{ env.OS }} arch: ${{ env.ARCH }} - name: Compile and Bundle PoC uses: ./.github/actions/compile-and-bundle with: circuit-name-display: "PoC" circuit-name-binary: "poc" circuit-path: "circom_circuits/Mantle/poc.circom" version: ${{ env.VERSION }} os: ${{ env.OS }} arch: ${{ env.ARCH }} build-windows: name: Build Windows Binaries (Native) runs-on: windows-latest needs: - setup env: VERSION: ${{ needs.setup.outputs.version }} OS: windows ARCH: x86_64 steps: - name: Setup MSYS2 uses: msys2/setup-msys2@v2.28.0 # FIXME: Ideally use the hash to avoid supply chain attacks. Currently unable to. with: update: true install: >- base-devel mingw-w64-x86_64-toolchain make git - name: Install Rust Toolchain uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 with: toolchain: stable cache: false - name: Install Circom run: | git clone https://github.com/iden3/circom.git cd circom $env:RUSTFLAGS="-A dead_code"; cargo build --release $env:RUSTFLAGS="-A dead_code"; cargo install --path circom circom --version - name: Checkout uses: actions/checkout@8edcb1bdb4e267140fa742c62e395cd74f332709 - name: Initialise Submodules run: git submodule update --init --recursive - name: Install Dependencies [Witness Generator] shell: msys2 {0} run: | # nlohmann/json mkdir -p /include/nlohmann/ wget -O /include/nlohmann/json.hpp https://github.com/nlohmann/json/releases/download/v3.12.0/json.hpp # mman-win32 git clone https://github.com/alitrack/mman-win32.git pushd mman-win32 ./configure --prefix= # Path: / make make install popd - name: Install Dependencies [Prover] shell: msys2 {0} run: pacman --noconfirm -Sy --needed cmake nasm mingw-w64-ucrt-x86_64-libsodium - name: Replace Prover Makefile # TODO: Make a fork generate the appropriate Windows Makefile shell: msys2 {0} run: cp .github/resources/prover/Makefile circom_circuits/rapidsnark/Makefile - name: Replace Prover CMakeLists shell: msys2 {0} run: cp .github/resources/prover/${{ env.OS }}.src-CMakeLists.txt circom_circuits/rapidsnark/src/CMakeLists.txt - name: Patch Windows mman shell: msys2 {0} run: cp .github/resources/prover/${{ env.OS }}.mman_patch.hpp /include/mman_patch.hpp - name: Add uio.h headers shell: msys2 {0} run: cp .github/resources/prover/${{ env.OS }}.uio.h /include/sys/uio.h - name: Replace build_gmp shell: msys2 {0} run: cp .github/resources/prover/${{ env.OS }}.build_gmp.sh circom_circuits/rapidsnark/build_gmp.sh - name: Compile Prover and Verifier shell: msys2 {0} working-directory: circom_circuits/rapidsnark run: | ./build_gmp.sh host make host_windows_x86_64_static - name: Bundle Rapidsnark Prover shell: msys2 {0} env: BINARY_NAME: prover BUNDLE_NAME: prover-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }} RAPIDSNARK_DIR: circom_circuits/rapidsnark/package run: | BUNDLE_DIR="${BUNDLE_NAME}/${BINARY_NAME}" mkdir -p "$BUNDLE_DIR" mv "${RAPIDSNARK_DIR}"/bin/${BINARY_NAME}.exe "$BUNDLE_DIR/" tar -czf "${BUNDLE_NAME}.tar.gz" "${BUNDLE_NAME}" - name: Bundle Rapidsnark Verifier shell: msys2 {0} env: BINARY_NAME: verifier BUNDLE_NAME: verifier-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }} RAPIDSNARK_DIR: circom_circuits/rapidsnark/package run: | BUNDLE_DIR="${BUNDLE_NAME}/${BINARY_NAME}" mkdir -p "$BUNDLE_DIR" mv "${RAPIDSNARK_DIR}"/bin/${BINARY_NAME}.exe "$BUNDLE_DIR/" tar -czf "${BUNDLE_NAME}.tar.gz" "${BUNDLE_NAME}" - name: Upload Rapidsnark Prover uses: actions/upload-artifact@de65e23aa2b7e23d713bb51fbfcb6d502f8667d8 with: name: prover-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz path: prover-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz - name: Upload Rapidsnark Verifier uses: actions/upload-artifact@de65e23aa2b7e23d713bb51fbfcb6d502f8667d8 with: name: verifier-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz path: verifier-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz - name: Compile and Bundle PoL uses: ./.github/actions/compile-and-bundle with: circuit-name-display: "PoL" circuit-name-binary: "pol" circuit-path: "circom_circuits/Mantle/pol.circom" version: ${{ env.VERSION }} os: ${{ env.OS }} arch: ${{ env.ARCH }} - name: Compile and Bundle PoQ uses: ./.github/actions/compile-and-bundle with: circuit-name-display: "PoQ" circuit-name-binary: "poq" circuit-path: "circom_circuits/Blend/poq.circom" version: ${{ env.VERSION }} os: ${{ env.OS }} arch: ${{ env.ARCH }} - name: Compile and Bundle ZKSign uses: ./.github/actions/compile-and-bundle with: circuit-name-display: "ZKSign" circuit-name-binary: "zksign" circuit-path: "circom_circuits/Mantle/signature.circom" version: ${{ env.VERSION }} os: ${{ env.OS }} arch: ${{ env.ARCH }} - name: Compile and Bundle PoC uses: ./.github/actions/compile-and-bundle with: circuit-name-display: "PoC" circuit-name-binary: "poc" circuit-path: "circom_circuits/Mantle/poc.circom" version: ${{ env.VERSION }} os: ${{ env.OS }} arch: ${{ env.ARCH }} build-macos: name: Build MacOS Binaries (Native) runs-on: macos-latest needs: - setup env: VERSION: ${{ needs.setup.outputs.version }} ARCH: aarch64 OS: macos steps: - name: Install Rust Toolchain uses: actions-rust-lang/setup-rust-toolchain@fb51252c7ba57d633bc668f941da052e410add48 with: toolchain: stable cache: false - name: Install Circom run: | git clone https://github.com/iden3/circom.git cd circom RUSTFLAGS="-A dead_code" cargo build --release RUSTFLAGS="-A dead_code" cargo install --path circom circom --version - name: Checkout uses: actions/checkout@8edcb1bdb4e267140fa742c62e395cd74f332709 - name: Initialise Submodules run: git submodule update --init --recursive - name: Setup Dependencies run: mkdir include - name: Install Dependencies [Witness Generator] run: brew install nlohmann-json - name: Install Dependencies [Prover] run: brew install nasm m4 - name: Compile Prover and Verifier working-directory: circom_circuits/rapidsnark run: | ./build_gmp.sh macos_arm64 make macos_arm64 - name: Bundle Rapidsnark Prover env: BINARY_NAME: prover BUNDLE_NAME: prover-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }} RAPIDSNARK_DIR: circom_circuits/rapidsnark/package_macos_arm64 run: | BUNDLE_DIR="${BUNDLE_NAME}/${BINARY_NAME}" mkdir -p "$BUNDLE_DIR" mv "${RAPIDSNARK_DIR}/bin/${BINARY_NAME}" "$BUNDLE_DIR/" tar -czf "${BUNDLE_NAME}.tar.gz" "${BUNDLE_NAME}" - name: Bundle Rapidsnark Verifier env: BINARY_NAME: verifier BUNDLE_NAME: verifier-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }} RAPIDSNARK_DIR: circom_circuits/rapidsnark/package_macos_arm64 run: | BUNDLE_DIR="${BUNDLE_NAME}/${BINARY_NAME}" mkdir -p "$BUNDLE_DIR" mv "${RAPIDSNARK_DIR}/bin/${BINARY_NAME}" "$BUNDLE_DIR/" tar -czf "${BUNDLE_NAME}.tar.gz" "${BUNDLE_NAME}" - name: Upload Rapidsnark Prover uses: actions/upload-artifact@de65e23aa2b7e23d713bb51fbfcb6d502f8667d8 with: name: prover-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz path: prover-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz - name: Upload Rapidsnark Verifier uses: actions/upload-artifact@de65e23aa2b7e23d713bb51fbfcb6d502f8667d8 with: name: verifier-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz path: verifier-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz - name: Compile and Bundle PoL uses: ./.github/actions/compile-and-bundle with: circuit-name-display: "PoL" circuit-name-binary: "pol" circuit-path: "circom_circuits/Mantle/pol.circom" version: ${{ env.VERSION }} os: ${{ env.OS }} arch: ${{ env.ARCH }} - name: Compile and Bundle PoQ uses: ./.github/actions/compile-and-bundle with: circuit-name-display: "PoQ" circuit-name-binary: "poq" circuit-path: "circom_circuits/Blend/poq.circom" version: ${{ env.VERSION }} os: ${{ env.OS }} arch: ${{ env.ARCH }} - name: Compile and Bundle ZKSign uses: ./.github/actions/compile-and-bundle with: circuit-name-display: "ZKSign" circuit-name-binary: "zksign" circuit-path: "circom_circuits/Mantle/signature.circom" version: ${{ env.VERSION }} os: ${{ env.OS }} arch: ${{ env.ARCH }} - name: Compile and Bundle PoC uses: ./.github/actions/compile-and-bundle with: circuit-name-display: "PoC" circuit-name-binary: "poc" circuit-path: "circom_circuits/Mantle/poc.circom" version: ${{ env.VERSION }} os: ${{ env.OS }} arch: ${{ env.ARCH }} publish-release: name: Create Release runs-on: ubuntu-latest needs: - setup - build-linux - build-windows - build-macos env: TAG: ${{ needs.setup.outputs.tag }} VERSION: ${{ needs.setup.outputs.version }} outputs: upload_url: ${{ steps.create_release.outputs.upload_url }} steps: - name: Create Release uses: actions/create-release@4c11c9fe1dcd9636620a16455165783b20fc7ea0 id: create_release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: tag_name: ${{ env.TAG }} release_name: Circom Circuits ${{ env.VERSION }} body: | This is a release of Circom Circuits ${{ env.VERSION }}. ## Changelog - feature(X): new feature - fix(Y): bug description - feature: performance improvement on Z ## Checklist Before publishing please ensure: - [ ] Description is complete - [ ] Changelog is correct - [ ] Assets for all platforms exist - [ ] Pre-release is checked if necessary - [ ] Remove this checklist before publishing the release. draft: true prerelease: true upload-artifacts: name: Upload Artifacts to Release runs-on: ubuntu-latest needs: - setup - publish-release strategy: fail-fast: false matrix: platform: - os: linux arch: x86_64 - os: macos arch: aarch64 - os: windows arch: x86_64 artifact: - prover - verifier - pol - poq - zksign - poc env: UPLOAD_URL: ${{ needs.publish-release.outputs.upload_url }} ARTIFACT_NAME: ${{ matrix.artifact }}-${{ needs.setup.outputs.version }}-${{ matrix.platform.os }}-${{ matrix.platform.arch }}.tar.gz steps: - name: Download Artifacts uses: actions/download-artifact@448e3f862ab3ef47aa50ff917776823c9946035b with: name: ${{ env.ARTIFACT_NAME }} - name: Upload Artifacts to Release uses: actions/upload-release-asset@ef2adfe8cb8ebfa540930c452c576b3819990faa env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ env.UPLOAD_URL }} asset_path: ${{ env.ARTIFACT_NAME }} asset_name: ${{ env.ARTIFACT_NAME }} asset_content_type: application/octet-stream