Add PoQ bundling.

This commit is contained in:
Alejandro Cabeza Romero 2025-09-04 18:33:26 +02:00
parent 882f2c468a
commit 5e21d9056e
No known key found for this signature in database
GPG Key ID: DA3D14AE478030FD
2 changed files with 178 additions and 56 deletions

View File

@ -1,43 +1,43 @@
.PHONY: linux macos windows build clean
# ---- Arguments ----
ifndef PROJECT
$(error PROJECT is not set. Usage: make PROJECT=<name>. E.g.: make PROJECT=pol linux)
endif
# ---- Common ----
CXX := g++
CXXFLAGS_COMMON := -std=c++11 -O3 -I. -Wno-address-of-packed-member
SRCS := main.cpp calcwit.cpp fr.cpp pol.cpp
SRCS := main.cpp calcwit.cpp fr.cpp $(PROJECT).cpp
OBJS := $(SRCS:.cpp=.o)
DEPS_HPP := circom.hpp calcwit.hpp fr.hpp
BIN_WINDOWS := pol.exe
BIN_UNIX := pol
BINS := $(BIN_UNIX) $(BIN_WINDOWS)
BIN := $(PROJECT)
# ---- Linux ----
linux: BIN=$(BIN_UNIX)
linux: CXXFLAGS=$(CXXFLAGS_COMMON)
linux: LDFLAGS=-static
linux: LDLIBS=-lgmp
linux: $(BIN_UNIX)
linux: $(BIN)
# ---- macOS ----
macos: BIN=$(BIN_UNIX)
macos: CXXFLAGS=$(CXXFLAGS_COMMON) -I/opt/homebrew/include -include gmp_patch.hpp
macos: LDFLAGS=-Wl,-search_paths_first -Wl,-dead_strip
macos: LDLIBS=/opt/homebrew/lib/libgmp.a
macos: $(BIN_UNIX)
macos: $(BIN)
# ---- Windows (MinGW) ----
windows: BIN=$(BIN_WINDOWS)
windows: CXXFLAGS=$(CXXFLAGS_COMMON) -I/include -Duint="unsigned int"
windows: LDFLAGS=-static
windows: LDLIBS=-L/lib -lgmp -lmman
windows: $(BIN_WINDOWS)
windows: $(BIN)
# ---- Rules ----
$(BINS): $(OBJS)
$(BIN): $(OBJS)
$(CXX) $(LDFLAGS) $^ $(LDLIBS) -o $@
%.o: %.cpp $(DEPS_HPP)
$(CXX) $(CXXFLAGS) -c $< -o $@
clean:
rm -f $(OBJS) $(BIN_WINDOWS) $(BIN_UNIX)
rm -f $(OBJS) $(BIN)

View File

