pub fn compact<T, F>(arr: &mut [T], is_dummy: F) -> usizeExpand description
Stably compacts an array arr of length n using oblivious compaction.
The payload array payload is the prefix sum of valid elements.
Uses https://eprint.iacr.org/2022/1333.pdf
§Requires
§Behavior
- returns
ret- the number of non-dummy elements (new real length of the array). - first
retelements ofarrare the non-dummy elements in the same order as they were in the original array. - the rest of the elements in
arrare the dummy elements in no particular order.
§Oblivious
- Fully data-independent memory access pattern.
- Leaks:
arr.len()- the full length of the original array