matrix systematic form
This commit is contained in:
parent
19225c3665
commit
1b37691f31
|
@ -50,6 +50,7 @@ public:
|
||||||
/*
|
/*
|
||||||
* matrix over GF(2) is a vector of columns
|
* matrix over GF(2) is a vector of columns
|
||||||
*/
|
*/
|
||||||
|
class permutation;
|
||||||
class matrix : public std::vector<bvector>
|
class matrix : public std::vector<bvector>
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
@ -71,6 +72,9 @@ public:
|
||||||
bool compute_inversion (matrix&);
|
bool compute_inversion (matrix&);
|
||||||
void generate_random_invertible (uint, prng&);
|
void generate_random_invertible (uint, prng&);
|
||||||
void unit (uint);
|
void unit (uint);
|
||||||
|
bool get_left_square (matrix&);
|
||||||
|
bool strip_left_square (matrix&);
|
||||||
|
bool goppa_systematic_form (matrix&, permutation&, prng&);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -141,12 +145,12 @@ class privkey
|
||||||
public:
|
public:
|
||||||
matrix Sinv;
|
matrix Sinv;
|
||||||
permutation Pinv;
|
permutation Pinv;
|
||||||
|
|
||||||
matrix h;
|
|
||||||
permutation hsys;
|
|
||||||
|
|
||||||
polynomial g;
|
polynomial g;
|
||||||
matrix sqInv; //"cache"
|
|
||||||
|
// derivable things not needed in actual key
|
||||||
|
matrix h;
|
||||||
|
permutation hperm;
|
||||||
|
matrix sqInv;
|
||||||
|
|
||||||
int decrypt (const bvector&, bvector&);
|
int decrypt (const bvector&, bvector&);
|
||||||
int sign (const bvector&, bvector&, uint, uint, prng&);
|
int sign (const bvector&, bvector&, uint, uint, prng&);
|
||||||
|
|
|
@ -109,3 +109,34 @@ void matrix::generate_random_invertible (uint size, prng & rng)
|
||||||
p.permute (lt, *this);
|
p.permute (lt, *this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool matrix::get_left_square (matrix&r)
|
||||||
|
{
|
||||||
|
uint h = height();
|
||||||
|
if (width() < h) return false;
|
||||||
|
r.resize (h);
|
||||||
|
for (uint i = 0; i < h; ++i) r[i] = item (i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool matrix::strip_left_square (matrix&r)
|
||||||
|
{
|
||||||
|
uint h = height(), w = width();
|
||||||
|
if (w < h) return false;
|
||||||
|
r.resize (w - h);
|
||||||
|
for (uint i = 0; i < w - h; ++i) r[i] = item (h + i);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool matrix::goppa_systematic_form (matrix&m, permutation&p, prng&rng)
|
||||||
|
{
|
||||||
|
matrix t, sinv, s;
|
||||||
|
|
||||||
|
p.generate_random (width(), rng);
|
||||||
|
p.permute (*this, t);
|
||||||
|
t.get_left_square (sinv);
|
||||||
|
if (!sinv.compute_inversion (s) ) return false; //meant to be retried.
|
||||||
|
|
||||||
|
s.mult (t);
|
||||||
|
s.strip_left_square (m);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue