def canon

bend-collections@1.0.0.0 · src/crypto/secp256k1/limbs.bend:146

import bend-collections@1.0.0.0/src/crypto/secp256k1/limbs.bend as Limbs
import Base

146# t (16 limbs, value below 2^256) mod m: t + c has bit 256 set exactly when
147# t >= m, and then its low 256 bits are t - m
148def canon(+c: List<&2, Nat>, +t: List<&2, Nat>) -> List<&2, Nat>:
149  +u = carry(32n, add(t, c), 0n)
150  select(top(u), take(16n, u), t)

Uses (7)

Used by (1)