-
Notifications
You must be signed in to change notification settings - Fork 23
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
Stark Config Validation #41
Closed
+192
−150
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3a62939
basic validation passes
neotheprogramist 8f990fe
security bits adjust
neotheprogramist bbc6c64
before fri config validation
neotheprogramist b352a10
fmt
neotheprogramist bf8e196
fri config validation working
neotheprogramist d72715c
move into for FriConfig impl
neotheprogramist 87a98bc
move validation to relevant structs
neotheprogramist 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 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
scarb build | ||
cd runner | ||
scarb build && \ | ||
cd runner && \ | ||
cargo run --release -- ../target/dev/cairo_verifier.sierra.json < resources/parserin.txt |
This file contains 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 |
---|---|---|
|
@@ -11,6 +11,7 @@ mod array_split; | |
mod consts; | ||
mod merge_sort; | ||
mod powers_array; | ||
mod asserts; | ||
|
||
#[cfg(test)] | ||
mod tests; |
This file contains 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,6 @@ | ||
use cairo_verifier::common::math::Felt252PartialOrd; | ||
|
||
fn assert_in_range(x: felt252, min: felt252, max: felt252) { | ||
assert(min <= x, 'Value too small'); | ||
assert(x < max, 'Value too large'); | ||
} |
This file contains 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,18 +1,20 @@ | ||
mod air; | ||
mod channel; | ||
mod common; | ||
mod input_structs; | ||
mod fri; | ||
mod structs; | ||
mod air; | ||
mod oods; | ||
mod fri; | ||
mod table_commitment; | ||
mod vector_commitment; | ||
mod queries; | ||
mod proof_of_work; | ||
mod table_commitment; | ||
mod validation; | ||
mod vector_commitment; | ||
|
||
use cairo_verifier::{structs::stark_proof::StarkProof, structs::stark_proof::verify_stark_proof}; | ||
|
||
use cairo_verifier::input_structs::stark_proof::StarkProof; | ||
|
||
fn main(x: Array<felt252>) { | ||
let mut x_span = x.span(); | ||
let stark_proof: StarkProof = Serde::deserialize(ref x_span).unwrap(); | ||
verify_stark_proof(stark_proof); | ||
} |
This file contains 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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
mod proof_of_work_config; | ||
mod public_input; | ||
mod stark_config; | ||
mod stark_proof; | ||
mod traces_config; | ||
mod unsent_commitment; | ||
mod witness; | ||
mod stark_unsent_commitment; | ||
mod stark_witness; |
This file was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -1,6 +1,16 @@ | ||
struct StarkProof { | ||
config: StarkConfig, | ||
// public_input: PublicInput, | ||
// unsent_commitment: StarkUnsentCommitment, | ||
// witness: StarkWitness, | ||
#[derive(Drop, Serde)] | ||
struct PublicInput { | ||
log_n_steps: felt252, | ||
range_check_min: felt252, | ||
range_check_max: felt252, | ||
layout: felt252, | ||
dynamic_params: Array<felt252>, | ||
n_segments: felt252, | ||
segments: Array<felt252>, | ||
padding_addr: felt252, | ||
padding_value: felt252, | ||
main_page_len: felt252, | ||
main_page: Array<felt252>, | ||
n_continuous_pages: felt252, | ||
continuous_page_headers: Array<felt252>, | ||
} |
This file contains 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opt for FRI functionalities & structs to be in fri module.
I think it should be moved to contextually relevant module WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you quite misunderstood the concept behind this struct.
It might be called
DeserializationFriendlyFriConfig
- when you take a deeper look you can see that there is a implementation of theinto
trait to the struct with the same name in thefri
module.It is because to support objects (original struct has an array of structs instead of felts) in arrays I would need to modify parser which for our testing purposes is not a priority in my opinion.
The other way would be to modify the
fri
implementation to support this struct instead of the old one, but I've decided to do it the faster way for now and to implementinto
to the original struct.This is only the "proxy" struct that helps in the deserialization from parser output to the
FriConfig
struct present in thefri
module.In my opinion such a bit "messy" struct used only for deserialization purposes for sure shouldn't be in the
fri
module which contains cleanfri
impl.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure let's change its name to DeserializationFriendlyFriConfig then
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @neotheprogramist , if the struct is going to be used for deserialization only it doesn't make sense to be in the
fri
module