diff --git a/example/program/src/lib.rs b/example/program/src/lib.rs index f39f38f..80b7c57 100644 --- a/example/program/src/lib.rs +++ b/example/program/src/lib.rs @@ -8,7 +8,7 @@ use solana_program::entrypoint; #[cfg(not(feature = "no-entrypoint"))] entrypoint!(process_instruction); -// Derived by running `cargo prove vkey --elf ../../sp1-program/elf/riscv32im-succinct-zkvm-elf` +// Derived by running `cargo prove vkey --elf ../../sp1-program/elf/riscv32im-succinct-zkvm-elf`. const FIBONACCI_VKEY_HASH: &str = "0083e8e370d7f0d1c463337f76c9a60b62ad7cc54c89329107c92c1e62097872"; diff --git a/example/script/src/main.rs b/example/script/src/main.rs index 4a3ebae..ea362f1 100644 --- a/example/script/src/main.rs +++ b/example/script/src/main.rs @@ -6,7 +6,7 @@ use solana_sdk::{ signer::Signer, transaction::Transaction, }; -use sp1_sdk::{utils, HashableKey, ProverClient, SP1ProofWithPublicValues, SP1Stdin}; +use sp1_sdk::{utils, ProverClient, SP1ProofWithPublicValues, SP1Stdin}; use sp1_solana::SP1ProofFixture; #[derive(clap::Parser)] @@ -23,7 +23,7 @@ struct Cli { const ELF: &[u8] = include_bytes!("../../sp1-program/elf/riscv32im-succinct-zkvm-elf"); -async fn run_example_instruction(fixture: SP1ProofFixture) { +async fn run_verify_instruction(fixture: SP1ProofFixture) { let program_id = Pubkey::new_unique(); // Create program test environment @@ -62,11 +62,9 @@ async fn main() { if args.prove { // Initialize the prover client let client = ProverClient::new(); - let (pk, vk) = client.setup(ELF); + let (pk, _vk) = client.setup(ELF); - println!("vkey hash: {:?}", vk.bytes32()); - - // Compute the 20th fibonacci number. + // In our SP1 program, compute the 20th fibonacci number. let mut stdin = SP1Stdin::new(); stdin.write(&20u32); @@ -87,7 +85,8 @@ async fn main() { let fixture_file = "../../proof-fixtures/fibonacci_fixture.bin"; fixture.save(&fixture_file).unwrap(); - run_example_instruction(fixture).await; + // Run the example instruction in a test environment + run_verify_instruction(fixture).await; } #[cfg(test)] @@ -99,7 +98,7 @@ mod tests { let fixture_file = "../../proof-fixtures/fibonacci_fixture.bin"; let fixture = SP1ProofFixture::load(&fixture_file).unwrap(); - run_example_instruction(fixture).await; + run_verify_instruction(fixture).await; } #[tokio::test] @@ -108,6 +107,6 @@ mod tests { let fixture_file = "../../proof-fixtures/fibonacci_fixture_bad.bin"; let fixture = SP1ProofFixture::load(&fixture_file).unwrap(); - run_example_instruction(fixture).await; + run_verify_instruction(fixture).await; } } diff --git a/verifier/src/fixture.rs b/verifier/src/fixture.rs index c4d70a1..8218320 100644 --- a/verifier/src/fixture.rs +++ b/verifier/src/fixture.rs @@ -100,7 +100,7 @@ mod sp1_serialize { let raw_proof = hex::decode(proof.raw_proof).unwrap(); - // Convert public inputs and vkey hash to bytes. + // Convert vkey hash to bytes. let vkey_hash = BigUint::from_str_radix(&proof.public_inputs[0], 10) .unwrap() .to_bytes_be(); @@ -129,6 +129,7 @@ mod sp1_serialize { let sp1_proof_with_public_values = SP1ProofWithPublicValues::load(&sp1_proof_with_public_values_file).unwrap(); + // Convert to a fixture. let fixture = SP1ProofFixture::from(sp1_proof_with_public_values); assert!(verify_proof_fixture(&fixture, &GROTH16_VK_BYTES).is_ok());