From 3e41ebdfe931d12c0a3aa7833b66820cf283a2bd Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Thu, 8 Nov 2012 12:52:07 +0100 Subject: [PATCH] mod_to_fractor replaced by more general ext_euclid --- include/codecrypt.h | 1 - lib/decoding.cpp | 2 +- lib/polynomial.cpp | 29 ----------------------------- 3 files changed, 1 insertion(+), 31 deletions(-) diff --git a/include/codecrypt.h b/include/codecrypt.h index 1c58b39..ebb02b7 100644 --- a/include/codecrypt.h +++ b/include/codecrypt.h @@ -253,7 +253,6 @@ public: void sqrt (vector&, gf2m&); polynomial gcd (polynomial, gf2m&); - void mod_to_fracton (polynomial&, polynomial&, polynomial&, gf2m&); void ext_euclid (polynomial&, polynomial&, polynomial&, gf2m&, int); bool is_irreducible (gf2m&) const; diff --git a/lib/decoding.cpp b/lib/decoding.cpp index 3957332..cd04824 100644 --- a/lib/decoding.cpp +++ b/lib/decoding.cpp @@ -38,7 +38,7 @@ void compute_goppa_error_locator (polynomial&syndrome, gf2m&fld, v.sqrt (sqInv, fld); //v = sqrt((1/s)+x) mod goppa polynomial a, b; - v.mod_to_fracton (a, b, goppa, fld); + v.ext_euclid (a, b, goppa, fld, goppa.degree()/2); a.square (fld); b.square (fld); diff --git a/lib/polynomial.cpp b/lib/polynomial.cpp index f7a97c1..19070b0 100644 --- a/lib/polynomial.cpp +++ b/lib/polynomial.cpp @@ -391,32 +391,3 @@ void polynomial::ext_euclid (polynomial&a_out, polynomial&b_out, b.swap (b_out); } -void polynomial::mod_to_fracton (polynomial&a, polynomial&b, - polynomial&m, gf2m&fld) -{ - //TODO: replace with ext_euclid - int deg = m.degree() / 2; - polynomial a0, a1, b0, b1, q, r; - a0 = m; - a1 = *this; - a1.mod (m, fld); - - b0.clear(); - b1.clear(); - b1.resize (1, 1); - - while (a1.degree() > deg) { - - a0.divmod (a1, q, r, fld); - a0.swap (a1); - a1.swap (r); - - q.mult (b1, fld); - q.mod (m, fld); - q.add (b0, fld); - b0.swap (b1); - b1.swap (q); - } - a.swap (a1); - b.swap (b1); -}