gf(2) Berlekamp Algorithm

If possible, factor polynomial, including at least one irreducible factor.

f = b0000000000000000000000000000000000000000000001101010101111101101
f = 0x000000000006abed
f = x18 + x17 + x15 + x13 + x11 + x9 + x8 + x7 + x6 + x5 + x3 + x2 + 1

Calculate vn = x2n (mod f) for n=0 to 18

v0 = x0 (mod f)
v0 = b0000000000000000000000000000000000000000000000000000000000000001
v0 = 0x0000000000000001
v0 = 1

v1 = x2 (mod f)
v1 = b0000000000000000000000000000000000000000000000000000000000000100
v1 = 0x0000000000000004
v1 = x2

v2 = x4 (mod f)
v2 = b0000000000000000000000000000000000000000000000000000000000010000
v2 = 0x0000000000000010
v2 = x4

v3 = x6 (mod f)
v3 = b0000000000000000000000000000000000000000000000000000000001000000
v3 = 0x0000000000000040
v3 = x6

v4 = x8 (mod f)
v4 = b0000000000000000000000000000000000000000000000000000000100000000
v4 = 0x0000000000000100
v4 = x8

v5 = x10 (mod f)
v5 = b0000000000000000000000000000000000000000000000000000010000000000
v5 = 0x0000000000000400
v5 = x10

v6 = x12 (mod f)
v6 = b0000000000000000000000000000000000000000000000000001000000000000
v6 = 0x0000000000001000
v6 = x12

v7 = x14 (mod f)
v7 = b0000000000000000000000000000000000000000000000000100000000000000
v7 = 0x0000000000004000
v7 = x14

v8 = x16 (mod f)
v8 = b0000000000000000000000000000000000000000000000010000000000000000
v8 = 0x0000000000010000
v8 = x16

v9 = x18 (mod f)
v9 = b0000000000000000000000000000000000000000000000101010101111101101
v9 = 0x000000000002abed
v9 = x17 + x15 + x13 + x11 + x9 + x8 + x7 + x6 + x5 + x3 + x2 + 1

v10 = x20 (mod f)
v10 = b0000000000000000000000000000000000000000000000010101001110000011
v10 = 0x0000000000015383
v10 = x16 + x14 + x12 + x9 + x8 + x7 + x + 1

v11 = x22 (mod f)
v11 = b0000000000000000000000000000000000000000000000111110010111100001
v11 = 0x000000000003e5e1
v11 = x17 + x16 + x15 + x14 + x13 + x10 + x8 + x7 + x6 + x5 + 1

v12 = x24 (mod f)
v12 = b0000000000000000000000000000000000000000000000101100000001011110
v12 = 0x000000000002c05e
v12 = x17 + x15 + x14 + x6 + x4 + x3 + x2 + x

v13 = x26 (mod f)
v13 = b0000000000000000000000000000000000000000000000001111110101001111
v13 = 0x000000000000fd4f
v13 = x15 + x14 + x13 + x12 + x11 + x10 + x8 + x6 + x3 + x2 + x + 1

v14 = x28 (mod f)
v14 = b0000000000000000000000000000000000000000000000111111010100111100
v14 = 0x000000000003f53c
v14 = x17 + x16 + x15 + x14 + x13 + x12 + x10 + x8 + x5 + x4 + x3 + x2

v15 = x30 (mod f)
v15 = b0000000000000000000000000000000000000000000000101000001100101010
v15 = 0x000000000002832a
v15 = x17 + x15 + x9 + x8 + x5 + x3 + x

v16 = x32 (mod f)
v16 = b0000000000000000000000000000000000000000000000011111000010011111
v16 = 0x000000000001f09f
v16 = x16 + x15 + x14 + x13 + x12 + x7 + x4 + x3 + x2 + x + 1

v17 = x34 (mod f)
v17 = b0000000000000000000000000000000000000000000000010110100110010001
v17 = 0x0000000000016991
v17 = x16 + x14 + x13 + x11 + x8 + x7 + x4 + 1

Represent v0-v17 as matrix Q
Q = 000000000000000001 000000000000000100 000000000000010000 000000000001000000 000000000100000000 000000010000000000 000001000000000000 000100000000000000 010000000000000000 101010101111101101 010101001110000011 111110010111100001 101100000001011110 001111110101001111 111111010100111100 101000001100101010 011111000010011111 010110100110010001
Represent 18x18 identity matrix I
I = 000000000000000001 000000000000000010 000000000000000100 000000000000001000 000000000000010000 000000000000100000 000000000001000000 000000000010000000 000000000100000000 000000001000000000 000000010000000000 000000100000000000 000001000000000000 000010000000000000 000100000000000000 001000000000000000 010000000000000000 100000000000000000
M = Q-I
M = 000000000000000000 000000000000000110 000000000000010100 000000000001001000 000000000100010000 000000010000100000 000001000001000000 000100000010000000 010000000100000000 101010100111101101 010101011110000011 111110110111100001 101101000001011110 001101110101001111 111011010100111100 100000001100101010 001111000010011111 110110100110010001
Find null basis vectors of M

