From 849cdbeec4a973c44f834f0d058c97a1914df882 Mon Sep 17 00:00:00 2001 From: Yuwen Zhang Date: Wed, 16 Oct 2024 18:12:03 -0700 Subject: [PATCH] more docs --- verifier/src/lib.rs | 19 +++++++++++++++++++ verifier/src/utils.rs | 6 ++++++ 2 files changed, 25 insertions(+) diff --git a/verifier/src/lib.rs b/verifier/src/lib.rs index a14f937..a54dfb8 100644 --- a/verifier/src/lib.rs +++ b/verifier/src/lib.rs @@ -1,3 +1,22 @@ +//! # Verifier +//! +//! This crate contains utilities for verifying SP1 Groth16 proofs on Solana. +//! +//! # Example +//! ``` +//! use sp1_sdk::proof::SP1ProofWithPublicValues; +//! use sp1_solana::{verify_proof, GROTH16_VK_2_0_0_BYTES}; +//! +//! let sp1_proof_with_public_values_file = "../proofs/fibonacci_proof.bin"; +//! let sp1_proof_with_public_values = +//! SP1ProofWithPublicValues::load(&sp1_proof_with_public_values_file).unwrap(); +//! let proof_bytes = sp1_proof_with_public_values.bytes(); +//! let sp1_public_inputs = sp1_proof_with_public_values.public_values.to_vec(); +//! let vkey_hash = "0x0083e8e370d7f0d1c463337f76c9a60b62ad7cc54c89329107c92c1e62097872"; +//! +//! verify_proof(&proof_bytes, &sp1_public_inputs, &vkey_hash, &GROTH16_VK_2_0_0_BYTES).unwrap(); +//! ``` + use groth16_solana::groth16::Groth16Verifyingkey; use sha2::{Digest, Sha256}; diff --git a/verifier/src/utils.rs b/verifier/src/utils.rs index 71055b6..80a707c 100644 --- a/verifier/src/utils.rs +++ b/verifier/src/utils.rs @@ -1,3 +1,9 @@ +//! Utility functions for the SP1 Groth16 Solana verifier. +//! +//! This module contains functions for decompressing G1 and G2 points, as well as +//! for loading proofs into a form appropriate for verification. This is necessary to coerce +//! SP1 Groth16 proofs into the form expected by the `groth16_solana` crate. + use ark_bn254::{Fq, G1Affine}; use ark_ff::PrimeField; use ark_serialize::CanonicalSerialize;