Skip to content

Commit

Permalink
fix cargo check with no-std
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicole authored and Nicole committed Dec 23, 2024
1 parent 023dd56 commit 7f04be0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
11 changes: 8 additions & 3 deletions math/src/field/fields/fft_friendly/quartic_babybear.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
use crate::{field::{
use crate::field::{
element::FieldElement,
errors::FieldError,
fields::fft_friendly::babybear::Babybear31PrimeField,
traits::{IsFFTField, IsField, IsSubFieldOf},
}, traits::AsBytes};
};

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

#[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 +265,7 @@ 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]);
Expand Down Expand Up @@ -306,10 +310,11 @@ impl ByteConversion for FieldElement<Degree4BabyBearExtensionField> {
}
}

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

Expand Down
5 changes: 5 additions & 0 deletions provers/stark/src/examples/read_only_memory_logup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,23 +410,28 @@ where
) where
Self::FieldExtension: IsFFTField,
{
// Main table
let main_segment_cols = trace.columns_main();
let a = &main_segment_cols[0];
let v = &main_segment_cols[1];
let a_sorted = &main_segment_cols[2];
let v_sorted = &main_segment_cols[3];
let m = &main_segment_cols[4];

// Challenges
let z = &challenges[0];
let alpha = &challenges[1];

let trace_len = trace.num_rows();
let mut aux_col = Vec::new();

// s_0 = m_0/(z - (a'_0 + α * v'_0) - 1/(z - (a_0 + α * v_0)
let unsorted_term = (-(&a[0] + &v[0] * alpha) + z).inv().unwrap();
let sorted_term = (-(&a_sorted[0] + &v_sorted[0] * alpha) + z).inv().unwrap();
aux_col.push(&m[0] * sorted_term - unsorted_term);

// Apply the same equation given in the permutation transition contraint to the rest of the trace.
// s_{i+1} = s_i + m_{i+1}/(z - (a'_{i+1} + α * v'_{i+1}) - 1/(z - (a_{i+1} + α * v_{i+1})
for i in 0..trace_len - 1 {
let unsorted_term = (-(&a[i + 1] + &v[i + 1] * alpha) + z).inv().unwrap();
let sorted_term = (-(&a_sorted[i + 1] + &v_sorted[i + 1] * alpha) + z)
Expand Down

0 comments on commit 7f04be0

Please sign in to comment.