Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get range check inputs one by one. #25

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions stwo_cairo_prover/src/components/range_check_unit/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,13 @@ impl ComponentGen for RangeCheckUnitTraceGenerator {}

impl ComponentTraceGenerator<CpuBackend> for RangeCheckUnitTraceGenerator {
type Component = RangeCheckUnitComponent;
type Inputs = Vec<BaseField>;
type Inputs = BaseField;

fn add_inputs(&mut self, inputs: &Self::Inputs) {
for input in inputs {
let input = input.0 as usize;
// TODO: replace the debug_assert! with an error return.
debug_assert!(input < self.max_value, "Input out of range");
self.multiplicities[input] += 1;
}
let input = inputs.0 as usize;
// TODO: replace the debug_assert! with an error return.
debug_assert!(input < self.max_value, "Input out of range");
self.multiplicities[input] += 1;
}

fn write_trace(
Expand Down
12 changes: 6 additions & 6 deletions stwo_cairo_prover/src/components/range_check_unit/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ mod tests {
use std::collections::BTreeMap;

use component::{RangeCheckUnitComponent, RangeCheckUnitTraceGenerator, RC_COMPONENT_ID, RC_Z};
use itertools::Itertools;
use stwo_prover::core::air::{Air, AirProver, Component, ComponentProver};
use stwo_prover::core::backend::CpuBackend;
use stwo_prover::core::channel::{Blake2sChannel, Channel};
Expand All @@ -28,7 +27,7 @@ mod tests {

pub fn register_test_rc(registry: &mut ComponentGenerationRegistry) {
registry.register(RC_COMPONENT_ID, RangeCheckUnitTraceGenerator::new(8));
let inputs = vec![
vec![
vec![BaseField::from_u32_unchecked(0); 3],
vec![BaseField::from_u32_unchecked(1); 1],
vec![BaseField::from_u32_unchecked(2); 2],
Expand All @@ -40,10 +39,11 @@ mod tests {
]
.into_iter()
.flatten()
.collect_vec();
registry
.get_generator_mut::<RangeCheckUnitTraceGenerator>(RC_COMPONENT_ID)
.add_inputs(&inputs);
.for_each(|input| {
registry
.get_generator_mut::<RangeCheckUnitTraceGenerator>(RC_COMPONENT_ID)
.add_inputs(&input);
});
}

struct TestAirGenerator {
Expand Down
Loading