Skip to content

Latest commit

 

History

History
105 lines (69 loc) · 3.1 KB

File metadata and controls

105 lines (69 loc) · 3.1 KB

WHIR proof verifier

A command-line and HTTP server application performing a recursive verification of a zero-knowledge proof using WHIR.

Usage

Command Line Interface

go run cmd/cli/main.go [flags]

Flags

  • --config Path to the JSON configuration file containing verifier circuit parameters (default: ../noir-examples/poseidon-rounds/params_for_recursive_verifier)
  • --r1cs Path to the R1CS JSON file describing the constraint system of the inner circuit (default: ../noir-examples/poseidon-rounds/r1cs.json)
  • --ccs Optional path to store the constraint system object of the verifier circuit (default: empty, don't serialize)
  • --pk Optional path to load the Proving Key (PK) that will be used to generate proof for the verifier circuit. If not provided, PK will be generated unsafely (default: empty, generate own key)
  • --vk Optional path to load the Verifying Key (VK) that will be used to prove the verifier circuit. If not provided, VK will be generated unsafely (default: empty, generate own key)

HTTP Server

Start the HTTP server:

go run cmd/server/main.go

HTTP API

This repository provides an HTTP API for verifying proofs.

Base URL

http://localhost:3000 (when running locally)

Endpoints

Health Check

GET /api/v1/ping

Returns a simple health check response.

Response:

pong

Generic Proof Verification

POST /api/v1/verify

Generic endpoint for verifying proofs with trusted setup keys vk/pk generated by server.

Request: Send a multipart/form-data POST request with the following fields:

  • config (required): JSON configuration file containing verifier circuit parameters
  • r1cs (required): R1CS JSON file describing the constraint system of the inner circuit
  • r1cs_url (optional): Publicly exposed url for downloading r1cs file. Takes precedence over r1cs file if both provided.
  • pk_url (optional): Publicly exposed url for downloading proving key
  • vk_url (optional): Publicly exposed url for downloading verifying key

Response:

  • Success (200): Verification successful
  • Error (400): Error message describing the failure

Server Configuration

The server is configured with the following settings:

  • Port: 3000
  • Read Timeout: 10 minutes (for file uploads)
  • Write Timeout: 5 minutes (for responses)
  • Idle Timeout: 90 minutes (total connection time)
  • Body Limit: 2GB (total size for params and R1CS files)
  • CORS: Enabled with permissive settings

Example Usage

Using curl for Generic Verification

curl -X POST \
  -F "config=@params_for_recursive_verifier" \
  -F "r1cs=@r1cs.json" \
  http://localhost:3000/api/v1/verify

Error Handling

The API returns appropriate HTTP status codes:

  • 200: Verification successful
  • 400: Bad request (missing files, verification failed, etc.)
  • 500: Internal server error

File Requirements

  • config: Must be a valid JSON file containing verifier circuit parameters
  • r1cs: Must be a valid R1CS JSON file describing the constraint system