mirror of
https://github.com/logos-storage/proof-aggregation.git
synced 2026-01-10 17:53:09 +00:00
improve cli bash script, and update readme
This commit is contained in:
parent
7948d6538d
commit
3c3de2b26d
0
gnark-wrapper/.gitignore
vendored
Normal file → Executable file
0
gnark-wrapper/.gitignore
vendored
Normal file → Executable file
41
gnark-wrapper/README.md
Normal file → Executable file
41
gnark-wrapper/README.md
Normal file → Executable file
@ -54,26 +54,39 @@ This folder `testdata/dummy` must contain:
|
|||||||
- `proof_with_public_inputs.json`
|
- `proof_with_public_inputs.json`
|
||||||
- `common_circuit_data.json`
|
- `common_circuit_data.json`
|
||||||
|
|
||||||
2. Compile:
|
2. **Create or edit your `params.sh`**
|
||||||
|
Define your defaults (circuit folder, output dir, proof system, dummy mode) in `params.sh`
|
||||||
```bash
|
```bash
|
||||||
./compile.sh ./testdata/dummy ./gnark_output groth16 false
|
export CIRCUIT_DIR="$PWD/testdata/dummy" # path to Plonky2 JSON files
|
||||||
|
export DATA_DIR="$PWD/gnark_output" # where to save gnark outputs
|
||||||
|
export PROOF_SYSTEM="groth16" # "plonk" or "groth16"
|
||||||
|
export DUMMY="false" # dummy or real setup
|
||||||
```
|
```
|
||||||
Produces ./gnark_output/groth16/r1cs.bin, pk.bin, vk.bin, and Verifier.sol.
|
|
||||||
|
|
||||||
3. Prove:
|
3. **Run the full end-to-end using defaults in `params.sh`**
|
||||||
```bash
|
```bash
|
||||||
./prove.sh ./testdata/dummy ./gnark_output groth16 false
|
./run_gnark_cli.sh
|
||||||
```
|
```
|
||||||
Produces ./gnark_output/groth16/proof.json and public_witness.bin.
|
If you don’t supply any of `--compile`, `--prove` or `--verify` flags, it will run all three compile → prove → verify in sequence.
|
||||||
|
|
||||||
4. Verify:
|
4. **Run individual steps**
|
||||||
```bash
|
Append any combination of:
|
||||||
./verify.sh ./testdata/dummy ./gnark_output groth16 false
|
- `--compile`
|
||||||
```
|
- `--prove`
|
||||||
Checks proof.json + vk.bin + public_witness.bin.
|
- `--verify`
|
||||||
|
|
||||||
5. (Optional) Full end-to-end
|
|
||||||
```bash
|
```bash
|
||||||
./test.sh ./testdata/dummy ./gnark_output groth16 false
|
# Compile only
|
||||||
|
./run_gnark_cli.sh --compile
|
||||||
|
|
||||||
|
# Prove and then verify
|
||||||
|
./run_gnark_cli.sh --prove --verify
|
||||||
|
```
|
||||||
|
|
||||||
|
5. **Use a custom params.sh location**
|
||||||
|
Pass -P or --params-file before any other flags:
|
||||||
|
```bash
|
||||||
|
./run_gnark_cli.sh \
|
||||||
|
-P /path/to/your/params.sh \
|
||||||
|
--compile --prove
|
||||||
```
|
```
|
||||||
Calls compile → prove → verify in sequence.
|
|
||||||
|
|||||||
0
gnark-wrapper/circuit.go
Normal file → Executable file
0
gnark-wrapper/circuit.go
Normal file → Executable file
1
gnark-wrapper/cli.go
Normal file → Executable file
1
gnark-wrapper/cli.go
Normal file → Executable file
@ -183,7 +183,6 @@ func ProveCircuit(circuitPath string, dataPath string, proofSystem string, isDum
|
|||||||
log.Err(err).Msg("failed sanity check to verify proof")
|
log.Err(err).Msg("failed sanity check to verify proof")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
log.Info().Msgf("number of public input: %s", publicWitness)
|
|
||||||
log.Info().Msg("Successfully passed sanity check - proof verification")
|
log.Info().Msg("Successfully passed sanity check - proof verification")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -1,19 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# Usage: ./compile.sh <circuit_dir> <data_dir> <proof_system> <dummy_setup>
|
|
||||||
CIRCUIT_DIR=${1:-"$PWD/testdata/dummy"} # path to your Plonky2 JSON folder
|
|
||||||
DATA_DIR=${2:-"$PWD/gnark_output"} # where to save gnark outputs
|
|
||||||
PROOF_SYSTEM=${3:-"groth16"} # "plonk" or "groth16"
|
|
||||||
DUMMY=${4:-"false"} # dummy or real setup
|
|
||||||
|
|
||||||
echo "Building verifier binary..."
|
|
||||||
go build -o verifier .
|
|
||||||
|
|
||||||
echo "Compiling circuit ($PROOF_SYSTEM)…"
|
|
||||||
./verifier \
|
|
||||||
-circuit "${CIRCUIT_DIR}" \
|
|
||||||
-data "${DATA_DIR}" \
|
|
||||||
-proof-system "${PROOF_SYSTEM}" \
|
|
||||||
-dummy="${DUMMY}" \
|
|
||||||
-compile
|
|
||||||
0
gnark-wrapper/go.mod
Normal file → Executable file
0
gnark-wrapper/go.mod
Normal file → Executable file
0
gnark-wrapper/go.sum
Normal file → Executable file
0
gnark-wrapper/go.sum
Normal file → Executable file
6
gnark-wrapper/params.sh
Executable file
6
gnark-wrapper/params.sh
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export CIRCUIT_DIR="$PWD/testdata/dummy" # path to Plonky2 JSON files
|
||||||
|
export DATA_DIR="$PWD/gnark_output" # where to save gnark outputs
|
||||||
|
export PROOF_SYSTEM="groth16" # "plonk" or "groth16"
|
||||||
|
export DUMMY="false" # dummy or real setup
|
||||||
@ -1,16 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# Usage: ./prove.sh <circuit_dir> <data_dir> [proof_system]
|
|
||||||
CIRCUIT_DIR=${1:-"$PWD/testdata/dummy"}
|
|
||||||
DATA_DIR=${2:-"$PWD/gnark_output"}
|
|
||||||
PROOF_SYSTEM=${3:-"groth16"}
|
|
||||||
DUMMY=${4:-"false"}
|
|
||||||
|
|
||||||
echo "Generating proof ($PROOF_SYSTEM)…"
|
|
||||||
./verifier \
|
|
||||||
-circuit "${CIRCUIT_DIR}" \
|
|
||||||
-data "${DATA_DIR}" \
|
|
||||||
-proof-system "${PROOF_SYSTEM}" \
|
|
||||||
-dummy="${DUMMY}" \
|
|
||||||
-prove
|
|
||||||
0
gnark-wrapper/prover.go
Normal file → Executable file
0
gnark-wrapper/prover.go
Normal file → Executable file
120
gnark-wrapper/run_gnark_cli.sh
Executable file
120
gnark-wrapper/run_gnark_cli.sh
Executable file
@ -0,0 +1,120 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $(basename "$0") [options]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-P, --params-file FILE Path to params.sh file (default: same directory as this script)
|
||||||
|
-c, --circuit-dir DIR Path to Plonky2 JSON circuit folder (default to params.sh \$CIRCUIT_DIR)
|
||||||
|
-d, --data-dir DIR Directory to save gnark outputs (default to params.sh \$DATA_DIR)
|
||||||
|
-s, --proof-system SYS Proof system: "plonk" or "groth16" (default to params.sh \$PROOF_SYSTEM)
|
||||||
|
--dummy Use dummy setup (sets DUMMY to "true")
|
||||||
|
--no-dummy Use real setup (sets DUMMY to "false")
|
||||||
|
--compile Compile the circuit
|
||||||
|
--prove Generate the proof
|
||||||
|
--verify Verify the proof
|
||||||
|
-h, --help Show this help message
|
||||||
|
|
||||||
|
If no operation flags (--compile, --prove, --verify) are provided, all steps are run.
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
# Default params file
|
||||||
|
PARAMS_FILE="$(dirname "$0")/params.sh"
|
||||||
|
# Pre-parse for custom params file, shifting out -P/--params-file
|
||||||
|
_original_args=("$@")
|
||||||
|
args=()
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
-P|--params-file)
|
||||||
|
PARAMS_FILE="$2"; shift 2;;
|
||||||
|
*)
|
||||||
|
args+=("$1"); shift;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
# Restore remaining args
|
||||||
|
if (( ${#args[@]} )); then
|
||||||
|
set -- "${args[@]}"
|
||||||
|
else
|
||||||
|
set --
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Load defaults from params.sh
|
||||||
|
if [[ -f "$PARAMS_FILE" ]]; then
|
||||||
|
source "$PARAMS_FILE"
|
||||||
|
else
|
||||||
|
echo "Error: params file not found at $PARAMS_FILE" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Initialize flags
|
||||||
|
do_compile=false
|
||||||
|
do_prove=false
|
||||||
|
do_verify=false
|
||||||
|
|
||||||
|
# Parse command-line arguments for operations and options
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
-c|--circuit-dir)
|
||||||
|
CIRCUIT_DIR="$2"; shift 2;;
|
||||||
|
-d|--data-dir)
|
||||||
|
DATA_DIR="$2"; shift 2;;
|
||||||
|
-s|--proof-system)
|
||||||
|
PROOF_SYSTEM="$2"; shift 2;;
|
||||||
|
--dummy)
|
||||||
|
DUMMY="true"; shift;;
|
||||||
|
--no-dummy)
|
||||||
|
DUMMY="false"; shift;;
|
||||||
|
--compile)
|
||||||
|
do_compile=true; shift;;
|
||||||
|
--prove)
|
||||||
|
do_prove=true; shift;;
|
||||||
|
--verify)
|
||||||
|
do_verify=true; shift;;
|
||||||
|
-h|--help)
|
||||||
|
usage; exit 0;;
|
||||||
|
*)
|
||||||
|
echo "Error: Unknown option: $1" >&2; usage; exit 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# If no operations are specified, perform all
|
||||||
|
if ! $do_compile && ! $do_prove && ! $do_verify; then
|
||||||
|
do_compile=true
|
||||||
|
do_prove=true
|
||||||
|
do_verify=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Build verifier binary
|
||||||
|
if $do_compile || $do_prove || $do_verify; then
|
||||||
|
echo "Building verifier binary..."
|
||||||
|
go build -o verifier .
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Helper to run gnark verifier with a specific operation
|
||||||
|
run_verifier() {
|
||||||
|
local mode_flag="$1"
|
||||||
|
local action_name="$2"
|
||||||
|
echo "${action_name} (${PROOF_SYSTEM})…"
|
||||||
|
./verifier \
|
||||||
|
-circuit "${CIRCUIT_DIR}" \
|
||||||
|
-data "${DATA_DIR}" \
|
||||||
|
-proof-system "${PROOF_SYSTEM}" \
|
||||||
|
-dummy="${DUMMY}" \
|
||||||
|
"${mode_flag}"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Execute requested operations
|
||||||
|
if $do_compile; then
|
||||||
|
run_verifier "-compile" "Compiling circuit"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $do_prove; then
|
||||||
|
run_verifier "-prove" "Generating proof"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if $do_verify; then
|
||||||
|
run_verifier "-verify" "Verifying proof"
|
||||||
|
fi
|
||||||
@ -1,14 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# Usage: ./test.sh <circuit_dir> <data_dir> <proof_system> <dummy_setup>
|
|
||||||
|
|
||||||
CIRCUIT_DIR=${1:-"$PWD/testdata/dummy"} # path to your Plonky2 JSON folder
|
|
||||||
DATA_DIR=${2:-"$PWD/gnark_output"} # where to save gnark outputs
|
|
||||||
PROOF_SYSTEM=${3:-"groth16"} # "plonk" or "groth16"
|
|
||||||
DUMMY=${4:-"false"} # dummy or real setup
|
|
||||||
|
|
||||||
echo "Running full test: compile → prove → verify"
|
|
||||||
./compile.sh "${CIRCUIT_DIR}" "${DATA_DIR}" "${PROOF_SYSTEM}" "${DUMMY}"
|
|
||||||
./prove.sh "${CIRCUIT_DIR}" "${DATA_DIR}" "${PROOF_SYSTEM}" "${DUMMY}"
|
|
||||||
./verify.sh "${CIRCUIT_DIR}" "${DATA_DIR}" "${PROOF_SYSTEM}" "${DUMMY}"
|
|
||||||
0
gnark-wrapper/testdata/dummy/common_circuit_data.json
vendored
Normal file → Executable file
0
gnark-wrapper/testdata/dummy/common_circuit_data.json
vendored
Normal file → Executable file
0
gnark-wrapper/testdata/dummy/proof_with_public_inputs.json
vendored
Normal file → Executable file
0
gnark-wrapper/testdata/dummy/proof_with_public_inputs.json
vendored
Normal file → Executable file
0
gnark-wrapper/testdata/dummy/verifier_only_circuit_data.json
vendored
Normal file → Executable file
0
gnark-wrapper/testdata/dummy/verifier_only_circuit_data.json
vendored
Normal file → Executable file
0
gnark-wrapper/verifier.go
Normal file → Executable file
0
gnark-wrapper/verifier.go
Normal file → Executable file
@ -1,16 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
set -euo pipefail
|
|
||||||
|
|
||||||
# Usage: ./verify.sh <circuit_dir> <data_dir> [proof_system]
|
|
||||||
CIRCUIT_DIR=${1:-"$PWD/testdata/dummy"}
|
|
||||||
DATA_DIR=${2:-"$PWD/gnark_output"}
|
|
||||||
PROOF_SYSTEM=${3:-"groth16"}
|
|
||||||
DUMMY=${4:-"false"}
|
|
||||||
|
|
||||||
echo "Verifying proof ($PROOF_SYSTEM)…"
|
|
||||||
./verifier \
|
|
||||||
-circuit "${CIRCUIT_DIR}" \
|
|
||||||
-data "${DATA_DIR}" \
|
|
||||||
-proof-system "${PROOF_SYSTEM}" \
|
|
||||||
-dummy="${DUMMY}" \
|
|
||||||
-verify
|
|
||||||
Loading…
x
Reference in New Issue
Block a user