def len_hi

bend-collections@1.0.0.0 · src/crypto/sha/packed/core.bend:467

import bend-collections@1.0.0.0/src/crypto/sha/packed/core.bend as Core
import Base

467# FIPS padding suffix for a message of n bytes, computed with modular
468# arithmetic. The proofs state the streaming hash in terms of it.
469def len_hi(+n: Nat) -> U32:
470  +d0 = Nat.div(n, 32n)
471  +d1 = Nat.div(d0, 256n)
472  +d2 = Nat.div(d1, 256n)
473  +d3 = Nat.div(d2, 256n)
474  +d4 = Nat.div(d3, 256n)
475  +d5 = Nat.div(d4, 256n)
476  +d6 = Nat.div(d5, 256n)
477  pack(U32.from_nat(Nat.mod(d6, 256n)), U32.from_nat(Nat.mod(d5, 256n)),
478    U32.from_nat(Nat.mod(d4, 256n)), U32.from_nat(Nat.mod(d3, 256n)))

Uses (6)

Used by (70)