more cleaniness
This commit is contained in:
parent
78da95a2e8
commit
b54fcb9bf3
|
@ -72,6 +72,7 @@ int privkey::decrypt (const bvector&in, bvector&out)
|
||||||
//prepare for decoding
|
//prepare for decoding
|
||||||
permutation hpermInv;
|
permutation hpermInv;
|
||||||
hperm.compute_inversion (hpermInv);
|
hperm.compute_inversion (hpermInv);
|
||||||
|
|
||||||
bvector canonical, syndrome;
|
bvector canonical, syndrome;
|
||||||
hpermInv.permute (not_permuted, canonical);
|
hpermInv.permute (not_permuted, canonical);
|
||||||
h.mult_vec_right (canonical, syndrome);
|
h.mult_vec_right (canonical, syndrome);
|
||||||
|
@ -80,8 +81,7 @@ int privkey::decrypt (const bvector&in, bvector&out)
|
||||||
bvector ev;
|
bvector ev;
|
||||||
syndrome_decode (syndrome, fld, g, sqInv, ev);
|
syndrome_decode (syndrome, fld, g, sqInv, ev);
|
||||||
|
|
||||||
std::cout << "ERRORS " << ev;
|
// check the error vector, it should have exactly t == deg (g) errors
|
||||||
//check the error vector. It should have exactly t == deg(g) errors
|
|
||||||
if ( (int) ev.hamming_weight() != g.degree() )
|
if ( (int) ev.hamming_weight() != g.degree() )
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|
|
@ -230,9 +230,9 @@ void polynomial::compute_goppa_check_matrix (matrix&r, gf2m&fld)
|
||||||
col.resize (2);
|
col.resize (2);
|
||||||
col[0] = i;
|
col[0] = i;
|
||||||
col[1] = 1;
|
col[1] = 1;
|
||||||
col.inv(*this,fld);
|
col.inv (*this, fld);
|
||||||
//i-th row of the check matrix is polynomial 1/(x-i)
|
//i-th row of the check matrix is polynomial 1/(x-i)
|
||||||
r[i].from_poly(col,fld);
|
r[i].from_poly (col, fld);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ void polynomial::div (polynomial&p, polynomial&m, gf2m&fld)
|
||||||
|
|
||||||
s0.clear();
|
s0.clear();
|
||||||
|
|
||||||
s1.swap(*this);
|
s1.swap (*this);
|
||||||
s1.mod (m, fld);
|
s1.mod (m, fld);
|
||||||
|
|
||||||
while (r1.degree() >= 0) {
|
while (r1.degree() >= 0) {
|
||||||
|
@ -302,13 +302,13 @@ void polynomial::div (polynomial&p, polynomial&m, gf2m&fld)
|
||||||
s1.swap (s2);
|
s1.swap (s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->swap(s0);
|
this->swap (s0);
|
||||||
|
|
||||||
//scalar divide by r0 head
|
//scalar divide by r0 head
|
||||||
if(r0.degree()<0) return;
|
if (r0.degree() < 0) return;
|
||||||
uint c=r0[r0.degree()];
|
uint c = r0[r0.degree() ];
|
||||||
c=fld.inv(c);
|
c = fld.inv (c);
|
||||||
for(uint i=0;i<size();++i) item(i) = fld.mult(item(i),c);
|
for (uint i = 0; i < size(); ++i) item (i) = fld.mult (item (i), c);
|
||||||
}
|
}
|
||||||
|
|
||||||
void polynomial::divmod (polynomial&d, polynomial&res, polynomial&rem, gf2m&fld)
|
void polynomial::divmod (polynomial&d, polynomial&res, polynomial&rem, gf2m&fld)
|
||||||
|
|
|
@ -39,7 +39,7 @@ int main()
|
||||||
cout << pub.G;
|
cout << pub.G;
|
||||||
|
|
||||||
ccr::bvector plain;
|
ccr::bvector plain;
|
||||||
plain.resize (pub.plain_size() );
|
plain.resize (pub.plain_size(), 0);
|
||||||
plain[0] = 1;
|
plain[0] = 1;
|
||||||
plain[1] = 1;
|
plain[1] = 1;
|
||||||
plain[2] = 1;
|
plain[2] = 1;
|
||||||
|
|
Loading…
Reference in a new issue