MCPcopy Create free account
hub / github.com/docknetwork/crypto / boolvec_to_u8vec

Function boolvec_to_u8vec

oblivious_transfer/src/util.rs:223–230  ·  view source on GitHub ↗
(bv: &[bool])

Source from the content-addressed store, hash-verified

221}
222
223pub fn boolvec_to_u8vec(bv: &[bool]) -> Vec<u8> {
224 let offset = if is_multiple_of_8(bv.len()) { 0 } else { 1 };
225 let mut v = vec![0u8; divide_by_8(bv.len()) + offset];
226 for (i, b) in bv.iter().enumerate() {
227 v[divide_by_8(i)] |= (*b as u8) << modulo_8(i);
228 }
229 v
230}
231
232pub fn u8vec_to_boolvec(v: &[u8]) -> Vec<bool> {
233 let mut bv = Vec::with_capacity(multiply_by_8(v.len()));

Callers 3

newMethod · 0.85

Calls 5

is_multiple_of_8Function · 0.85
divide_by_8Function · 0.85
modulo_8Function · 0.85
lenMethod · 0.45
iterMethod · 0.45

Tested by

no test coverage detected