Skip to content

Commit

Permalink
migrated opcodes air out of cairo air
Browse files Browse the repository at this point in the history
  • Loading branch information
ohad-starkware committed Dec 1, 2024
1 parent 3aeb156 commit dd827e7
Show file tree
Hide file tree
Showing 4 changed files with 537 additions and 36 deletions.
38 changes: 5 additions & 33 deletions stwo_cairo_prover/crates/prover/src/cairo_air/air.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ use stwo_prover::core::prover::StarkProof;
use stwo_prover::core::vcs::blake2_merkle::Blake2sMerkleChannel;
use stwo_prover::core::vcs::ops::MerkleHasher;

use super::opcodes_air::{
OpcodeClaim, OpcodeComponents, OpcodeInteractionClaim, OpcodesClaimGenerator,
OpcodesInteractionClaimGenerator,
};
use super::IS_FIRST_LOG_SIZES;
use crate::components::memory::{memory_address_to_id, memory_id_to_big};
use crate::components::range_check_vector::{
range_check_19, range_check_4_3, range_check_7_2_5, range_check_9_9,
};
use crate::components::{
add_ap_opcode_is_imm_f_op1_base_fp_f, add_ap_opcode_is_imm_f_op1_base_fp_t,
add_ap_opcode_is_imm_t_op1_base_fp_f, generic_opcode, ret_opcode, verify_instruction,
};
use crate::components::verify_instruction;
use crate::felt::split_f252;
use crate::input::state_transitions::StateTransitions;
use crate::input::CairoInput;
use crate::relations;

Expand All @@ -39,34 +39,6 @@ pub struct CairoProof<H: MerkleHasher> {
// (Address, Id, Value)
pub type PublicMemory = Vec<(u32, u32, [u32; 8])>;

#[derive(Serialize, Deserialize)]
pub struct OpcodeClaim {
add_ap_f_f: Vec<add_ap_opcode_is_imm_f_op1_base_fp_f::Claim>,
add_ap_f_t: Vec<add_ap_opcode_is_imm_f_op1_base_fp_t::Claim>,
add_ap_t_f: Vec<add_ap_opcode_is_imm_t_op1_base_fp_f::Claim>,
ret: Vec<ret_opcode::Claim>,
generic: Vec<generic_opcode::Claim>,
}
impl OpcodeClaim {
pub fn mix_into(&self, channel: &mut impl Channel) {
self.add_ap_f_f.iter().for_each(|c| c.mix_into(channel));
self.add_ap_f_t.iter().for_each(|c| c.mix_into(channel));
self.add_ap_t_f.iter().for_each(|c| c.mix_into(channel));
self.ret.iter().for_each(|c| c.mix_into(channel));
self.generic.iter().for_each(|c| c.mix_into(channel));
}

pub fn log_sizes(&self) -> TreeVec<Vec<u32>> {
TreeVec::concat_cols(chain!(
self.add_ap_f_f.iter().map(|c| c.log_sizes()),
self.add_ap_f_t.iter().map(|c| c.log_sizes()),
self.add_ap_t_f.iter().map(|c| c.log_sizes()),
self.generic.iter().map(|c| c.log_sizes()),
self.ret.iter().map(|c| c.log_sizes()),
))
}
}

#[derive(Serialize, Deserialize)]
pub struct CairoClaim {
pub public_data: PublicData,
Expand Down
3 changes: 2 additions & 1 deletion stwo_cairo_prover/crates/prover/src/cairo_air/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod air;
pub mod opcodes_air;

use air::{lookup_sum, CairoClaimGenerator, CairoComponents, CairoInteractionElements, CairoProof};
use num_traits::Zero;
Expand All @@ -17,7 +18,7 @@ use crate::input::CairoInput;

const LOG_MAX_ROWS: u32 = 20;

const IS_FIRST_LOG_SIZES: [u32; 7] = [18, 4, 14, 19, 7, 6, 5];
const IS_FIRST_LOG_SIZES: [u32; 16] = [19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4];
pub fn prove_cairo(input: CairoInput) -> Result<CairoProof<Blake2sMerkleHasher>, ProvingError> {
let _span = span!(Level::INFO, "prove_cairo").entered();
let config = PcsConfig::default();
Expand Down
Loading

0 comments on commit dd827e7

Please sign in to comment.