Skip to main content

concat

Function concat 

Source
pub fn concat(b: &CircuitBuilder, inputs: &[ByteVec]) -> ByteVec
Expand description

Computes the concatenation of a list of ByteVecs as a new ByteVec.

The returned vector has:

  • capacity (number of data wires) equal to the sum of the inputs’ capacities,
  • runtime length equal to the sum of the inputs’ len_bytes values, and
  • len_range equal to the sum of the inputs’ ranges (sum(start)..sum(end)).

The output data wires are populated by a prover-side concatenation hint; soundness is enforced by constraining each input’s region of the output to equal that input’s data. How that constraint is emitted depends on what is known at circuit-build time:

  • When a term’s byte offset into the output is a compile-time constant (i.e. every preceding term has a constant length), its region is extracted with constant shifts and masks (no multiplexer or dynamic-shift machinery).
  • When that term also has a constant length, the comparison degenerates further to a plain per-word assert_eq (with a constant mask on the final partial word), dropping the saturating-diff / variable-shift / select machinery of assert_slice_eq entirely.
  • Otherwise (a dynamic offset, once some preceding term has a dynamic length) the term falls back to the fully-dynamic slice() + assert_slice_eq path.

Bytes of output.data beyond output.len_bytes are unconstrained.