nv0 = b0000000000000000000000000000000000000000000000100110101110101010
nv0 = 0x0000000000026baa
nv0 = x17 + x14 + x13 + x11 + x9 + x8 + x7 + x5 + x3 + x

nv1 = b0000000000000000000000000000000000000000000000011100010001011110
nv1 = 0x000000000001c45e
nv1 = x16 + x15 + x14 + x10 + x6 + x4 + x3 + x2 + x

nv2 = b0000000000000000000000000000000000000000000000000000000000000001
nv2 = 0x0000000000000001
nv2 = 1

Add f to list of known factors (kf)

kfo = b0000000000000000000000000000000000000000000001101010101111101101
kfo = 0x000000000006abed
kfo = x18 + x17 + x15 + x13 + x11 + x9 + x8 + x7 + x6 + x5 + x3 + x2 + 1

For each null basis vector (excluding trivial 1), find known factor (kf) which can be factored.

nv0 = b0000000000000000000000000000000000000000000000100110101110101010
nv0 = 0x0000000000026baa
nv0 = x17 + x14 + x13 + x11 + x9 + x8 + x7 + x5 + x3 + x

New factor (nf) = f/gcd(f,nv0)

nf = b0000000000000000000000000000000000000000000000000000000101110001
nf = 0x0000000000000171
nf = x8 + x6 + x5 + x4 + 1

Search though known factors (kf) for which (nf) factors evenly

kf0 = b0000000000000000000000000000000000000000000001101010101111101101
kf0 = 0x000000000006abed
kf0 = x18 + x17 + x15 + x13 + x11 + x9 + x8 + x7 + x6 + x5 + x3 + x2 + 1

t = kf0/nf

tremainder = b0000000000000000000000000000000000000000000000000000000000000000
tremainder = 0x0000000000000000
tremainder = 0

tremainder == 0, nf is a factor of kf0

kf0 = nf // Replace kf0 with nf
kf1 = tquotient // Append tquotient to known factors list

tquotient = b0000000000000000000000000000000000000000000000000000011111011101
tquotient = 0x00000000000007dd
tquotient = x10 + x9 + x8 + x7 + x6 + x4 + x3 + x2 + 1

nv1 = b0000000000000000000000000000000000000000000000011100010001011110
nv1 = 0x000000000001c45e
nv1 = x16 + x15 + x14 + x10 + x6 + x4 + x3 + x2 + x

New factor (nf) = f/gcd(f,nv1)

nf = b0000000000000000000000000000000000000000000000000011111101100111
nf = 0x0000000000003f67
nf = x13 + x12 + x11 + x10 + x9 + x8 + x6 + x5 + x2 + x + 1

Search though known factors (kf) for which (nf) factors evenly

kf0 = b0000000000000000000000000000000000000000000000000000000101110001
kf0 = 0x0000000000000171
kf0 = x8 + x6 + x5 + x4 + 1

t = kf0/nf

tremainder = b0000000000000000000000000000000000000000000000000000000101110001
tremainder = 0x0000000000000171
tremainder = x8 + x6 + x5 + x4 + 1

tremainder != 0, nf is not a factor.

kf1 = b0000000000000000000000000000000000000000000000000000011111011101
kf1 = 0x00000000000007dd
kf1 = x10 + x9 + x8 + x7 + x6 + x4 + x3 + x2 + 1

t = kf1/nf

tremainder = b0000000000000000000000000000000000000000000000000000011111011101
tremainder = 0x00000000000007dd
tremainder = x10 + x9 + x8 + x7 + x6 + x4 + x3 + x2 + 1

tremainder != 0, nf is not a factor.

Known factors:

kf0 = b0000000000000000000000000000000000000000000000000000000101110001
kf0 = 0x0000000000000171
kf0 = x8 + x6 + x5 + x4 + 1

kf1 = b0000000000000000000000000000000000000000000000000000011111011101
kf1 = 0x00000000000007dd
kf1 = x10 + x9 + x8 + x7 + x6 + x4 + x3 + x2 + 1

Current factorization of f:

f = (b101110001)(b11111011101)
f = (0x171)(0x7dd)
f = (x8 + x6 + x5 + x4 + 1)(x10 + x9 + x8 + x7 + x6 + x4 + x3 + x2 + 1)

See also: