Skip to main content

sub

Function sub 

Source
pub fn sub(builder: &CircuitBuilder, a: &BigUint, b: &BigUint) -> BigUint
Expand description

Subtracts two equally-sized BigUintss with carry propagation.

Computes a - b with proper borrow handling between limbs. The result has the same number of limbs as the inputs. Underflow beyond the most significant limb is checked and must be zero. This implies that a >= b and the difference remains unsigned.

§Arguments

  • builder - Circuit builder for constraint generation
  • a - minuend
  • b - subtrahend (must have same number of limbs as a)

§Returns

Difference as a BigUint with the same number of limbs as the inputs

§Panics

  • Panics if a and b have different number of limbs