def carry

bend-collections@1.0.0.0 · src/crypto/poly1305/limbs.bend:66

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

66# A carry pass over n limbs, each kept to 8 bits; the carry u and all limbs
67# from n on (one, on the Poly1305 path) are summed into the top limb.
68def carry(n: Nat, +ds: List<&2, U32>, u: U32) -> List<&2, U32>:
69  match n:
70    case 0n: [U32.add(u, hd0(ds))]
71    case 1n+k:
72      +s = U32.add(u, hd0(ds))
73      U32.and(s, 255) <> carry(k, tl(ds), U32.shrn(s, 8n))

Uses (8)

Used by (2)