def len_hi

bend-collections@1.0.0.0 · spec/crypto/sha/packed.bend:5

import bend-collections@1.0.0.0/spec/crypto/sha/packed.bend as Packed
import Base
import bend-collections@1.0.0.0/spec/crypto/sha.bend as F

5# Packed-format reference: logical input byte j is the big-endian byte j%4
6# of array word floor(j/4). Only the declared prefix is part of the message.
7# Block collection uses a generic list reader, not the optimized 16-read chain.
8def len_hi(+n: Nat) -> U32:
9  +d0 = Nat.div(n, 32n)
10  +d1 = Nat.div(d0, 256n)
11  +d2 = Nat.div(d1, 256n)
12  +d3 = Nat.div(d2, 256n)
13  +d4 = Nat.div(d3, 256n)
14  +d5 = Nat.div(d4, 256n)
15  +d6 = Nat.div(d5, 256n)
16  F.decode(U32.from_nat(Nat.mod(d6, 256n)), U32.from_nat(Nat.mod(d5, 256n)),
17    U32.from_nat(Nat.mod(d4, 256n)), U32.from_nat(Nat.mod(d3, 256n)))

Uses (6)

Used by (2)