This commit is contained in:
Mirek Kratochvil 2012-04-20 10:11:21 +02:00
parent 0b4a55d235
commit 985c71e831
4 changed files with 8 additions and 5 deletions

View file

@ -34,7 +34,8 @@ bool bvector::zero() const
void bvector::to_poly (polynomial&r, gf2m&fld) void bvector::to_poly (polynomial&r, gf2m&fld)
{ {
r.clear(); r.clear();
r.resize ( (size() % fld.m) ? 1 : 0 + (size() / fld.m), 0); if(size() % fld.m) return; //impossible
r.resize (size() / fld.m, 0);
for (uint i = 0; i < size(); ++i) for (uint i = 0; i < size(); ++i)
if (item (i) ) r[i/fld.m] |= 1 << (i % fld.m); if (item (i) ) r[i/fld.m] |= 1 << (i % fld.m);
} }

View file

@ -5,6 +5,7 @@ void syndrome_decode (bvector&syndrome, gf2m&fld, polynomial& goppa,
std::vector<polynomial>& sqInv, bvector&ev) std::vector<polynomial>& sqInv, bvector&ev)
{ {
ev.clear();
ev.resize (fld.n, 0); ev.resize (fld.n, 0);
if (syndrome.zero() ) return; if (syndrome.zero() ) return;

View file

@ -95,7 +95,7 @@ int privkey::decrypt (const bvector&in, bvector&out)
not_permuted.resize (Sinv.size() ); not_permuted.resize (Sinv.size() );
//unscramble the result //unscramble the result
Sinv.mult_vec_right (not_permuted, out); Sinv.mult_vecT_left (not_permuted, out);
return 0; return 0;
} }

View file

@ -244,8 +244,9 @@ void polynomial::compute_goppa_check_matrix (matrix&r, gf2m&fld)
//multiply by goppa coefficients (compute t*vd) //multiply by goppa coefficients (compute t*vd)
h.resize (fld.n); h.resize (fld.n);
for (i = 0; i < fld.n; ++i) { for (i = 0; i < fld.n; ++i) {
h[i].resize (t, 0); h[i].resize (t);
for (j = 0; j < t; ++j) //computing the element h[i][j] 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 for (k = 0; k <= j; ++k) //k = column index of t
h[i][j] = fld.add (h[i][j], h[i][j] = fld.add (h[i][j],
fld.mult (item (t - j + k), fld.mult (item (t - j + k),
@ -285,7 +286,7 @@ void polynomial::sqrt (vector<polynomial>& sqInv, gf2m&fld)
{ {
polynomial a = *this; polynomial a = *this;
clear(); clear();
uint s=sqInv.size(); uint s = sqInv.size();
resize (s, 0); resize (s, 0);
for (uint i = 0; i < s; ++i) { for (uint i = 0; i < s; ++i) {