def Gf8Bits.x

bend-osdev-gf@0.1.1.0 · gf.bend:77

import bend-osdev-gf@0.1.1.0/gf.bend as Gf
import Base

77# a times x, where p holds the low 8 bits of the polynomial: shift up one
78# place, and if the coefficient of x^8 was set, add p (x^8 = p in the field)
79def Gf8Bits.x(a: Gf8Bits, p: Gf8Bits) -> Gf8Bits:
80  match a p:
81    case Gf8Bits{a0, a1, a2, a3, a4, a5, a6, +a7} Gf8Bits{p0, p1, p2, p3, p4, p5, p6, p7}:
82      Gf8Bits{Bool.and(a7, p0), Bool.xor(a0, Bool.and(a7, p1)), Bool.xor(a1, Bool.and(a7, p2)), Bool.xor(a2, Bool.and(a7, p3)), Bool.xor(a3, Bool.and(a7, p4)), Bool.xor(a4, Bool.and(a7, p5)), Bool.xor(a5, Bool.and(a7, p6)), Bool.xor(a6, Bool.and(a7, p7))}

Uses (3)

Used by (14)