pub fn slice(
b: &CircuitBuilder,
len_input: Wire,
len_slice: Wire,
input: &[Wire],
offset: Wire,
max_n_words: usize,
) -> Vec<Wire>Expand description
Extracts a slice from an input byte array and returns it as a vector of packed 64-bit words.
Returns the bytes from input starting at offset for len_slice bytes, packed into
max_n_words little-endian 64-bit words. Bytes past len_slice are not constrained — they
hold whatever raw bytes happen to follow in input (and may be nonzero garbage). Callers that
need to compare against an expected slice should use assert_slice_eq, which masks the
comparison to the first len_slice bytes.
§Limitations
All size and offset values must fit within 32 bits. Specifically:
len_inputmust be < 2^32len_slicemust be < 2^32offsetmust be < 2^32offset + len_slicemust be < 2^32
These limitations are enforced by the circuit constraints.
§Arguments
b- Circuit builderlen_input- Actual input size in byteslen_slice- Actual slice size in bytesinput- Input array packed as words (8 bytes per word)offset- Byte offset where slice startsmax_n_words- Number of output wires; the maximum slice length in bytes ismax_n_words * 8
§Returns
A Vec<Wire> of length max_n_words containing the extracted slice bytes packed in
little-endian order. Bytes past len_slice are unconstrained garbage; use assert_slice_eq
for comparisons that should ignore them.
§Panics
- If
input.len() * 8 > u32::MAX - If
max_n_words * 8 > u32::MAX