Skip to content

Commit

Permalink
Update names of lookup elements
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmilson committed Feb 2, 2025
1 parent 74d7c86 commit 6f09702
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub impl InteractionClaimImpl of InteractionClaimTrait {
pub struct Component {
pub claim: Claim,
pub interaction_claim: InteractionClaim,
pub lookup_elements: super::super::AddrToIdElements,
pub lookup_elements: super::super::MemoryAddressToIdElements,
}

pub impl ComponentImpl of CairoComponent<Component> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ pub impl InteractionClaimImpl of InteractionClaimTrait {
pub struct Component {
pub claim: Claim,
pub interaction_claim: InteractionClaim,
pub memoryaddresstoid_lookup_elements: super::super::AddrToIdElements,
pub memoryidtobig_lookup_elements: super::super::IdToValueElements,
pub memoryaddresstoid_lookup_elements: super::super::MemoryAddressToIdElements,
pub memoryidtobig_lookup_elements: super::super::MemoryIdToBigElements,
pub range_check_19_lookup_elements: super::super::RangeCheck19BitElements,
pub range_check_9_9_lookup_elements: super::super::RangeCheck9Bit9BitElements,
pub verifyinstruction_lookup_elements: super::super::VerifyInstructionElements,
pub opcodes_lookup_elements: super::super::VmElements,
pub opcodes_lookup_elements: super::super::OpcodeElements,
}

pub impl ComponentImpl of CairoComponent<Component> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub impl InteractionClaimImpl of InteractionClaimTrait {
pub struct BigComponent {
pub log_n_rows: u32,
pub interaction_claim: InteractionClaim,
pub lookup_elements: super::super::IdToValueElements,
pub lookup_elements: super::super::MemoryIdToBigElements,
pub range_9_9_lookup_elements: super::super::RangeCheck9Bit9BitElements,
}

Expand Down Expand Up @@ -222,7 +222,7 @@ pub impl BigComponentImpl of CairoComponent<BigComponent> {
pub struct SmallComponent {
pub log_n_rows: u32,
pub interaction_claim: InteractionClaim,
pub lookup_elements: super::super::IdToValueElements,
pub lookup_elements: super::super::MemoryIdToBigElements,
pub range_9_9_lookup_elements: super::super::RangeCheck9Bit9BitElements,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ pub impl InteractionClaimImpl of InteractionClaimTrait {
pub struct Component {
pub claim: Claim,
pub interaction_claim: InteractionClaim,
pub memoryaddresstoid_lookup_elements: super::super::AddrToIdElements,
pub memoryidtobig_lookup_elements: super::super::IdToValueElements,
pub memoryaddresstoid_lookup_elements: super::super::MemoryAddressToIdElements,
pub memoryidtobig_lookup_elements: super::super::MemoryIdToBigElements,
pub verifyinstruction_lookup_elements: super::super::VerifyInstructionElements,
pub opcodes_lookup_elements: super::super::VmElements,
pub opcodes_lookup_elements: super::super::OpcodeElements,
}

pub impl ComponentImpl of CairoComponent<Component> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ pub impl InteractionClaimImpl of InteractionClaimTrait {
pub struct Component {
pub claim: Claim,
pub interaction_claim: InteractionClaim,
pub memoryaddresstoid_lookup_elements: super::super::AddrToIdElements,
pub memoryidtobig_lookup_elements: super::super::IdToValueElements,
pub memoryaddresstoid_lookup_elements: super::super::MemoryAddressToIdElements,
pub memoryidtobig_lookup_elements: super::super::MemoryIdToBigElements,
pub verifyinstruction_lookup_elements: super::super::VerifyInstructionElements,
pub opcodes_lookup_elements: super::super::VmElements,
pub opcodes_lookup_elements: super::super::OpcodeElements,
}

pub impl ComponentImpl of CairoComponent<Component> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use crate::components::CairoComponent;
use crate::utils::U32Impl;
use stwo_constraint_framework::{
ClaimedPrefixSum, PreprocessedColumn, PreprocessedColumnSet, PreprocessedMaskValues,
PreprocessedMaskValuesImpl,
PreprocessedColumnSet, PreprocessedColumn, PreprocessedMaskValues, PreprocessedMaskValuesImpl,
};
use stwo_verifier_core::channel::{Channel, ChannelImpl};
use stwo_verifier_core::circle::CirclePoint;
use stwo_verifier_core::fields::qm31::{QM31, QM31Zero, QM31_EXTENSION_DEGREE};
use stwo_verifier_core::poly::circle::CanonicCosetImpl;
use stwo_verifier_core::utils::ArrayImpl;
use stwo_verifier_core::{ColumnArray, ColumnSpan, TreeArray};
use crate::components::CairoComponent;
use crate::utils::U32Impl;
use super::super::utils::UsizeExTrait;
use super::super::Invertible;

mod constraints;
Expand All @@ -26,10 +26,13 @@ pub impl ClaimImpl of ClaimTrait {
}

fn log_sizes(self: @Claim) -> TreeArray<Span<u32>> {
const N_LOOKUPS: usize = 5;
let log_size = self.log_size();
let preprocesed_trace_log_sizes = array![log_size].span();
let trace_log_sizes = ArrayImpl::new_repeated(29, log_size).span();
let interaction_log_sizes = ArrayImpl::new_repeated(QM31_EXTENSION_DEGREE * 3, log_size)
let interaction_log_sizes = ArrayImpl::new_repeated(
QM31_EXTENSION_DEGREE * N_LOOKUPS.div_ceil(2), log_size,
)
.span();
array![preprocesed_trace_log_sizes, trace_log_sizes, interaction_log_sizes]
}
Expand All @@ -55,8 +58,8 @@ pub impl InteractionClaimImpl of InteractionClaimTrait {
pub struct Component {
pub claim: Claim,
pub interaction_claim: InteractionClaim,
pub memoryaddresstoid_lookup_elements: super::super::AddrToIdElements,
pub memoryidtobig_lookup_elements: super::super::IdToValueElements,
pub memoryaddresstoid_lookup_elements: super::super::MemoryAddressToIdElements,
pub memoryidtobig_lookup_elements: super::super::MemoryIdToBigElements,
pub rangecheck_4_3_lookup_elements: super::super::RangeCheck4Bit3BitElements,
pub range_check_7_2_5_lookup_elements: super::super::RangeCheck7Bit2Bit5BitElements,
pub verifyinstruction_lookup_elements: super::super::VerifyInstructionElements,
Expand Down
19 changes: 13 additions & 6 deletions stwo_cairo_verifier/crates/cairo_air/src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,19 @@ const PREPROCESSED_COLUMNS_LOG_SIZES: [u32; 19] = [
// (Address, Id, Value)
pub type PublicMemory = Array<(u32, u32, [u32; 8])>;

type VmElements = LookupElements<3>;
type OpcodeElements = LookupElements<3>;

type VerifyInstructionElements = LookupElements<29>;

type AddrToIdElements = LookupElements<2>;
type MemoryAddressToIdElements = LookupElements<2>;

type IdToValueElements = LookupElements<29>;
type MemoryIdToBigElements = LookupElements<29>;

type RangeCheck3BitElements = LookupElements<1>;

type RangeCheck6BitElements = LookupElements<1>;

type RangeCheck18BitElements = LookupElements<1>;

type RangeCheck19BitElements = LookupElements<1>;

Expand All @@ -65,6 +71,7 @@ type RangeCheck7Bit2Bit5BitElements = LookupElements<3>;

type RangeCheck4Bit3BitElements = LookupElements<2>;


#[derive(Drop, Serde)]
pub struct CairoProof {
pub claim: CairoClaim,
Expand Down Expand Up @@ -146,10 +153,10 @@ pub fn lookup_sum(

#[derive(Drop)]
struct CairoInteractionElements {
pub opcodes: VmElements,
pub opcodes: OpcodeElements,
pub verify_instruction: VerifyInstructionElements,
pub memory_addr_to_id: AddrToIdElements,
pub memory_id_to_value: IdToValueElements,
pub memory_addr_to_id: MemoryAddressToIdElements,
pub memory_id_to_value: MemoryIdToBigElements,
pub range_check_19: RangeCheck19BitElements,
pub range_check_9_9: RangeCheck9Bit9BitElements,
pub range_check_7_2_5: RangeCheck7Bit2Bit5BitElements,
Expand Down

0 comments on commit 6f09702

Please sign in to comment.