Skip to content

Commit 1cc89f6

Browse files
committed
new
1 parent 484afad commit 1cc89f6

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

src/_string_tools/slice_packed_field.nr

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -612,19 +612,9 @@ unconstrained fn decompose(val: Field) -> [Field; 16] {
612612
pub fn get_last_limb_path<let OutputFields: u32>(last_limb_index: Field) -> [Field; OutputFields] {
613613
// TODO we offset by 1 explain why (0 byte length produces 0 - 1 which = invalid array index. we just add 1 and increase array length by 1 to compensate)
614614
let path = LAST_LIMB_PATH[cast_num_to_u32(last_limb_index + 1)]; // 2
615-
// Safety: check the comments below
616-
let path_valid_bits = unsafe { decompose(path) };
617-
let mut path_valid_sum: Field = 0;
618-
let mut path_valid_output: [Field; OutputFields] = [0; OutputFields];
619-
for i in 0..OutputFields {
620-
// we check that the path valid bits are binary
621-
assert(path_valid_bits[i] * path_valid_bits[i] - path_valid_bits[i] == 0);
622-
path_valid_sum += (path_valid_bits[i] * (1 << i as u8) as Field);
623-
path_valid_output[i] = path_valid_bits[i];
624-
}
625-
// we check that the path valid bits sum to the path
626-
assert(path_valid_sum == path);
627-
path_valid_output
615+
let a = path.to_le_bits::<OutputFields>();
616+
let result = a.map(|b| b as Field);
617+
result
628618
}
629619

630620
/**

0 commit comments

Comments
 (0)