def mulx
import bend-collections@1.0.0.0/src/crypto/aes/gcm.bend as Gcmimport Base
25# V * x: the block shifted one bit toward x^127, x^128 = R.
26def mulx(v: Block) -> Block:
27 match v:
28 case B{+a, +b, +c, +d}:
29 B{U32.xor(U32.and(3774873600, U32.sub(0, U32.and(1, d))), U32.shrn(a, 1n)),
30 U32.or(U32.shln(a, 31n), U32.shrn(b, 1n)),
31 U32.or(U32.shln(b, 31n), U32.shrn(c, 1n)),
32 U32.or(U32.shln(c, 31n), U32.shrn(d, 1n))}