libff icon indicating copy to clipboard operation
libff copied to clipboard

Investigate potential off by one issue in pack_bit_vector_into_field_element_vector

Open ValarDragon opened this issue 2 years ago • 1 comments

pack_bit_vector_into_field_element_vector everywhere uses fieldT::floor_size_in_bits(), but it seems like it should be using capacity/ceil_size_in_bits().

(This got changed from capacity in #103, however that was a non-breaking change, and actually just reflected what the old field API did)

ValarDragon avatar Oct 05 '21 05:10 ValarDragon

@ValarDragon, I also thought this was an error and checked it. However, div_ceil is called inside the function. Therefore, The repacked_size seems to be calculated safely.

When "vector bit size" and "field bit size" are the same, and the "vector value" is greater than the "field size", I think ceil_size_in_bits() is not sufficient.

Am I misunderstanding?

Jun-Hee-Lee avatar Dec 09 '22 04:12 Jun-Hee-Lee