forked from Plonky3/Plonky3
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Handle aux boundary values #33
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
Merged
Al-Kindi-0
merged 11 commits into
0xMiden:main
from
massalabs:handle_aux_boundary_values
Dec 17, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
acb2e68
feat: add access to bus_types() in Air
Leo-Besancon a9ffd66
feat: add aux_bus_boundary_values handling
Leo-Besancon 1f3cc3f
refactor: move aux_finals from OpenedValues to Proof
Leo-Besancon afff307
feat: add aux_finals in transcript
Leo-Besancon 38ef4fa
feat: add var_len_pub_inputs handling
Leo-Besancon a1170e9
Merge branch 'main' into handle_aux_boundary_values
Leo-Besancon 51ec3a6
feat: auto add bus boundary constraints to the air
Leo-Besancon 463bd7d
fix: only add bus boundary constraints if num_randomness > 0
Leo-Besancon ea807d8
chore: cargo fmt + clippy fixes
Leo-Besancon b769c59
docs: review comments
Leo-Besancon 719c20b
docs: add comments on limitations of checking the bus_types length
Leo-Besancon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| use std::marker::PhantomData; | ||
|
|
||
| use miden_air::{BusType, MidenAir, MidenAirBuilder}; | ||
| use p3_field::{PrimeCharacteristicRing, TwoAdicField}; | ||
| use p3_matrix::Matrix; | ||
| use p3_matrix::dense::RowMajorMatrix; | ||
| use p3_maybe_rayon::prelude::*; | ||
|
|
||
| use crate::{StarkGenericConfig, Val}; | ||
|
|
||
| pub struct AirWithBoundaryConstraints<'a, SC, A> | ||
| where | ||
| SC: StarkGenericConfig + std::marker::Sync, | ||
| A: MidenAir<Val<SC>, SC::Challenge>, | ||
| Val<SC>: TwoAdicField, | ||
| { | ||
| pub inner: &'a A, | ||
| pub phantom: PhantomData<SC>, | ||
| } | ||
|
|
||
| impl<'a, SC, A> MidenAir<Val<SC>, SC::Challenge> for AirWithBoundaryConstraints<'a, SC, A> | ||
| where | ||
| SC: StarkGenericConfig + std::marker::Sync, | ||
| A: MidenAir<Val<SC>, SC::Challenge>, | ||
| Val<SC>: TwoAdicField, | ||
| { | ||
| fn width(&self) -> usize { | ||
| self.inner.width() | ||
| } | ||
|
|
||
| fn preprocessed_trace(&self) -> Option<RowMajorMatrix<Val<SC>>> { | ||
| self.inner.preprocessed_trace() | ||
| } | ||
|
|
||
| fn num_public_values(&self) -> usize { | ||
| self.inner.num_public_values() | ||
| } | ||
|
|
||
| fn periodic_table(&self) -> Vec<Vec<Val<SC>>> { | ||
| self.inner.periodic_table() | ||
| } | ||
|
|
||
| fn num_randomness(&self) -> usize { | ||
| self.inner.num_randomness() | ||
| } | ||
|
|
||
| fn aux_width(&self) -> usize { | ||
| self.inner.aux_width() | ||
| } | ||
|
|
||
| /// Types of buses | ||
| fn bus_types(&self) -> Vec<BusType> { | ||
| self.inner.bus_types() | ||
| } | ||
|
|
||
| fn build_aux_trace( | ||
| &self, | ||
| _main: &RowMajorMatrix<Val<SC>>, | ||
| _challenges: &[SC::Challenge], | ||
| ) -> Option<RowMajorMatrix<Val<SC>>> { | ||
| self.inner.build_aux_trace(_main, _challenges) | ||
| } | ||
|
|
||
| fn eval<AB: MidenAirBuilder<F = Val<SC>>>(&self, builder: &mut AB) { | ||
| // First, apply the inner AIR's constraints | ||
| self.inner.eval(builder); | ||
|
|
||
| if self.inner.num_randomness() > 0 { | ||
| // Then, apply any additional boundary constraints as needed | ||
| let aux = builder.permutation(); | ||
| let aux_current = aux.row_slice(0).unwrap(); | ||
| let aux_bus_boundary_values = builder.aux_bus_boundary_values().to_vec(); | ||
|
|
||
| for (idx, bus_type) in self.inner.bus_types().into_iter().enumerate() { | ||
| match bus_type { | ||
| BusType::Multiset => { | ||
| builder | ||
| .when_first_row() | ||
| .assert_zero_ext(aux_current[idx].into() - AB::ExprEF::ONE); | ||
| } | ||
| BusType::Logup => { | ||
| builder | ||
| .when_first_row() | ||
| .assert_zero_ext(aux_current[idx].into()); | ||
| } | ||
| } | ||
| builder | ||
| .when_last_row() | ||
| .assert_zero_ext(aux_current[idx].into() - aux_bus_boundary_values[idx].into()); | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.