Skip to content

Commit 90c0ffc

Browse files
starknet_proof_verifier: accept either PROOF_VERSION_V0 or PROOF_VERSION_V1 in verify_proof
1 parent c7f441b commit 90c0ffc

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

crates/starknet_proof_verifier/src/proof_verifier.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::sync::Arc;
55
use apollo_sizeof::SizeOf;
66
use privacy_circuit_verify::{verify_recursive_circuit, PrivacyProofOutput};
77
use 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};
99
use starknet_types_core::felt::Felt;
1010
use 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.
122126
pub 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

Comments
 (0)