@@ -5,7 +5,7 @@ use std::sync::Arc;
55use apollo_sizeof:: SizeOf ;
66use privacy_circuit_verify:: { verify_recursive_circuit, PrivacyProofOutput } ;
77use serde:: { Deserialize , Serialize } ;
8- use starknet_api:: transaction:: fields:: { Proof , ProofFacts , PROOF_VERSION_V0 } ;
8+ use starknet_api:: transaction:: fields:: { Proof , ProofFacts , PROOF_VERSION_V0 , PROOF_VERSION_V1 } ;
99use starknet_types_core:: felt:: Felt ;
1010use thiserror:: Error ;
1111
@@ -15,8 +15,8 @@ pub enum VerifyProofError {
1515 EmptyProof ,
1616 #[ error( transparent) ]
1717 ProgramOutputError ( #[ from] ProgramOutputError ) ,
18- #[ error( "Invalid proof version: expected {expected }, got {actual} ." ) ]
19- InvalidProofVersion { expected : Felt , actual : Felt } ,
18+ #[ error( "Unsupported proof version: got {actual }, expected V0 ({v0}) or V1 ({v1}) ." ) ]
19+ InvalidProofVersion { v0 : Felt , v1 : Felt , actual : Felt } ,
2020 #[ error( "Proof facts too short: expected at least 3 elements, got {length}." ) ]
2121 ProofFactsTooShort { length : usize } ,
2222 #[ error( "Proof verification failed: {0}" ) ]
@@ -29,9 +29,9 @@ impl PartialEq for VerifyProofError {
2929 ( Self :: EmptyProof , Self :: EmptyProof ) => true ,
3030 ( Self :: ProgramOutputError ( lhs) , Self :: ProgramOutputError ( rhs) ) => lhs == rhs,
3131 (
32- Self :: InvalidProofVersion { expected : exp_l , actual : act_l } ,
33- Self :: InvalidProofVersion { expected : exp_r , actual : act_r } ,
34- ) => exp_l == exp_r && act_l == act_r,
32+ Self :: InvalidProofVersion { v0 : v0_l , v1 : v1_l , actual : act_l } ,
33+ Self :: InvalidProofVersion { v0 : v0_r , v1 : v1_r , actual : act_r } ,
34+ ) => v0_l == v0_r && v1_l == v1_r && act_l == act_r,
3535 ( Self :: Verification ( lhs) , Self :: Verification ( rhs) ) => lhs == rhs,
3636 ( Self :: ProofFactsTooShort { length : l } , Self :: ProofFactsTooShort { length : r } ) => {
3737 l == r
@@ -119,19 +119,22 @@ pub fn reconstruct_output_preimage(
119119}
120120
121121/// Verifies a submitted proof against the proof facts using the circuit verifier.
122+ ///
123+ /// Accepts either V0 (legacy) or V1 (current) proof versions. Both currently resolve to the same
124+ /// upstream circuit revision. When the V1 circuit revision is bumped, V0 verification should be
125+ /// routed to a `privacy-circuit-verify-legacy` alias pinned to the old revision.
122126pub fn verify_proof ( proof_facts : ProofFacts , proof : Proof ) -> Result < ( ) , VerifyProofError > {
123127 // Reject empty proof payloads before running the verifier.
124128 if proof. is_empty ( ) {
125129 return Err ( VerifyProofError :: EmptyProof ) ;
126130 }
127131
128- // Validate that the first element of proof facts is PROOF_VERSION_V0.
129- let expected_proof_version = PROOF_VERSION_V0 ;
130- let actual_first = proof_facts. 0 . first ( ) . copied ( ) . unwrap_or_default ( ) ;
131- if actual_first != expected_proof_version {
132+ let proof_version = proof_facts. 0 . first ( ) . copied ( ) . unwrap_or_default ( ) ;
133+ if proof_version != PROOF_VERSION_V0 && proof_version != PROOF_VERSION_V1 {
132134 return Err ( VerifyProofError :: InvalidProofVersion {
133- expected : expected_proof_version,
134- actual : actual_first,
135+ v0 : PROOF_VERSION_V0 ,
136+ v1 : PROOF_VERSION_V1 ,
137+ actual : proof_version,
135138 } ) ;
136139 }
137140
0 commit comments