Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion ff/src/const_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl<const N: usize> IndexMut<usize> for MulBuffer<N> {
}
}

/// A buffer to hold values of size 2 * N. This is mostly
/// A buffer to hold values of size 8 * N + 1 bytes. This is mostly
/// a hack that's necessary until `generic_const_exprs` is stable.
#[derive(Copy, Clone)]
#[repr(C, align(1))]
Expand Down
5 changes: 2 additions & 3 deletions ff/src/fields/models/fp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,9 +638,8 @@ impl<P: FpConfig<N>, const N: usize> CanonicalDeserializeWithFlags for Fp<P, N>
return Err(SerializationError::NotEnoughSpace);
}
// Calculate the number of bytes required to represent a field element
// serialized with `flags`. If `F::BIT_SIZE < 8`,
// this is at most `$byte_size + 1`
let output_byte_size = buffer_byte_size(Self::MODULUS_BIT_SIZE as usize + F::BIT_SIZE);
// serialized with `flags`.
let output_byte_size = Self::zero().serialized_size_with_flags::<F>();

let mut masked_bytes = crate::const_helpers::SerBuffer::zeroed();
masked_bytes.read_exact_up_to(reader, output_byte_size)?;
Expand Down
8 changes: 2 additions & 6 deletions serialize/src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,8 @@ impl Flags for EmptyFlags {
}

#[inline]
fn from_u8(value: u8) -> Option<Self> {
if (value >> 7) == 0 {
Some(EmptyFlags)
} else {
None
}
fn from_u8(_: u8) -> Option<Self> {
Some(EmptyFlags)
}
}

Expand Down
2 changes: 2 additions & 0 deletions test-templates/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,8 @@ macro_rules! generate_field_serialization_test {
let b: Fq = rng.gen();

let byte_size = a.serialized_size();
let (_, buffer_size) = buffer_bit_byte_size(Fr::MODULUS_BIT_SIZE as usize);
assert_eq!(byte_size, buffer_size);
field_serialization_test::<Fr>(byte_size);

let byte_size = b.serialized_size();
Expand Down