def length_field
import bend-collections-laws-crypto@1.0.0.0/spec/crypto/sha512.bend as Sha512import Base
149# The 128-bit block of the message length in bits, 8n: its low octet is
150# 8 * (n mod 32) and the fifteen above it are n div 32 in base 256
151# (8n = 256 * (n div 32) + 8 * (n mod 32)), so no Nat above n is formed.
152def length_field(+n: Nat) -> List<&2, U32>:
153 List.append(&2, U32, octets(15n, Nat.div(n, 32n)),
154 [U32.shln(U32.from_nat(Nat.mod(n, 32n)), 3n)])