Skip to main content

assert_slice_eq

Function assert_slice_eq 

Source
pub fn assert_slice_eq(
    b: &CircuitBuilder,
    name: impl Into<String>,
    len_bytes: Wire,
    actual: &[Wire],
    expected: &[Wire],
)
Expand description

Asserts that two byte sequences (packed little-endian into 64-bit words) are equal in their first len_bytes bytes. Bytes past len_bytes are ignored on both sides.

For each word index i, the saturating difference diff = len_bytes - i*8 selects between:

  • full-word assert_eq when diff > 8 (whole word is in range),
  • partial comparison via var_sll_bytes shifting both sides left by 8 - diff bytes so only the low diff bytes remain (1 ≤ diff ≤ 8 — note that the diff = 8 case picks the shifted form with shift = 0, which is identical to the original word), and
  • skipped comparison (both sides forced to zero) when the diff is 0.

§Panics

Panics if actual.len() != expected.len().