Skip to content

Commit 54e2cbf

Browse files
starknet_api,starknet_proof_verifier: rename PROOF_VERSION to PROOF_VERSION_V0 (#14011)
1 parent 834c553 commit 54e2cbf

5 files changed

Lines changed: 26 additions & 22 deletions

File tree

crates/starknet_api/src/test_utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crate::transaction::fields::{
3535
ProofFacts,
3636
ResourceBounds,
3737
ValidResourceBounds,
38-
PROOF_VERSION,
38+
PROOF_VERSION_V0,
3939
VIRTUAL_OS_OUTPUT_VERSION,
4040
VIRTUAL_SNOS,
4141
};
@@ -413,7 +413,7 @@ impl ProofFacts {
413413
// These fields are not verified by the OS (they are application-related).
414414
let l2_to_l1_messages_segment_size = Felt::ZERO;
415415
proof_facts![
416-
PROOF_VERSION,
416+
PROOF_VERSION_V0,
417417
VIRTUAL_SNOS,
418418
program_hash,
419419
VIRTUAL_OS_OUTPUT_VERSION,

crates/starknet_api/src/transaction/fields.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,8 @@ impl AccountDeploymentData {
630630
// Represent the string `VIRTUAL_SNOS` as a Felt.
631631
pub const VIRTUAL_SNOS: Felt = Felt::from_hex_unchecked("0x5649525455414c5f534e4f53");
632632

633-
// Represent the `PROOF_VERSION` marker as a Felt ('PROOF0').
634-
pub const PROOF_VERSION: Felt = Felt::from_hex_unchecked("0x50524f4f4630");
633+
// Represent the `PROOF_VERSION_V0` marker as a Felt ('PROOF0').
634+
pub const PROOF_VERSION_V0: Felt = Felt::from_hex_unchecked("0x50524f4f4630");
635635

636636
/// The version of the virtual OS output (short string 'VIRTUAL_SNOS0').
637637
/// This must match the Cairo constant `VIRTUAL_OS_OUTPUT_VERSION` in `virtual_os_output.cairo`.
@@ -681,11 +681,11 @@ impl TryFrom<&ProofFacts> for ProofFactsVariant {
681681
)));
682682
};
683683

684-
// Validate that the first element is PROOF_VERSION.
685-
if *proof_version != PROOF_VERSION {
684+
// Validate that the first element is PROOF_VERSION_V0.
685+
if *proof_version != PROOF_VERSION_V0 {
686686
return Err(StarknetApiError::InvalidProofFacts(format!(
687-
"Expected first field to be {} (PROOF_VERSION), but got {}",
688-
PROOF_VERSION, proof_version
687+
"Expected first field to be {} (PROOF_VERSION_V0), but got {}",
688+
PROOF_VERSION_V0, proof_version
689689
)));
690690
}
691691

crates/starknet_os/src/constants_test.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ use starknet_api::core::{
88
L2_ADDRESS_UPPER_BOUND,
99
STARKNET_OS_CONFIG_HASH_VERSION,
1010
};
11-
use starknet_api::transaction::fields::{PROOF_VERSION, VIRTUAL_OS_OUTPUT_VERSION, VIRTUAL_SNOS};
11+
use starknet_api::transaction::fields::{
12+
PROOF_VERSION_V0,
13+
VIRTUAL_OS_OUTPUT_VERSION,
14+
VIRTUAL_SNOS,
15+
};
1216
use starknet_api::versioned_constants_logic::VersionedConstantsTrait;
1317
use starknet_committer::hash_function::hash::CONTRACT_CLASS_LEAF_V0;
1418

@@ -78,10 +82,10 @@ fn test_virtual_snos() {
7882
assert_eq!(Const::VirtualSnos.fetch_from_os_program().unwrap(), VIRTUAL_SNOS);
7983
}
8084

81-
/// Asserts that the Rust PROOF_VERSION constant matches the Cairo constant.
85+
/// Asserts that the Rust PROOF_VERSION_V0 constant matches the Cairo constant.
8286
#[test]
8387
fn test_proof_version() {
84-
assert_eq!(Const::ProofVersion.fetch_from_os_program().unwrap(), PROOF_VERSION);
88+
assert_eq!(Const::ProofVersion.fetch_from_os_program().unwrap(), PROOF_VERSION_V0);
8589
}
8690

8791
/// Asserts that the Rust STARKNET_OS_CONFIG_HASH_VERSION constant matches the Cairo constant.

crates/starknet_proof_verifier/src/proof_verifier.rs

Lines changed: 8 additions & 8 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};
8+
use starknet_api::transaction::fields::{Proof, ProofFacts, PROOF_VERSION_V0};
99
use starknet_types_core::felt::Felt;
1010
use thiserror::Error;
1111

@@ -68,7 +68,7 @@ impl ProgramOutput {
6868
/// The bootloader output for a single task is:
6969
/// `[num_tasks, output_size, program_hash, ...task_output...]`
7070
///
71-
/// We replace `num_tasks` with `[PROOF_VERSION, program_variant]` and skip `output_size`,
71+
/// We replace `num_tasks` with `[PROOF_VERSION_V0, program_variant]` and skip `output_size`,
7272
/// which is a bootloader-internal field not part of the proof facts.
7373
pub fn try_into_proof_facts(
7474
&self,
@@ -83,7 +83,7 @@ impl ProgramOutput {
8383
return Err(ProgramOutputError::TooShort(self.0.len()));
8484
}
8585
// Add the proof version and variant markers in place of num_tasks.
86-
let mut facts = vec![PROOF_VERSION];
86+
let mut facts = vec![PROOF_VERSION_V0];
8787
facts.push(program_variant);
8888
// Skip num_tasks (index 0) and output_size (index 1); add the task output
8989
// (program_hash followed by the virtual OS output).
@@ -100,17 +100,17 @@ impl From<Vec<Felt>> for ProgramOutput {
100100

101101
/// Reconstructs the output preimage from proof facts for circuit verification.
102102
///
103-
/// Proof facts layout: `[PROOF_VERSION, variant, program_hash, ...task_output]`
103+
/// Proof facts layout: `[PROOF_VERSION_V0, variant, program_hash, ...task_output]`
104104
/// Output preimage layout: `[num_tasks=1, output_size, program_hash, ...task_output]`
105105
/// where `output_size = task_content.len() + 1` (includes itself).
106106
pub fn reconstruct_output_preimage(
107107
proof_facts: &ProofFacts,
108108
) -> Result<Vec<Felt>, VerifyProofError> {
109-
// Proof facts must contain at least [PROOF_VERSION, variant, program_hash].
109+
// Proof facts must contain at least [PROOF_VERSION_V0, variant, program_hash].
110110
if proof_facts.0.len() < 3 {
111111
return Err(VerifyProofError::ProofFactsTooShort { length: proof_facts.0.len() });
112112
}
113-
// Skip PROOF_VERSION (index 0) and variant (index 1).
113+
// Skip PROOF_VERSION_V0 (index 0) and variant (index 1).
114114
let task_content = &proof_facts.0[2..];
115115
let output_size = Felt::from(
116116
u64::try_from(task_content.len() + 1).expect("task content length exceeds u64::MAX"),
@@ -125,8 +125,8 @@ pub fn verify_proof(proof_facts: ProofFacts, proof: Proof) -> Result<(), VerifyP
125125
return Err(VerifyProofError::EmptyProof);
126126
}
127127

128-
// Validate that the first element of proof facts is PROOF_VERSION.
129-
let expected_proof_version = PROOF_VERSION;
128+
// Validate that the first element of proof facts is PROOF_VERSION_V0.
129+
let expected_proof_version = PROOF_VERSION_V0;
130130
let actual_first = proof_facts.0.first().copied().unwrap_or_default();
131131
if actual_first != expected_proof_version {
132132
return Err(VerifyProofError::InvalidProofVersion {

crates/starknet_proof_verifier/src/proof_verifier_test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rstest::rstest;
22
use starknet_api::test_utils::{path_in_resources, read_json_file};
3-
use starknet_api::transaction::fields::{Proof, ProofFacts, PROOF_VERSION};
3+
use starknet_api::transaction::fields::{Proof, ProofFacts, PROOF_VERSION_V0};
44
use starknet_types_core::felt::Felt;
55

66
use crate::{reconstruct_output_preimage, verify_proof, ProgramOutput};
@@ -21,8 +21,8 @@ fn roundtrip_program_output_to_proof_facts_and_back() {
2121
let program_variant = Felt::from(0x42_u64);
2222
let proof_facts = program_output.try_into_proof_facts(program_variant).unwrap();
2323

24-
// Verify the proof facts structure: [PROOF_VERSION, variant, program_hash, ...task_output].
25-
assert_eq!(proof_facts.0[0], PROOF_VERSION);
24+
// Verify the proof facts structure: [PROOF_VERSION_V0, variant, program_hash, ...task_output].
25+
assert_eq!(proof_facts.0[0], PROOF_VERSION_V0);
2626
assert_eq!(proof_facts.0[1], program_variant);
2727
assert_eq!(proof_facts.0[2], program_hash);
2828
assert_eq!(&proof_facts.0[3..], &task_output);

0 commit comments

Comments
 (0)