Skip to content

Commit

Permalink
Range Checks for Poseidon Builtin
Browse files Browse the repository at this point in the history
  • Loading branch information
Gali-StarkWare committed Feb 13, 2025
1 parent f61e1b2 commit 72336c7
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 5 deletions.
37 changes: 34 additions & 3 deletions stwo_cairo_prover/crates/prover/src/cairo_air/debug_tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ use stwo_prover::core::poly::circle::CanonicCoset;

use super::air::CairoClaim;
use crate::components::range_check_vector::{
range_check_11, range_check_12, range_check_18, range_check_19, range_check_3_6,
range_check_3_6_6_3, range_check_4_3, range_check_6, range_check_7_2_5, range_check_9_9,
range_check_11, range_check_12, range_check_18, range_check_19, range_check_3_3_3_3_3,
range_check_3_6, range_check_3_6_6_3, range_check_4_3, range_check_4_4, range_check_4_4_4_4,
range_check_6, range_check_7_2_5, range_check_9_9,
};
use crate::components::{
add_ap_opcode, add_ap_opcode_imm, add_ap_opcode_op_1_base_fp, add_opcode, add_opcode_imm,
Expand Down Expand Up @@ -674,6 +675,16 @@ where
)
.entries(trace),
);
entries.extend(
RelationTrackerComponent::new(
tree_span_provider,
range_check_4_4::Eval {
lookup_elements: relations::RangeCheck_4_4::dummy(),
},
1 << 8,
)
.entries(trace),
);
entries.extend(
RelationTrackerComponent::new(
tree_span_provider,
Expand All @@ -700,7 +711,27 @@ where
range_check_3_6_6_3::Eval {
lookup_elements: relations::RangeCheck_3_6_6_3::dummy(),
},
1 << 14,
1 << 18,
)
.entries(trace),
);
entries.extend(
RelationTrackerComponent::new(
tree_span_provider,
range_check_4_4_4_4::Eval {
lookup_elements: relations::RangeCheck_4_4_4_4::dummy(),
},
1 << 16,
)
.entries(trace),
);
entries.extend(
RelationTrackerComponent::new(
tree_span_provider,
range_check_3_3_3_3_3::Eval {
lookup_elements: relations::RangeCheck_3_3_3_3_3::dummy(),
},
1 << 15,
)
.entries(trace),
);
Expand Down
25 changes: 25 additions & 0 deletions stwo_cairo_prover/crates/prover/src/cairo_air/preprocessed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ fn gen_range_check_columns() -> Vec<Box<dyn PreProcessedColumn>> {
// RangeCheck_4_3.
let range_check_4_3_col_0 = RangeCheck::new([4, 3], 0);
let range_check_4_3_col_1 = RangeCheck::new([4, 3], 1);
// RangeCheck_4_4.
let range_check_4_4_col_0 = RangeCheck::new([4, 4], 0);
let range_check_4_4_col_1 = RangeCheck::new([4, 4], 1);
// RangeCheck_9_9.
let range_check_9_9_col_0 = RangeCheck::new([9, 9], 0);
let range_check_9_9_col_1 = RangeCheck::new([9, 9], 1);
Expand All @@ -112,6 +115,17 @@ fn gen_range_check_columns() -> Vec<Box<dyn PreProcessedColumn>> {
let range_check_3_6_6_3_col_1 = RangeCheck::new([3, 6, 6, 3], 1);
let range_check_3_6_6_3_col_2 = RangeCheck::new([3, 6, 6, 3], 2);
let range_check_3_6_6_3_col_3 = RangeCheck::new([3, 6, 6, 3], 3);
// RangeCheck_4_4_4_4.
let range_check_4_4_4_4_col_0 = RangeCheck::new([4, 4, 4, 4], 0);
let range_check_4_4_4_4_col_1 = RangeCheck::new([4, 4, 4, 4], 1);
let range_check_4_4_4_4_col_2 = RangeCheck::new([4, 4, 4, 4], 2);
let range_check_4_4_4_4_col_3 = RangeCheck::new([4, 4, 4, 4], 3);
// RangeCheck_3_3_3_3_3.
let range_check_3_3_3_3_3_col_0 = RangeCheck::new([3, 3, 3, 3, 3], 0);
let range_check_3_3_3_3_3_col_1 = RangeCheck::new([3, 3, 3, 3, 3], 1);
let range_check_3_3_3_3_3_col_2 = RangeCheck::new([3, 3, 3, 3, 3], 2);
let range_check_3_3_3_3_3_col_3 = RangeCheck::new([3, 3, 3, 3, 3], 3);
let range_check_3_3_3_3_3_col_4 = RangeCheck::new([3, 3, 3, 3, 3], 4);

vec![
Box::new(range_check_6),
Expand All @@ -123,6 +137,8 @@ fn gen_range_check_columns() -> Vec<Box<dyn PreProcessedColumn>> {
Box::new(range_check_3_6_col_1),
Box::new(range_check_4_3_col_0),
Box::new(range_check_4_3_col_1),
Box::new(range_check_4_4_col_0),
Box::new(range_check_4_4_col_1),
Box::new(range_check_9_9_col_0),
Box::new(range_check_9_9_col_1),
Box::new(range_check_7_2_5_col_0),
Expand All @@ -132,6 +148,15 @@ fn gen_range_check_columns() -> Vec<Box<dyn PreProcessedColumn>> {
Box::new(range_check_3_6_6_3_col_1),
Box::new(range_check_3_6_6_3_col_2),
Box::new(range_check_3_6_6_3_col_3),
Box::new(range_check_4_4_4_4_col_0),
Box::new(range_check_4_4_4_4_col_1),
Box::new(range_check_4_4_4_4_col_2),
Box::new(range_check_4_4_4_4_col_3),
Box::new(range_check_3_3_3_3_3_col_0),
Box::new(range_check_3_3_3_3_3_col_1),
Box::new(range_check_3_3_3_3_3_col_2),
Box::new(range_check_3_3_3_3_3_col_3),
Box::new(range_check_3_3_3_3_3_col_4),
]
}

Expand Down
Loading

0 comments on commit 72336c7

Please sign in to comment.