Skip to content

Commit e5fa00f

Browse files
authored
Remove EmptyFlags construction checks (#394)
1 parent 6ea310e commit e5fa00f

5 files changed

Lines changed: 8 additions & 10 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ jobs:
216216
echo "ark-mnt4-298 = { git = 'https://github.com/arkworks-rs/curves' }"
217217
echo "ark-mnt6-298 = { git = 'https://github.com/arkworks-rs/curves' }"
218218
echo "ark-ed-on-bls12-377 = { git = 'https://github.com/arkworks-rs/curves' }"
219+
echo "ark-r1cs-std = { git = 'https://github.com/arkworks-rs/r1cs-std' }"
219220
} >> Cargo.toml
220221
221222
- name: Test on ${{ matrix.curve }}

ff/src/const_helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl<const N: usize> IndexMut<usize> for MulBuffer<N> {
8282
}
8383
}
8484

85-
/// A buffer to hold values of size 2 * N. This is mostly
85+
/// A buffer to hold values of size 8 * N + 1 bytes. This is mostly
8686
/// a hack that's necessary until `generic_const_exprs` is stable.
8787
#[derive(Copy, Clone)]
8888
#[repr(C, align(1))]

ff/src/fields/models/fp/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,9 +638,8 @@ impl<P: FpConfig<N>, const N: usize> CanonicalDeserializeWithFlags for Fp<P, N>
638638
return Err(SerializationError::NotEnoughSpace);
639639
}
640640
// Calculate the number of bytes required to represent a field element
641-
// serialized with `flags`. If `F::BIT_SIZE < 8`,
642-
// this is at most `$byte_size + 1`
643-
let output_byte_size = buffer_byte_size(Self::MODULUS_BIT_SIZE as usize + F::BIT_SIZE);
641+
// serialized with `flags`.
642+
let output_byte_size = Self::zero().serialized_size_with_flags::<F>();
644643

645644
let mut masked_bytes = crate::const_helpers::SerBuffer::zeroed();
646645
masked_bytes.read_exact_up_to(reader, output_byte_size)?;

serialize/src/flags.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,8 @@ impl Flags for EmptyFlags {
5252
}
5353

5454
#[inline]
55-
fn from_u8(value: u8) -> Option<Self> {
56-
if (value >> 7) == 0 {
57-
Some(EmptyFlags)
58-
} else {
59-
None
60-
}
55+
fn from_u8(_: u8) -> Option<Self> {
56+
Some(EmptyFlags)
6157
}
6258
}
6359

test-templates/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,8 @@ macro_rules! generate_field_serialization_test {
593593
let b: Fq = rng.gen();
594594

595595
let byte_size = a.serialized_size();
596+
let (_, buffer_size) = buffer_bit_byte_size(Fr::MODULUS_BIT_SIZE as usize);
597+
assert_eq!(byte_size, buffer_size);
596598
field_serialization_test::<Fr>(byte_size);
597599

598600
let byte_size = b.serialized_size();

0 commit comments

Comments
 (0)