Skip to content

REST API for snarkjs prover, configured to be deployable to AWS lambda specifically for Zorkin, an authentication service.

License

Notifications You must be signed in to change notification settings

Helium-Labs/zorkin-prover-server

 
 

Repository files navigation

Zorkin Prover Server

This is the Prover Server for Zorkin. It's a REST API Wrapper for go-rapidsnark, with AWS CloudFormation based deployment config to deploy an ARM64 build of the prover to AWS Lambda with AWS ECR, exposed behind a Lambda function URL with IAM authorization. To make minimal changes to the server itself, so it can remain a standard HTTPs server, aws-lambda-web-adapter is leveraged.

List of implemented features:

  • Generate proof
  • Verify proof

Deployment

Setup

  1. Edit config file configs/prover.yaml
  2. Put compiled circuits into <circuitsBasePath>/<circuitName> directory. Where <circuitsBasePath> is config option with default value circuits, and <circuitName> is name of the circuit that will be passed as a param to an API call. See SnarkJS Readme for instructions on how to compile circuits.

AWS Lambda with ECR Image Deployment

Assuming you're on linux or macos, the Docker image can be built and deployed to AWS ECR as follows with AWS CloudFormation as follows. It assumes you have the AWS CLI installed. Please provide your values for AWS_ACCOUNT_ID and AWS_REGION environment variables to a .env file.

make deploy-ecr-image

Once the image is deployed to ECR, create the AWS Lambda stack using CloudFormation (see template.yaml) as follows. Set the ImageUri parameter to the ECR image URI created in the previous step. Provide an ARN of a principal IAM identity, such as a user, for the ZorkinPrincipalUser parameter. This IAM identity will receive permission to invoke the function via the function URL.

make deploy-sam

To remove a deployment, the following command can be used:

make delete-stack

Did you receive a pass init error? See https://docs.docker.com/desktop/get-started/#credentials-management-for-linux-users.

API

Generate proof

POST /api/v1/proof/generate
Content-Type: application/json
{
  "inputs": {...}, // circuit specific inputs
  "circuit_name": "..." // name of a directory containing circuit_final.zkey, verification_key.json and circuit.wasm files
}

License

Please check the LICENSE file for more details.

About

REST API for snarkjs prover, configured to be deployable to AWS lambda specifically for Zorkin, an authentication service.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 88.6%
  • Makefile 5.9%
  • Dockerfile 4.0%
  • Shell 1.5%