def sq_rem

bend-collections-laws-crypto@1.0.0.0 · src/math/f64.bend:449

import bend-collections-laws-crypto@1.0.0.0/src/math/f64.bend as F64
import Base
import bend-collections-laws-crypto@1.0.0.0/src/math/u64.bend as W
import bend-collections-laws-crypto@1.0.0.0/src/math/w64.bend as X

449# N - S0^2 = a - b for a = u 2^32, b = q^2: the root is S0 when b <= a
450def sq_rem(+e: Nat, +s0: W.U64, +a: W.U64, +b: W.U64, ge: Bool) -> F64:
451  match ge:
452    case True{}:
453      sq_fin(e, s0, Bool.not(X.eq(a, b)))
454    case False{}:
455      sq_neg(e, s0, X.sub(b, a))

Uses (9)

Used by (1)