MCPcopy Create free account
hub / github.com/BitVM/BitVM / byte_array_to_nib

Method byte_array_to_nib

bitvm/src/chunk/elements.rs:163–172  ·  view source on GitHub ↗
(bytes: &[u8])

Source from the content-addressed store, hash-verified

161 pub(crate) fn deserialize_from_byte_array(byte_array: Vec<u8>) -> Self {
162 assert!(byte_array.len() == BLAKE3_HASH_LENGTH || byte_array.len() == 32);
163 fn byte_array_to_nib(bytes: &[u8]) -> Vec<u8> {
164 let mut nibbles = Vec::with_capacity(bytes.len() * 2);
165 for &b in bytes {
166 let high = b >> 4;
167 let low = b & 0x0F;
168 nibbles.push(low);
169 nibbles.push(high);
170 }
171 nibbles
172 }
173 if byte_array.len() == BLAKE3_HASH_LENGTH {
174 let nib_arr = byte_array_to_nib(&byte_array);
175 let nib_arr: [u8; BLAKE3_HASH_LENGTH * 2] = nib_arr.try_into().unwrap();

Callers

nothing calls this directly

Calls 2

lenMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected