goppa generator matrix

This commit is contained in:
Mirek Kratochvil 2012-04-05 13:52:42 +02:00
parent 1b37691f31
commit 9e97374131
3 changed files with 35 additions and 12 deletions

View file

@ -74,7 +74,9 @@ public:
void unit (uint);
bool get_left_square (matrix&);
bool strip_left_square (matrix&);
void extend_left_compact (matrix&);
bool goppa_systematic_form (matrix&, permutation&, prng&);
bool goppa_systematic_form (matrix&, const permutation&);
};
/*
@ -86,12 +88,12 @@ class permutation : public std::vector<uint>
protected:
_ccr_declare_vector_item
public:
void compute_inversion (permutation&);
void compute_inversion (permutation&) const;
void generate_random (uint n, prng&);
void permute (const bvector&, bvector&);
void permute (const matrix&, matrix&);
void permute_rows (const matrix&, matrix&);
void permute (const bvector&, bvector&) const;
void permute (const matrix&, matrix&) const;
void permute_rows (const matrix&, matrix&) const;
};
/*

View file

@ -127,16 +127,37 @@ bool matrix::strip_left_square (matrix&r)
return true;
}
bool matrix::goppa_systematic_form (matrix&m, permutation&p, prng&rng)
void matrix::extend_left_compact (matrix&r)
{
uint i;
uint h = height(), w = width();
r.resize (h + w);
for (i = 0; i < h; ++i) {
r[i].resize (h, 0);
r[i][i] = 1;
}
for (i = 0; i < w; ++i) {
r[h+i] = item (i);
}
}
bool matrix::goppa_systematic_form (matrix&g, permutation&p, prng&rng)
{
p.generate_random (width(), rng);
return goppa_systematic_form (g, p);
}
bool matrix::goppa_systematic_form (matrix&g, const permutation&p)
{
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;
s.strip_left_square (t); //matrix pingpong. optimize it.
t.compute_transpose (s);
s.extend_left_compact (g);
return true;
}

View file

@ -3,7 +3,7 @@
using namespace ccr;
void permutation::compute_inversion (permutation&r)
void permutation::compute_inversion (permutation&r) const
{
r.resize (size(), 0);
for (uint i = 0; i < size(); ++i)
@ -27,19 +27,19 @@ void permutation::generate_random (uint size, prng&rng)
}
}
void permutation::permute (const bvector&a, bvector&r)
void permutation::permute (const bvector&a, bvector&r) const
{
r.resize (a.size() );
for (uint i = 0; i < size(); ++i) r[item (i) ] = a[i];
}
void permutation::permute (const matrix&a, matrix&r)
void permutation::permute (const matrix&a, matrix&r) const
{
r.resize (a.size() );
for (uint i = 0; i < size(); ++i) r[item (i) ] = a[i];
}
void permutation::permute_rows (const matrix&a, matrix&r)
void permutation::permute_rows (const matrix&a, matrix&r) const
{
r.resize (a.size() );
for (uint i = 0; i < a.size(); ++i) permute (a[i], r[i]);