Skip to content

Implement Boundary Constraints - #27

Open
varunthakore wants to merge 10 commits into
zksecurity:masterfrom
varunthakore:air-1
Open

Implement Boundary Constraints#27
varunthakore wants to merge 10 commits into
zksecurity:masterfrom
varunthakore:air-1

Conversation

@varunthakore

Copy link
Copy Markdown
Contributor

This PR implements boundary constraints which are part of the following library.
https://github.com/starkware-libs/stone-prover/tree/main/src/starkware/air

This PR has dependency on #26.

@varunthakore
varunthakore requested a review from rot256 October 28, 2024 08:55

@rot256 rot256 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only delta compared to the other PR is air/src/boundary.rs right?

Comment thread air/src/boundry.rs
Comment on lines +33 to +35
let pos = constraints
.iter()
.position(|constraint: &ConstraintData<F>| constraint.point_x == x);

@rot256 rot256 Oct 28, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be fine since the number of boundary constraints is probably small, but this has O(n^2) complexity.

Maybe use a Map : point_x -> point_y

Then collect into ConstraintData at the end.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the use case of "overwriting" a previous boundary constraint with a different point_y? Should we just error instead?

Comment thread air/src/boundry.rs
Comment on lines +51 to +54
let mut mask = Vec::with_capacity(n_columns);
for i in 0..n_columns {
mask.push((0, i));
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let mask = (0..n_columns).map(|i| (0, i)).collect()

Comment thread air/src/boundry.rs
Comment on lines +82 to +90
fn constraints_eval(
&self,
neighbors: &[F],
_periodic_columns: &[F],
random_coefficients: &[F],
point: &F,
_shifts: &[F],
_precomp_domains: &[F],
) -> F {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we compose this with other types of constraints?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't reviewed the Stone code where boundary constraints are composed with other types of constraints, so I can't answer this yet.

@varunthakore

Copy link
Copy Markdown
Contributor Author

The only delta compared to the other PR is air/src/boundary.rs right?

The code in the following commit is the delta
c57fc90

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants