Skip to main content

Crate sp1_solana

Crate sp1_solana 

Source
Expand description

§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};

// Load the sp1_proof_with_public_values from a file.
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();

// Fetch the proof and public inputs from the SP1ProofWithPublicValues.
let proof_bytes = sp1_proof_with_public_values.bytes();
let sp1_public_inputs = sp1_proof_with_public_values.public_values.to_vec();

// Typically, the vkey hash is computed from `vk.bytes32()` on the SP1 program's vkey.
let vkey_hash = "0x0083e8e370d7f0d1c463337f76c9a60b62ad7cc54c89329107c92c1e62097872";

verify_proof(&proof_bytes, &sp1_public_inputs, &vkey_hash, &GROTH16_VK_2_0_0_BYTES).unwrap();

Constants§

GROTH16_VK_2_0_0_BYTES
GROTH16_VK_3_0_0_BYTES
GROTH16_VK_3_0_0_RC4_BYTES
GROTH16_VK_4_0_0_RC3_BYTES
GROTH16_VK_5_0_0_BYTES
Groth16 verification keys for different SP1 versions.

Functions§

verify_proof
Verifies a proof generated by [SP1ProofWithPublicValues].
verify_proof_raw
Verifies a proof using raw bytes, without any checks.