Comment on page
Integrating Snarkify SDK
The Snarkify SDK, a Rust-based library, offers a comprehensive interface for engaging with Snarkify Cloud. It allows for the swift conversion of your existing circuit code into a deployable prover. With Snarkify SDK's streamlined process, you can easily tap into the capabilities of Snarkify Cloud using just a handful of straightforward steps.
cargo add snarkify-sdk
- 1.Create a new file
snarkify.rs
in yoursrc/bin
directory - 2.Implement the
ProofHandler
trait andprove
method for proof creation - 3.Invoke
snarkify_sdk::run::<{YourProofHandler}>()
in the main function
Here's a snippet of code illustrating how to use the SDK:
use std::io;
use serde::{Deserialize, Serialize};
use snarkify_sdk::prover::ProofHandler;
struct MyProofHandler;
#[derive(Deserialize)]
struct MyInput {
public_input: String,
}
#[derive(Serialize)]
struct MyOutput {
proof: String,
}
impl ProofHandler for MyProofHandler {
type Input = MyInput;
type Output = MyOutput;
type Error = ();
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>()
}
To run your prover locally, simply run,
cargo run --bin snarkify
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"
}'
Last modified 23d ago