#prover #zkp #serverless #cloud #deployment #service #snarkify

snarkify-sdk

Snarkify Rust SDK for Streamlined Serverless Prover Development and Deployment

10 releases

0.1.0-alpha.10 Dec 4, 2024
0.1.0-alpha.9 Nov 5, 2024
0.1.0-alpha.8 Jul 18, 2024
0.1.0-alpha.7 Jun 12, 2024
0.1.0-alpha.1 Sep 27, 2023

#1162 in Web programming

Download history 37/week @ 2024-08-19 37/week @ 2024-08-26 55/week @ 2024-09-02 50/week @ 2024-09-09 72/week @ 2024-09-16 95/week @ 2024-09-23 87/week @ 2024-09-30 7/week @ 2024-10-07 40/week @ 2024-10-14 33/week @ 2024-10-21 49/week @ 2024-10-28 155/week @ 2024-11-04 6/week @ 2024-11-11 40/week @ 2024-11-18 66/week @ 2024-11-25 259/week @ 2024-12-02

376 downloads per month

MIT/Apache

27KB
488 lines

Snarkify SDK

The Snarkify SDK is a Rust library designed to simplify the creation and deployment of ZKP provers as serverless services to Snarkify Trustless Cloud.

Installation

To include the Snarkify SDK in your project, add the following line to your Cargo.toml under [dependencies]:

snarkify-sdk = "0.1.0"

or simply run

cargo add snarkify-sdk

Quick Start

Code changes

  1. Create a new file snarkify.rs in your src/bin directory
  2. Implement the ProofHandler trait and prove method for proof creation
  3. Invoke snarkify_sdk::run::<{YourProofHandler}>() in the main function

Here's a basic example illustrating how to use the SDK:

use std::io;

use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use snarkify_sdk::prover::ProofHandler;

struct MyProofHandler;

#[derive(Deserialize)]
struct MyInput {
    public_input: String,
}

#[derive(Serialize)]
struct MyOutput {
    proof: String,
}

#[async_trait]
impl ProofHandler for MyProofHandler {
    type Input = MyInput;
    type Output = MyOutput;
    type Error = ();

    async fn prove(data: Self::Input) -> Result<Self::Output, Self::Error> {
        Ok(MyOutput {
            proof: data.public_input.chars().rev().collect(),
        })
    }
}

fn main() -> Result<(), io::Error> {
    snarkify_sdk::run::<MyProofHandler>()
}

Running & Testing

As an example, to run the prover basic_prover in examples directory, simply run

cargo run --example basic_prover

and you can test the prover locally with a sample request like

curl --location --request POST 'http://localhost:8080' \
--header 'Content-Type: application/json' \
--header 'ce-specversion: 1.0' \
--header 'ce-id: abcdef123456' \
--header 'ce-source: test' \
--header 'ce-type: com.test.example' \
--data-raw '{
     "public_input": "aloha"
 }'

Dependencies

~22–36MB
~611K SLoC