def clamp_mask

bend-collections@1.0.0.0 · spec/crypto/poly1305.bend:76

import bend-collections@1.0.0.0/spec/crypto/poly1305.bend as Poly1305
import Base

76# clamp(r): r &= 0x0ffffffc0ffffffc0ffffffc0fffffff, i.e. r[3], r[7], r[11]
77# and r[15] keep their low four bits, r[4], r[8] and r[12] lose their low two.
78def clamp_mask(i: Nat) -> U32:
79  match i:
80    case 3n: 15
81    case 7n: 15
82    case 11n: 15
83    case 15n: 15
84    case 4n: 252
85    case 8n: 252
86    case 12n: 252
87    case _: 255

Uses (2)

Used by (1)