restyled decoding

This commit is contained in:
Mirek Kratochvil 2012-05-15 14:02:42 +02:00
parent d208819103
commit 977d3afdc9

View file

@ -9,15 +9,18 @@ void syndrome_decode (bvector&syndrome, gf2m&fld, polynomial& goppa,
ev.resize (fld.n, 0); ev.resize (fld.n, 0);
if (syndrome.zero() ) return; if (syndrome.zero() ) return;
polynomial p; polynomial v;
syndrome.to_poly (p, fld); syndrome.to_poly (v, fld);
p.inv (goppa, fld); // p=S^-1 mod goppa
p[1] = fld.add (1, p[1]); //p is now tau v.inv (goppa, fld); // v=Synd^-1 mod goppa
p.sqrt (sqInv, fld); //tau = sqrt(T+x) mod goppa
if (v.size() < 2) v.resize (2, 0);
v[1] = fld.add (1, v[1]); //add x
v.sqrt (sqInv, fld); //v = sqrt((1/s)+x) mod goppa
polynomial a, b; polynomial a, b;
p.mod_to_fracton (a, b, goppa, fld); v.mod_to_fracton (a, b, goppa, fld);
a.square (fld); a.square (fld);
b.square (fld); b.square (fld);
b.shift (1); b.shift (1);
@ -26,6 +29,6 @@ void syndrome_decode (bvector&syndrome, gf2m&fld, polynomial& goppa,
a.make_monic (fld); //now it is the error locator. a.make_monic (fld); //now it is the error locator.
for (uint i = 0; i < fld.n; ++i) { for (uint i = 0; i < fld.n; ++i) {
if (0 == a.eval (i, fld) ) ev[i] = 1; if (a.eval (i, fld) == 0) ev[i] = 1;
} }
} }