Skip to content

Commit

Permalink
deserialized the public values
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwen01 committed Oct 11, 2024
1 parent a7739c7 commit 8136a7f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion example/program/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use borsh::BorshDeserialize;
use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, pubkey::Pubkey};
use solana_program::{account_info::AccountInfo, entrypoint::ProgramResult, msg, pubkey::Pubkey};
use sp1_solana::{hash_public_inputs, verify_proof_fixture, SP1ProofFixture};

#[cfg(not(feature = "no-entrypoint"))]
Expand Down Expand Up @@ -31,10 +31,20 @@ pub fn process_instruction(
// Make sure that we're verifying a fibonacci program.
assert_eq!(&fixture.vkey_hash(), FIBONACCI_VKEY_HASH);

// Verify that the provided public inputs match the proof fixture's committed values digest.
if let Some(sp1_public_inputs) = &fixture.sp1_public_inputs {
let digest = hash_public_inputs(sp1_public_inputs);
assert_eq!(digest, fixture.commited_values_digest());
}

// Print out the public values.
if let Some(sp1_public_inputs) = &fixture.sp1_public_inputs {
let mut reader = sp1_public_inputs.as_slice();
let n = u32::deserialize(&mut reader).unwrap();
let a = u32::deserialize(&mut reader).unwrap();
let b = u32::deserialize(&mut reader).unwrap();
msg!("Public values: (n: {}, a: {}, b: {})", n, a, b);
}

Ok(())
}

0 comments on commit 8136a7f

Please sign in to comment.