Sha.length_field: def of bend-collections@1.0.0.0 Import: import bend-collections@1.0.0.0/spec/crypto/sha.bend as Sha Lines 44-47 of bend-collections@1.0.0.0/spec/crypto/sha.bend: https://jend.leeeet.dev/read.txt?path=bend-collections@1.0.0.0/spec/crypto/sha.bend&start_line=44&end_line=47 import Base # 8*n = 256*(n/32) + 8*(n mod 32); avoids overflowing runtime Nat. def length_field(+n: Nat) -> List<&2, U32>: List.append(&2, U32, octets(7n, Nat.div(n, 32n)), [U32.shln(U32.from_nat(Nat.mod(n, 32n)), 3n)]) Uses (9): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List.append https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.div https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat.mod https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.from_nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.shln https://jend.leeeet.dev/definition.txt?path=bend-collections@1.0.0.0/spec/crypto/sha.bend&name=octets