Skip to content

Commit

Permalink
nits
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwen01 committed Oct 11, 2024
1 parent 0a20301 commit 68b2a4a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion example/program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
17 changes: 8 additions & 9 deletions example/script/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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
Expand Down Expand Up @@ -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);

Expand All @@ -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)]
Expand All @@ -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]
Expand All @@ -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;
}
}
3 changes: 2 additions & 1 deletion verifier/src/fixture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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());
Expand Down

0 comments on commit 68b2a4a

Please sign in to comment.