Skip to content
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

Optimize FRI quotient constants (Work In Progress) #205

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions stwo_cairo_verifier/.tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scarb nightly-2024-11-09
starknet-foundry 0.32.0
scarb nightly-2024-11-19
starknet-foundry 0.33.0
6 changes: 3 additions & 3 deletions stwo_cairo_verifier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ Modify [`Scarb.toml`](./Scarb.toml) to use [Starknet Foundary](https://github.co

```diff
[dev-dependencies]
- cairo_test = "2.8.0"
+ snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.32.0" }
+ assert_macros = "2.8.0"
- cairo_test = "2.8.5"
+ snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry", tag = "v0.33.0" }
+ assert_macros = "2.8.5"
+
+ [scripts]
+ test = "snforge test --max-n-steps 100000000"
Expand Down
11 changes: 4 additions & 7 deletions stwo_cairo_verifier/Scarb.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@ name = "stwo_cairo_verifier"
version = "0.1.0"
edition = "2024_07"

# [cairo]
# enable-gas = false

[lib]
casm = true

[cairo]
# TODO(andrew): Remove once inlining bug fixed as increases step counts by about 3x.
inlining-strategy = "avoid"

[tool.fmt]
sort-module-level-items = true

[dependencies]

[dev-dependencies]
cairo_test = "2.8.4"
cairo_test = "2.8.5"
14 changes: 4 additions & 10 deletions stwo_cairo_verifier/src/channel.cairo
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use core::array::SpanTrait;
use core::num::traits::{WrappingMul, WrappingSub};
use core::poseidon::{hades_permutation, poseidon_hash_span};
use core::poseidon::hades_permutation;
use core::traits::DivRem;
use crate::fields::qm31::QM31Trait;
use crate::utils::pack4;
use crate::utils::{pack4, poseidon_hash_span};
use crate::{BaseField, SecureField};

/// Equals `2^31`.
Expand Down Expand Up @@ -61,14 +61,8 @@ pub impl ChannelImpl of ChannelTrait {
fn draw_base_felts(ref self: Channel) -> [BaseField; FELTS_PER_HASH] {
let mut cur = self.draw_felt252().into();
[
extract_m31(ref cur),
extract_m31(ref cur),
extract_m31(ref cur),
extract_m31(ref cur),
extract_m31(ref cur),
extract_m31(ref cur),
extract_m31(ref cur),
extract_m31(ref cur),
extract_m31(ref cur), extract_m31(ref cur), extract_m31(ref cur), extract_m31(ref cur),
extract_m31(ref cur), extract_m31(ref cur), extract_m31(ref cur), extract_m31(ref cur),
]
}

Expand Down
1 change: 1 addition & 0 deletions stwo_cairo_verifier/src/fields/qm31.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ pub impl QM31Mul of core::traits::Mul<QM31> {
#[inline]
fn mul(lhs: QM31, rhs: QM31) -> QM31 {
// (a + bu) * (c + du) = (ac + rbd) + (ad + bc)u.
// QM31Impl::fma(lhs, rhs, qm31(0, 0, 0, 0))
QM31 { a: lhs.a * rhs.a + R * lhs.b * rhs.b, b: lhs.a * rhs.b + lhs.b * rhs.a }
}
}
Expand Down
Loading
Loading