def octets_okb
bend-collections-laws-crypto@1.0.0.0 · proofs/crypto/ed25519/bytes.bend:117
import bend-collections-laws-crypto@1.0.0.0/proofs/crypto/ed25519/bytes.bend as Bytes
import Base
import bend-collections-laws-crypto@1.0.0.0/src/crypto/sha512/core.bend as C512
import bend-collections-laws-crypto@1.0.0.0/proofs/crypto/curve25519/limbs.bend as LM
117def octets_okb(+n: Nat, +x: U32, +t: List<&2, U32>, +ht: {LM.okb(n, t, 255n) == True{} : Bool}) -> {LM.okb(4n+n, C512.octets(x, t), 255n) == True{} : Bool}:
118 +b0 = U32.and(x, 255)
119 +b1 = U32.and(U32.shrn(x, 8n), 255)
120 +b2 = U32.and(U32.shrn(x, 16n), 255)
121 +b3 = U32.and(U32.shrn(x, 24n), 255)
122 +l0 = okb_con(n, b0, t, byte_and(x), ht)
123 +l1 = okb_con(1n+n, b1, Con{b0, t}, byte_and(U32.shrn(x, 8n)), l0)
124 +l2 = okb_con(2n+n, b2, Con{b1, Con{b0, t}}, byte_and(U32.shrn(x, 16n)), l1)
125 okb_con(3n+n, b3, Con{b2, Con{b1, Con{b0, t}}}, byte_and(U32.shrn(x, 24n)), l2)