-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1fc25f3
commit 6187464
Showing
65 changed files
with
59,160 additions
and
130 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 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 +1,2 @@ | ||
pub mod logging_utils; | ||
pub mod serialise; |
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,170 @@ | ||
use starknet_ff::FieldElement; | ||
use stwo_prover::core::fields::m31::BaseField; | ||
use stwo_prover::core::fields::qm31::SecureField; | ||
use stwo_prover::core::fri::{FriLayerProof, FriProof}; | ||
use stwo_prover::core::pcs::CommitmentSchemeProof; | ||
use stwo_prover::core::poly::line::LinePoly; | ||
use stwo_prover::core::prover::StarkProof; | ||
use stwo_prover::core::vcs::ops::MerkleHasher; | ||
use stwo_prover::core::vcs::prover::MerkleDecommitment; | ||
|
||
pub trait CairoSerialize { | ||
fn serialize(&self, output: &mut Vec<FieldElement>); | ||
} | ||
|
||
impl CairoSerialize for u32 { | ||
fn serialize(&self, output: &mut Vec<FieldElement>) { | ||
output.push((*self).into()); | ||
} | ||
} | ||
|
||
impl CairoSerialize for u64 { | ||
fn serialize(&self, output: &mut Vec<FieldElement>) { | ||
output.push((*self).into()); | ||
} | ||
} | ||
|
||
impl CairoSerialize for usize { | ||
fn serialize(&self, output: &mut Vec<FieldElement>) { | ||
output.push((*self).into()); | ||
} | ||
} | ||
|
||
impl CairoSerialize for BaseField { | ||
fn serialize(&self, output: &mut Vec<FieldElement>) { | ||
output.push(self.0.into()); | ||
} | ||
} | ||
|
||
impl CairoSerialize for SecureField { | ||
fn serialize(&self, output: &mut Vec<FieldElement>) { | ||
output.extend(self.to_m31_array().map(|c| FieldElement::from(c.0))); | ||
} | ||
} | ||
|
||
impl<H: MerkleHasher> CairoSerialize for MerkleDecommitment<H> | ||
where | ||
H::Hash: CairoSerialize, | ||
{ | ||
fn serialize(&self, output: &mut Vec<FieldElement>) { | ||
let Self { | ||
hash_witness, | ||
column_witness, | ||
} = self; | ||
hash_witness.serialize(output); | ||
column_witness.serialize(output); | ||
} | ||
} | ||
|
||
impl CairoSerialize for LinePoly { | ||
fn serialize(&self, output: &mut Vec<FieldElement>) { | ||
(**self).serialize(output); | ||
output.push((self.len().ilog2()).into()); | ||
} | ||
} | ||
|
||
impl<H: MerkleHasher> CairoSerialize for FriLayerProof<H> | ||
where | ||
H::Hash: CairoSerialize, | ||
{ | ||
fn serialize(&self, output: &mut Vec<FieldElement>) { | ||
let Self { | ||
fri_witness, | ||
decommitment, | ||
commitment, | ||
} = self; | ||
fri_witness.serialize(output); | ||
decommitment.serialize(output); | ||
commitment.serialize(output); | ||
} | ||
} | ||
|
||
impl<H: MerkleHasher> CairoSerialize for FriProof<H> | ||
where | ||
H::Hash: CairoSerialize, | ||
{ | ||
fn serialize(&self, output: &mut Vec<FieldElement>) { | ||
let Self { | ||
first_layer, | ||
inner_layers, | ||
last_layer_poly, | ||
} = self; | ||
first_layer.serialize(output); | ||
inner_layers.serialize(output); | ||
last_layer_poly.serialize(output); | ||
} | ||
} | ||
|
||
impl CairoSerialize for FieldElement { | ||
fn serialize(&self, output: &mut Vec<FieldElement>) { | ||
output.push(*self); | ||
} | ||
} | ||
|
||
impl<H: MerkleHasher> CairoSerialize for CommitmentSchemeProof<H> | ||
where | ||
H::Hash: CairoSerialize, | ||
{ | ||
fn serialize(&self, output: &mut Vec<FieldElement>) { | ||
let Self { | ||
commitments, | ||
sampled_values, | ||
decommitments, | ||
queried_values, | ||
proof_of_work, | ||
fri_proof, | ||
} = self; | ||
commitments.serialize(output); | ||
sampled_values.serialize(output); | ||
decommitments.serialize(output); | ||
queried_values.serialize(output); | ||
output.push((*proof_of_work).into()); | ||
fri_proof.serialize(output); | ||
} | ||
} | ||
|
||
impl<H: MerkleHasher> CairoSerialize for StarkProof<H> | ||
where | ||
H::Hash: CairoSerialize, | ||
{ | ||
fn serialize(&self, output: &mut Vec<FieldElement>) { | ||
let Self(commitment_scheme_proof) = self; | ||
commitment_scheme_proof.serialize(output); | ||
} | ||
} | ||
|
||
impl<T: CairoSerialize> CairoSerialize for [T] { | ||
fn serialize(&self, output: &mut Vec<FieldElement>) { | ||
output.push(self.len().into()); | ||
self.iter().for_each(|v| v.serialize(output)); | ||
} | ||
} | ||
|
||
impl<T: CairoSerialize, const N: usize> CairoSerialize for [T; N] { | ||
fn serialize(&self, output: &mut Vec<FieldElement>) { | ||
self.iter().for_each(|v| v.serialize(output)); | ||
} | ||
} | ||
|
||
impl<T: CairoSerialize> CairoSerialize for Vec<T> { | ||
fn serialize(&self, output: &mut Vec<FieldElement>) { | ||
(**self).serialize(output); | ||
} | ||
} | ||
|
||
impl<T0: CairoSerialize, T1: CairoSerialize> CairoSerialize for (T0, T1) { | ||
fn serialize(&self, output: &mut Vec<FieldElement>) { | ||
let (v0, v1) = self; | ||
v0.serialize(output); | ||
v1.serialize(output); | ||
} | ||
} | ||
|
||
impl<T0: CairoSerialize, T1: CairoSerialize, T2: CairoSerialize> CairoSerialize for (T0, T1, T2) { | ||
fn serialize(&self, output: &mut Vec<FieldElement>) { | ||
let (v0, v1, v2) = self; | ||
v0.serialize(output); | ||
v1.serialize(output); | ||
v2.serialize(output); | ||
} | ||
} |
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 +1 @@ | ||
tests/verifier/proofs | ||
*_proof.cairo |
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,2 +1,2 @@ | ||
scarb nightly-2024-11-19 | ||
scarb nightly-2024-12-14 | ||
starknet-foundry 0.33.0 |
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 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 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,19 +1,7 @@ | ||
[workspace] | ||
members = ["bounded_int"] | ||
|
||
[package] | ||
name = "stwo_cairo_verifier" | ||
version = "0.1.0" | ||
edition = "2024_07" | ||
|
||
[lib] | ||
casm = true | ||
|
||
[tool.fmt] | ||
sort-module-level-items = true | ||
|
||
[dependencies] | ||
bounded_int = { path = "bounded_int" } | ||
|
||
[dev-dependencies] | ||
cairo_test = "2.8.5" | ||
members = [ | ||
"crates/bounded_int", | ||
"crates/cairo_air", | ||
"crates/constraint_framework", | ||
"crates/verifier_core", | ||
] |
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,11 @@ | ||
[crate_roots] | ||
verifier = "src" | ||
bounded_int = "bounded_int/src" | ||
|
||
[config.override.verifier] | ||
edition = "2024_07" | ||
|
||
[config.override.verifier.dependencies.bounded_int] | ||
|
||
[config.override.bounded_int] | ||
edition = "2023_10" |
File renamed without changes.
5 changes: 2 additions & 3 deletions
5
..._cairo_verifier/bounded_int/src/lib.cairo → ...verifier/crates/bounded_int/src/lib.cairo
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,8 +1,7 @@ | ||
//! Utility crate that exports internal corelib function. | ||
//! This crate is compiled with an older edition that does not enforce visibity rules. | ||
|
||
use core::integer::upcast; | ||
use core::internal::bounded_int::{ | ||
BoundedInt, add, constrain, div_rem, sub, AddHelper, ConstrainHelper, DivRemHelper, SubHelper, | ||
AddHelper, BoundedInt, ConstrainHelper, DivRemHelper, SubHelper, add, constrain, div_rem, sub, | ||
}; | ||
|
||
use core::integer::upcast; |
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,17 @@ | ||
[package] | ||
name = "stwo_cairo_air" | ||
version = "0.1.0" | ||
edition = "2024_07" | ||
|
||
[lib] | ||
casm = true | ||
|
||
[tool.fmt] | ||
sort-module-level-items = true | ||
|
||
[dependencies] | ||
stwo_verifier_core = { path = "../verifier_core" } | ||
stwo_constraint_framework = { path = "../constraint_framework" } | ||
|
||
[dev-dependencies] | ||
cairo_test = "2.9.2" |
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,32 @@ | ||
use stwo_constraint_framework::PreprocessedMaskValues; | ||
use stwo_verifier_core::ColumnSpan; | ||
use stwo_verifier_core::circle::CirclePoint; | ||
use stwo_verifier_core::fields::qm31::QM31; | ||
|
||
pub mod addr_to_id; | ||
pub mod genericopcode; | ||
pub mod id_to_f252; | ||
pub mod range_check; | ||
pub mod ret_opcode; | ||
pub mod verify_instruction; | ||
|
||
pub trait CairoComponent<T> { | ||
fn mask_points( | ||
self: @T, | ||
ref trace_mask_points: Array<Array<CirclePoint<QM31>>>, | ||
ref interaction_trace_mask_points: Array<Array<CirclePoint<QM31>>>, | ||
point: CirclePoint<QM31>, | ||
); | ||
|
||
fn max_constraint_log_degree_bound(self: @T) -> u32; | ||
|
||
fn evaluate_constraints_at_point( | ||
self: @T, | ||
ref sum: QM31, | ||
ref preprocessed_mask_values: PreprocessedMaskValues, | ||
ref trace_mask_values: ColumnSpan<Array<QM31>>, | ||
ref interaction_trace_mask_values: ColumnSpan<Array<QM31>>, | ||
random_coeff: QM31, | ||
point: CirclePoint<QM31>, | ||
); | ||
} |
Oops, something went wrong.