Index Mathematics Conjectures nbv lettuce Widgets

r1cs_compose_vertical

stdlib/r1cs/r1cs_compose_vertical.nbv

r1cs_compose_vertical(static width, l_r_a, l_r_b, l_r_c, r_r_a, r_r_b, r_r_c)

combine two R1CS vertically. Witness lengths must be equal.

Precompiles
assert_eq!, assert_ne!, concat!, div_exact!, if_ne!, len!
Used by
r1cs/r1cs_from_output, r1cs/r1cs_with_output

Source

# combine two R1CS vertically. Witness lengths
# must be equal.
(
  static width,
  l_r_a,
  l_r_b,
  l_r_c,
  r_r_a,
  r_r_b,
  r_r_c
)

assert_ne! 0, width

if_ne! 0, (len! l_r_a) {
  static l_height = div_exact! (len! l_r_a), width
  assert_eq! l_height, div_exact! (len! l_r_b), width
  assert_eq! l_height, div_exact! (len! l_r_c), width
}

if_ne! 0, (len! r_r_a) {
  static r_height = div_exact! (len! r_r_a), width
  assert_eq! r_height, div_exact! (len! r_r_b), width
  assert_eq! r_height, div_exact! (len! r_r_c), width
}

(
  width,
  (concat! l_r_a, r_r_a),
  (concat! l_r_b, r_r_b),
  (concat! l_r_c, r_r_c)
)