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

Add LogUp stark memory example #946

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d546080
create file
Nov 13, 2024
7ff0290
continuity and single value constraint
Nov 13, 2024
e992970
imp air
ColoCarletti Nov 13, 2024
821e1f6
permutation constraint
Nov 13, 2024
56de567
evaluate function for SingleValueConstraint
Nov 14, 2024
52912f1
add last element constraint
ColoCarletti Nov 14, 2024
0b5ac61
add public inputs
ColoCarletti Nov 14, 2024
f911837
add sort function for the trace
jotabulacios Nov 14, 2024
e25efde
add integration test
Nov 14, 2024
b975d36
fix clippy
ColoCarletti Nov 15, 2024
ca1fe3d
fix constraints
ColoCarletti Nov 15, 2024
cceb719
add documentation
Nov 15, 2024
5724131
handle possible panic
ColoCarletti Nov 21, 2024
0fc7284
rename variables
jotabulacios Nov 21, 2024
59c8b26
fix doc
Nov 25, 2024
02283aa
FRI verification fail
Nov 27, 2024
1167f54
different way of doing logup rap
Nov 27, 2024
ff4fc43
add m0 public input boundary constraint
Nov 27, 2024
0243f88
change end expemtions to 1
Nov 28, 2024
dba0fc0
change cp degree bound
Nov 29, 2024
31e956f
Merge branch 'main' into stark-mem-example
nicole-graus Nov 29, 2024
0de13e2
Merge branch 'stark-mem-example' into logup-mem-example
Nov 29, 2024
09a0615
fix clippy
Nov 29, 2024
04ac811
fix comment
Dec 5, 2024
28575f6
Merge branch 'main' into logup-mem-example
nicole-graus Dec 11, 2024
44b5933
Merge branch 'main' into logup-mem-example
nicole-graus Dec 20, 2024
9e1cee7
fix read_mem and tests for small fields. And add byteConversion for d…
Dec 23, 2024
023dd56
Add AsBytes for FE<Degree4BabyBear>
Dec 23, 2024
7f04be0
fix cargo check with no-std
Dec 23, 2024
2fd42b1
fix cargo fmt
Dec 23, 2024
5de9b62
fix cargo fmt
Dec 23, 2024
bf9b5cd
fix cargo fmt
Dec 23, 2024
21bcea7
fix clippy no-std
Dec 23, 2024
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
57 changes: 57 additions & 0 deletions math/src/field/fields/fft_friendly/quartic_babybear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ use crate::field::{
#[cfg(feature = "lambdaworks-serde-binary")]
use crate::traits::ByteConversion;

#[cfg(feature = "lambdaworks-serde-binary")]
#[cfg(feature = "alloc")]
use crate::traits::AsBytes;

/// We are implementig the extension of Baby Bear of degree 4 using the irreducible polynomial x^4 + 11.
/// BETA = 11 and -BETA = -11 is the non-residue.
pub const BETA: FieldElement<Babybear31PrimeField> =
Expand Down Expand Up @@ -262,6 +266,59 @@ impl ByteConversion for [FieldElement<Babybear31PrimeField>; 4] {
}
}

#[cfg(feature = "lambdaworks-serde-binary")]
impl ByteConversion for FieldElement<Degree4BabyBearExtensionField> {
fn to_bytes_be(&self) -> alloc::vec::Vec<u8> {
let mut byte_slice = ByteConversion::to_bytes_be(&self.value()[0]);
byte_slice.extend(ByteConversion::to_bytes_be(&self.value()[1]));
byte_slice.extend(ByteConversion::to_bytes_be(&self.value()[2]));
byte_slice.extend(ByteConversion::to_bytes_be(&self.value()[3]));
byte_slice
}

fn to_bytes_le(&self) -> alloc::vec::Vec<u8> {
let mut byte_slice = ByteConversion::to_bytes_le(&self.value()[0]);
byte_slice.extend(ByteConversion::to_bytes_le(&self.value()[1]));
byte_slice.extend(ByteConversion::to_bytes_le(&self.value()[2]));
byte_slice.extend(ByteConversion::to_bytes_le(&self.value()[3]));
byte_slice
}

fn from_bytes_be(bytes: &[u8]) -> Result<Self, crate::errors::ByteConversionError>
where
Self: Sized,
{
const BYTES_PER_FIELD: usize = 8;
let x0 = FieldElement::from_bytes_be(&bytes[0..BYTES_PER_FIELD])?;
let x1 = FieldElement::from_bytes_be(&bytes[BYTES_PER_FIELD..BYTES_PER_FIELD * 2])?;
let x2 = FieldElement::from_bytes_be(&bytes[BYTES_PER_FIELD * 2..BYTES_PER_FIELD * 3])?;
let x3 = FieldElement::from_bytes_be(&bytes[BYTES_PER_FIELD * 3..BYTES_PER_FIELD * 4])?;

Ok(Self::new([x0, x1, x2, x3]))
}

fn from_bytes_le(bytes: &[u8]) -> Result<Self, crate::errors::ByteConversionError>
where
Self: Sized,
{
const BYTES_PER_FIELD: usize = 8;
let x0 = FieldElement::from_bytes_le(&bytes[0..BYTES_PER_FIELD])?;
let x1 = FieldElement::from_bytes_le(&bytes[BYTES_PER_FIELD..BYTES_PER_FIELD * 2])?;
let x2 = FieldElement::from_bytes_le(&bytes[BYTES_PER_FIELD * 2..BYTES_PER_FIELD * 3])?;
let x3 = FieldElement::from_bytes_le(&bytes[BYTES_PER_FIELD * 3..BYTES_PER_FIELD * 4])?;

Ok(Self::new([x0, x1, x2, x3]))
}
}

#[cfg(feature = "lambdaworks-serde-binary")]
#[cfg(feature = "alloc")]
impl AsBytes for FieldElement<Degree4BabyBearExtensionField> {
fn as_bytes(&self) -> alloc::vec::Vec<u8> {
self.to_bytes_be()
}
}

impl IsFFTField for Degree4BabyBearExtensionField {
const TWO_ADICITY: u64 = 29;
const TWO_ADIC_PRIMITVE_ROOT_OF_UNITY: Self::BaseType = [
Expand Down
1 change: 1 addition & 0 deletions provers/stark/src/examples/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ pub mod fibonacci_2_columns;
pub mod fibonacci_rap;
pub mod quadratic_air;
pub mod read_only_memory;
pub mod read_only_memory_logup;
pub mod simple_fibonacci;
pub mod simple_periodic_cols;
Loading
Loading