From 0db682e5df45b7d614646b236c66a8addc221b65 Mon Sep 17 00:00:00 2001 From: Mirek Kratochvil Date: Tue, 15 May 2012 13:58:48 +0200 Subject: [PATCH] simplified check matrix creation --- lib/polynomial.cpp | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/lib/polynomial.cpp b/lib/polynomial.cpp index f8ceb7b..f29b49a 100644 --- a/lib/polynomial.cpp +++ b/lib/polynomial.cpp @@ -222,37 +222,18 @@ uint polynomial::eval (uint x, gf2m&fld) const void polynomial::compute_goppa_check_matrix (matrix&r, gf2m&fld) { if (degree() < 0) return; //wrongly initialized polynomial - uint t = degree(); - vector vd, h; //matrix over fld - uint i, j, k; - //construction from Barreto's slides with maximal support L=[0..fld.n) - vd.resize (fld.n); - for (i = 0; i < fld.n; ++i) { - vd[i].resize (t); - vd[i][0] = fld.inv (eval (i, fld) ); - } - //compute support powers - for (j = 0; j < fld.n; ++j) for (i = 1; i < t; ++i) - vd[j][i] = fld.mult (vd[j][i-1], j); - - //multiply by goppa coefficients (compute t*vd) - h.resize (fld.n); - for (i = 0; i < fld.n; ++i) { - h[i].resize (t); - for (j = 0; j < t; ++j) { //computing the element h[i][j] - h[i][j] = 0; - for (k = 0; k <= j; ++k) //k = column index of t - h[i][j] = fld.add (h[i][j], - fld.mult (item (t + k - j), - vd[i][k]) ); - } - } - - //now convert to binary r.resize (fld.n); - for (i = 0; i < fld.n; ++i) - r[i].from_poly (h[i], fld); + + for (uint i = 0; i < fld.n; ++i) { + polynomial col; + col.resize (2); + col[0] = i; + col[1] = 1; + col.inv(*this,fld); + //i-th row of the check matrix is polynomial 1/(x-i) + r[i].from_poly(col,fld); + } } void polynomial::make_monic (gf2m&fld)