Skip to content

Commit 6768372

Browse files
authored
Extend enter_region method (#5)
1 parent 117cc2d commit 6768372

3 files changed

Lines changed: 30 additions & 3 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ members = [
55
resolver = "2"
66

77
[workspace.package]
8-
version = "0.2.0"
8+
version = "0.3.0"
99
authors = ["Daniel Dominguez (Veridise) <daniel@veridise.com>"]
1010
edition = "2024"
1111
rust-version = "1.85"

core/src/synthesis.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use ff::Field;
55
use crate::{
66
info_traits::{GroupInfo, SelectorInfo},
77
query::{Advice, Fixed},
8-
table::{Any, Column},
8+
table::{Any, Column, RegionIndex, RegionStart},
99
};
1010

1111
/// Unique identifier for a group.
@@ -17,8 +17,17 @@ pub type GroupKey = u64;
1717
pub trait SynthesizerLike<F: Field> {
1818
/// Enters a new region of the circuit.
1919
///
20+
/// If the region index and starting row is known at this point is better to give
21+
/// this information now since it avoids having to infer the information from context clues
22+
/// later.
23+
///
2024
/// Panics if the synthesizer entered a region already and didn't exit.
21-
fn enter_region(&mut self, region_name: String);
25+
fn enter_region(
26+
&mut self,
27+
region_name: String,
28+
region_index: Option<RegionIndex>,
29+
region_start: Option<RegionStart>,
30+
);
2231

2332
/// Exits the current region of the circuit.
2433
///

core/src/table.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,24 @@ impl From<usize> for RegionIndex {
214214
}
215215
}
216216

217+
/// Replacement for Halo2's `RegionStart` type.
218+
#[derive(Eq, Hash, PartialEq, Debug, Copy, Clone)]
219+
pub struct RegionStart(usize);
220+
221+
impl Deref for RegionStart {
222+
type Target = usize;
223+
224+
fn deref(&self) -> &Self::Target {
225+
&self.0
226+
}
227+
}
228+
229+
impl From<usize> for RegionStart {
230+
fn from(value: usize) -> Self {
231+
Self(value)
232+
}
233+
}
234+
217235
/// Errors related to the PLONK table.
218236
#[derive(Error, Copy, Clone, Debug)]
219237
pub enum TableError {

0 commit comments

Comments
 (0)