@ -4,6 +4,7 @@ on:
push:
tags:
- "circom_circuits-v*.*.*"
pull_request: # TODO: Testing only. Remove.
workflow_dispatch:
inputs:
tag:
@ -23,7 +24,8 @@ jobs:
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 || '' }}
# TAG: ${{ (github.ref_type == 'tag' && github.ref_name) || inputs.tag || '' }}
TAG: ${{ (github.ref_type == 'tag' && github.ref_name) || inputs.tag || 'circom_circuits-v0.0.0' }} # TODO: Testing only. Remove.
run: |
if [ -z "$TAG" ]; then
echo "Could not determine tag."
@ -93,17 +95,29 @@ jobs:
./build_gmp.sh host
make host_linux_x86_64_static
- name: Generate Witness Generator's C++ Circuit
- name: Generate PoL
working-directory: repo/circom_circuits/Mantle
run: circom --c --r1cs --no_asm --O2 pol.circom
- name: Replace Witness Generator Makefile # TODO: Make a fork generate the appropriate Linux Makefile
- name: Replace PoL Makefile # TODO: Make a fork generate the appropriate Linux Makefile
working-directory: repo
run: cp .github/resources/witness-generator/Makefile circom_circuits/Mantle/pol_cpp/Makefile
- name: Compile Witness Generator
- name: Compile PoL
working-directory: repo/circom_circuits/Mantle/pol_cpp
run: make linux
run: make PROJECT=pol linux
- name: Generate PoQ
working-directory: repo/circom_circuits/Blend
run: circom --c --r1cs --no_asm --O2 poq.circom
- name: Replace PoQ Makefile # TODO: Make a fork generate the appropriate Linux Makefile
working-directory: repo
run: cp .github/resources/witness-generator/Makefile circom_circuits/Blend/poq_cpp/Makefile
- name: Compile PoQ
working-directory: repo/circom_circuits/Blend/poq_cpp
run: make PROJECT=poq linux
- name: Bundle Rapidsnark Prover
working-directory: repo
@ -133,16 +147,36 @@ jobs:
tar -czf "${BUNDLE_NAME}.tar.gz" "${BUNDLE_NAME}"
- name: Bundle Pol Witness Generator
- name: Bundle PoL Witness Generator
working-directory: repo
env:
CIRCUIT_NAME: pol
PLATFORM_BINARY_NAME: pol
BUNDLE_NAME: pol-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}
WITNESS_GENERATOR_DIR: circom_circuits/Mantle/pol_cpp
run: |
BUNDLE_DIR="${BUNDLE_NAME}/witness-generator"
mkdir -p "$BUNDLE_DIR"
mv "${WITNESS_GENERATOR_DIR}"/{pol,pol.dat} "$BUNDLE_DIR/"
ls -la ${WITNESS_GENERATOR_DIR}
mv "${WITNESS_GENERATOR_DIR}/${CIRCUIT_NAME}" "$BUNDLE_DIR/${PLATFORM_BINARY_NAME}"
mv "${WITNESS_GENERATOR_DIR}/${CIRCUIT_NAME}.dat" "$BUNDLE_DIR/${PLATFORM_BINARY_NAME}.dat"
tar -czf "${BUNDLE_NAME}.tar.gz" "${BUNDLE_NAME}"
- name: Bundle PoQ Witness Generator
working-directory: repo
env:
CIRCUIT_NAME: poq
PLATFORM_BINARY_NAME: poq
BUNDLE_NAME: poq-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}
WITNESS_GENERATOR_DIR: circom_circuits/Blend/poq_cpp
run: |
BUNDLE_DIR="${BUNDLE_NAME}/witness-generator"
mkdir -p "$BUNDLE_DIR"
mv "${WITNESS_GENERATOR_DIR}/${CIRCUIT_NAME}" "$BUNDLE_DIR/${PLATFORM_BINARY_NAME}"
mv "${WITNESS_GENERATOR_DIR}/${CIRCUIT_NAME}.dat" "$BUNDLE_DIR/${PLATFORM_BINARY_NAME}.dat"
tar -czf "${BUNDLE_NAME}.tar.gz" "${BUNDLE_NAME}"
@ -158,12 +192,18 @@ jobs:
name: verifier-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
path: repo/verifier-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
- name: Upload Pol Witness Generator
- name: Upload PoL Witness Generator
uses: actions/upload-artifact@de65e23aa2b7e23d713bb51fbfcb6d502f8667d8
with:
name: pol-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
path: repo/pol-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
- name: Upload PoQ Witness Generator
uses: actions/upload-artifact@de65e23aa2b7e23d713bb51fbfcb6d502f8667d8
with:
name: poq-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
path: repo/poq-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
build-windows:
name: Build Windows Binaries (Native)
runs-on: windows-latest
@ -258,19 +298,33 @@ jobs:
./build_gmp.sh host
make host_windows_x86_64_static
- name: Generate Witness Generator's C++ Circuit
- name: Generate PoL
working-directory: repo/circom_circuits/Mantle
run: circom --c --r1cs --no_asm pol.circom
- name: Replace Witness Generator Makefile # TODO: Make a fork generate the appropriate Windows Makefile
- name: Replace PoL Makefile # TODO: Make a fork generate the appropriate Windows Makefile
shell: msys2 {0}
working-directory: repo
run: cp .github/resources/witness-generator/Makefile circom_circuits/Mantle/pol_cpp/Makefile
- name: Compile Witness Generator
- name: Compile PoL
shell: msys2 {0}
working-directory: repo/circom_circuits/Mantle/pol_cpp
run: make windows
run: make PROJECT=pol windows
- name: Generate PoQ
working-directory: repo/circom_circuits/Blend
run: circom --c --r1cs --no_asm poq.circom
- name: Replace PoQ Makefile # TODO: Make a fork generate the appropriate Windows Makefile
shell: msys2 {0}
working-directory: repo
run: cp .github/resources/witness-generator/Makefile circom_circuits/Blend/poq_cpp/Makefile
- name: Compile PoQ
shell: msys2 {0}
working-directory: repo/circom_circuits/Blend/poq_cpp
run: make PROJECT=poq windows
- name: Bundle Rapidsnark Prover
shell: msys2 {0}
@ -302,18 +356,37 @@ jobs:
tar -czf "${BUNDLE_NAME}.tar.gz" "${BUNDLE_NAME}"
- name: Bundle Pol Witness Generator
- name: Bundle PoL Witness Generator
shell: msys2 {0}
working-directory: repo
env:
CIRCUIT_NAME: pol
PLATFORM_BINARY_NAME: pol.exe
BUNDLE_NAME: pol-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}
WITNESS_GENERATOR_DIR: circom_circuits/Mantle/pol_cpp
run: |
BUNDLE_DIR="${BUNDLE_NAME}/witness-generator"
mkdir -p "$BUNDLE_DIR"
mv "${WITNESS_GENERATOR_DIR}/pol" "$BUNDLE_DIR/pol.exe"
mv "${WITNESS_GENERATOR_DIR}/pol.dat" "$BUNDLE_DIR/pol.exe.dat"
mv "${WITNESS_GENERATOR_DIR}/${CIRCUIT_NAME}" "$BUNDLE_DIR/${PLATFORM_BINARY_NAME}"
mv "${WITNESS_GENERATOR_DIR}/${CIRCUIT_NAME}.dat" "$BUNDLE_DIR/${PLATFORM_BINARY_NAME}.dat"
tar -czf "${BUNDLE_NAME}.tar.gz" "${BUNDLE_NAME}"
- name: Bundle PoQ Witness Generator
shell: msys2 {0}
working-directory: repo
env:
CIRCUIT_NAME: poq
PLATFORM_BINARY_NAME: poq.exe
BUNDLE_NAME: poq-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}
WITNESS_GENERATOR_DIR: circom_circuits/Blend/poq_cpp
run: |
BUNDLE_DIR="${BUNDLE_NAME}/witness-generator"
mkdir -p "$BUNDLE_DIR"
mv "${WITNESS_GENERATOR_DIR}/${CIRCUIT_NAME}" "$BUNDLE_DIR/${PLATFORM_BINARY_NAME}"
mv "${WITNESS_GENERATOR_DIR}/${CIRCUIT_NAME}.dat" "$BUNDLE_DIR/${PLATFORM_BINARY_NAME}.dat"
tar -czf "${BUNDLE_NAME}.tar.gz" "${BUNDLE_NAME}"
@ -329,12 +402,18 @@ jobs:
name: verifier-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
path: repo/verifier-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
- name: Upload Pol Witness Generator
- name: Upload PoL Witness Generator
uses: actions/upload-artifact@de65e23aa2b7e23d713bb51fbfcb6d502f8667d8
with:
name: pol-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
path: repo/pol-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
- name: Upload PoQ Witness Generator
uses: actions/upload-artifact@de65e23aa2b7e23d713bb51fbfcb6d502f8667d8
with:
name: poq-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
path: repo/poq-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
build-macos:
name: Build MacOS Binaries (Native)
runs-on: macos-latest
@ -383,11 +462,11 @@ jobs:
./build_gmp.sh macos_arm64
make macos_arm64
- name: Generate Witness Generator's C++ Circuit
- name: Generate PoL
working-directory: repo/circom_circuits/Mantle
run: circom --c --r1cs --no_asm --O2 pol.circom
- name: Replace Witness Generator's Makefile # TODO: Make a fork generate the appropriate MacOS Makefile
- name: Replace PoL's Makefile # TODO: Make a fork generate the appropriate MacOS Makefile
working-directory: repo
run: cp .github/resources/witness-generator/Makefile circom_circuits/Mantle/pol_cpp/Makefile
@ -395,9 +474,25 @@ jobs:
working-directory: repo
run: cp .github/resources/witness-generator/${{ env.OS }}.gmp_patch.hpp circom_circuits/Mantle/pol_cpp/gmp_patch.hpp
- name: Compile Witness Generator
- name: Compile PoL
working-directory: repo/circom_circuits/Mantle/pol_cpp
run: make macos
run: make PROJECT=pol macos
- name: Generate PoQ
working-directory: repo/circom_circuits/Blend
run: circom --c --r1cs --no_asm --O2 poq.circom
- name: Replace PoQ's Makefile # TODO: Make a fork generate the appropriate MacOS Makefile
working-directory: repo
run: cp .github/resources/witness-generator/Makefile circom_circuits/Blend/poq_cpp/Makefile
- name: Patch MacOS GMP
working-directory: repo
run: cp .github/resources/witness-generator/${{ env.OS }}.gmp_patch.hpp circom_circuits/Blend/poq_cpp/gmp_patch.hpp
- name: Compile PoQ
working-directory: repo/circom_circuits/Blend/poq_cpp
run: make PROJECT=poq macos
- name: Bundle Rapidsnark Prover
working-directory: repo
@ -427,16 +522,36 @@ jobs:
tar -czf "${BUNDLE_NAME}.tar.gz" "${BUNDLE_NAME}"
- name: Bundle Pol Witness Generator
- name: Bundle PoL Witness Generator
working-directory: repo
env:
CIRCUIT_NAME: pol
PLATFORM_BINARY_NAME: pol
BUNDLE_NAME: pol-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}
WITNESS_GENERATOR_DIR: circom_circuits/Mantle/pol_cpp
run: |
BUNDLE_DIR="${BUNDLE_NAME}/witness-generator"
mkdir -p "$BUNDLE_DIR"
mv "${WITNESS_GENERATOR_DIR}"/{pol,pol.dat} "$BUNDLE_DIR/"
ls -la ${WITNESS_GENERATOR_DIR}
mv "${WITNESS_GENERATOR_DIR}/${CIRCUIT_NAME}" "$BUNDLE_DIR/${PLATFORM_BINARY_NAME}"
mv "${WITNESS_GENERATOR_DIR}/${CIRCUIT_NAME}.dat" "$BUNDLE_DIR/${PLATFORM_BINARY_NAME}.dat"
tar -czf "${BUNDLE_NAME}.tar.gz" "${BUNDLE_NAME}"
- name: Bundle PoQ Witness Generator
working-directory: repo
env:
CIRCUIT_NAME: poq
PLATFORM_BINARY_NAME: poq
BUNDLE_NAME: poq-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}
WITNESS_GENERATOR_DIR: circom_circuits/Blend/poq_cpp
run: |
BUNDLE_DIR="${BUNDLE_NAME}/witness-generator"
mkdir -p "$BUNDLE_DIR"
mv "${WITNESS_GENERATOR_DIR}/${CIRCUIT_NAME}" "$BUNDLE_DIR/${PLATFORM_BINARY_NAME}"
mv "${WITNESS_GENERATOR_DIR}/${CIRCUIT_NAME}.dat" "$BUNDLE_DIR/${PLATFORM_BINARY_NAME}.dat"
tar -czf "${BUNDLE_NAME}.tar.gz" "${BUNDLE_NAME}"
@ -452,12 +567,18 @@ jobs:
name: verifier-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
path: repo/verifier-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
- name: Upload Pol Witness Generator
- name: Upload PoL Witness Generator
uses: actions/upload-artifact@de65e23aa2b7e23d713bb51fbfcb6d502f8667d8
with:
name: pol-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
path: repo/pol-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
- name: Upload PoQ Witness Generator
uses: actions/upload-artifact@de65e23aa2b7e23d713bb51fbfcb6d502f8667d8
with:
name: poq-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
path: repo/poq-${{ env.VERSION }}-${{ env.OS }}-${{ env.ARCH }}.tar.gz
publish-release:
name: Create Release
runs-on: ubuntu-latest
@ -516,6 +637,7 @@ jobs:
- prover
- verifier
- pol
- poq
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