@@ -23,29 +23,27 @@ static SP1_PROVER_CLIENT_CPU: LazyLock<CpuProver> =
2323pub struct SP1ProofWithPubValuesAndElf {
2424 pub proof_with_pub_values : SP1ProofWithPublicValues ,
2525 pub elf : Vec < u8 > ,
26+ pub vk : SP1VerifyingKey ,
2627}
2728
2829impl SP1ProofWithPubValuesAndElf {
30+ pub fn new ( proof_with_pub_values : SP1ProofWithPublicValues , elf : Vec < u8 > ) -> Self {
31+ let vk = vk_from_elf ( & elf) ;
32+
33+ Self {
34+ proof_with_pub_values,
35+ elf,
36+ vk,
37+ }
38+ }
39+
2940 pub fn hash_vk_and_pub_inputs ( & self ) -> [ u8 ; 32 ] {
3041 let mut hasher = Keccak256 :: new ( ) ;
31- let vk_bytes = & self . vk ( ) . hash_bytes ( ) ;
42+ let vk_bytes = & self . vk . hash_bytes ( ) ;
3243 hasher. update ( vk_bytes) ;
3344 hasher. update ( self . proof_with_pub_values . public_values . as_slice ( ) ) ;
3445 hasher. finalize ( ) . into ( )
3546 }
36-
37- pub fn vk ( & self ) -> SP1VerifyingKey {
38- // it is safe to unwrap here as we only support compressed proofs for sp1
39- let vk = self
40- . proof_with_pub_values
41- . proof
42- . try_as_compressed_ref ( )
43- . unwrap ( )
44- . vk
45- . clone ( ) ;
46-
47- SP1VerifyingKey { vk }
48- }
4947}
5048
5149#[ derive( Debug ) ]
@@ -70,15 +68,15 @@ pub(crate) fn run_user_proofs_aggregator(
7068 . proofs_vk_and_pub_inputs
7169 . push ( SP1VkAndPubInputs {
7270 public_inputs : proof. proof_with_pub_values . public_values . to_vec ( ) ,
73- vk : proof. vk ( ) . hash_u32 ( ) ,
71+ vk : proof. vk . hash_u32 ( ) ,
7472 } ) ;
7573 }
7674
7775 stdin. write ( & program_input) ;
7876
7977 // write proofs
8078 for input_proof in proofs. iter ( ) {
81- let vk = input_proof. vk ( ) . vk ;
79+ let vk = input_proof. vk . vk . clone ( ) ;
8280 // we only support sp1 Compressed proofs for now
8381 let sp1_sdk:: SP1Proof :: Compressed ( proof) = input_proof. proof_with_pub_values . proof . clone ( )
8482 else {
@@ -110,6 +108,7 @@ pub(crate) fn run_user_proofs_aggregator(
110108 let proof_and_elf = SP1ProofWithPubValuesAndElf {
111109 proof_with_pub_values : proof,
112110 elf : USER_PROOFS_PROGRAM_ELF . to_vec ( ) ,
111+ vk,
113112 } ;
114113
115114 Ok ( proof_and_elf)
@@ -129,7 +128,7 @@ pub(crate) fn run_chunk_aggregator(
129128 program_input. proofs_and_leaves_commitment . push ( (
130129 SP1VkAndPubInputs {
131130 public_inputs : proof. proof_with_pub_values . public_values . to_vec ( ) ,
132- vk : proof. vk ( ) . hash_u32 ( ) ,
131+ vk : proof. vk . hash_u32 ( ) ,
133132 } ,
134133 leaves_commitment. clone ( ) ,
135134 ) ) ;
@@ -139,7 +138,7 @@ pub(crate) fn run_chunk_aggregator(
139138
140139 // write proofs
141140 for ( input_proof, _) in proofs. iter ( ) {
142- let vk = input_proof. vk ( ) . vk ;
141+ let vk = input_proof. vk . vk . clone ( ) ;
143142 // we only support sp1 Compressed proofs for now
144143 let sp1_sdk:: SP1Proof :: Compressed ( proof) = input_proof. proof_with_pub_values . proof . clone ( )
145144 else {
@@ -182,6 +181,7 @@ pub(crate) fn run_chunk_aggregator(
182181 let proof_and_elf = SP1ProofWithPubValuesAndElf {
183182 proof_with_pub_values : proof,
184183 elf : CHUNK_PROGRAM_ELF . to_vec ( ) ,
184+ vk,
185185 } ;
186186
187187 Ok ( proof_and_elf)
0 commit comments