def sp.nib
import bend-osdev-legacy-ciphers@0.1.0.0/serpent.bend as Serpentimport Base
115def sp.nib(b: LcSpBox, inv: Bool, n: LcSpNib) -> LcSpNib:
116 match n:
117 case LcSpNib{x0, x1, x2, x3}:
118 +v = U32.or(U32.or(Bool.to_u32(x0), U32.shl(Bool.to_u32(x1))), U32.or(U32.shln(Bool.to_u32(x2), 2n), U32.shln(Bool.to_u32(x3), 3n)))
119 +w = sp.sbox(b, inv, v)
120 LcSpNib{sp.bit(w, 0n), sp.bit(w, 1n), sp.bit(w, 2n), sp.bit(w, 3n)}