Skip to main content

reduce

Function reduce 

Source
pub(crate) fn reduce<L: Limbs>(
    log_2_bound: u32,
    a: L,
    b: (Choice, L),
    c: L,
) -> (L, (Choice, L), L)
Expand description

Reduce an element.

For a positive definite binary quadratic form (a, b, c) such that:

  • b^2 - 4ac = delta where delta < 0 (the form is well-defined for a negative discriminant)
  • $delta \cong 1 \mod 2$
  • 0 <= a, c (a, c aren’t negative, as enforced by the type system)
  • floor(log_2(a)) + 1 <= log_2_bound
  • floor(log_2(|b|)) + 1 <= log_2_bound
  • ceil(log_2_bound / Limb::BITS) <= <L as AsRef::<[Limb]>>::as_ref(&a).len()
  • <L as AsRef::<[Limb]>>::as_ref(&a).len() <= <L as AsRef::<[Limb]>>::as_ref(&b.1).len()
  • <L as AsRef::<[Limb]>>::as_ref(&a).len() == <L as AsRef::<[Limb]>>::as_ref(&c).len()

Yield the reduced equivalent form (a', b', c') such that:

  • |b'| <= a' <= c'
  • b' >= 0 if (|b'| == a') || (a' == c')
  • gcd(a, b, c) = gcd(a', b', c')

b.0, b'.0 are true if the value is positive.

delta is bound to be negative and specified via its absolute value in negative_discriminant_abs.