vector helpers
This commit is contained in:
parent
b22e2177fe
commit
5ba94ca423
|
@ -77,6 +77,9 @@ public:
|
||||||
void extend_left_compact (matrix&);
|
void extend_left_compact (matrix&);
|
||||||
bool create_goppa_generator (matrix&, permutation&, prng&);
|
bool create_goppa_generator (matrix&, permutation&, prng&);
|
||||||
bool create_goppa_generator (matrix&, const permutation&);
|
bool create_goppa_generator (matrix&, const permutation&);
|
||||||
|
|
||||||
|
bool mult_vecT_left (const bvector&, bvector&);
|
||||||
|
bool mult_vec_right (const bvector&, bvector&);
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -158,6 +161,13 @@ public:
|
||||||
int prepare();
|
int prepare();
|
||||||
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&);
|
||||||
|
|
||||||
|
uint cipher_size() {
|
||||||
|
return Pinv.size();
|
||||||
|
}
|
||||||
|
uint plain_size() {
|
||||||
|
return Sinv.width();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class pubkey
|
class pubkey
|
||||||
|
@ -168,6 +178,13 @@ public:
|
||||||
|
|
||||||
int encrypt (const bvector&, bvector&, prng&);
|
int encrypt (const bvector&, bvector&, prng&);
|
||||||
int verify (const bvector&, const bvector&, uint, uint);
|
int verify (const bvector&, const bvector&, uint, uint);
|
||||||
|
|
||||||
|
uint cipher_size() {
|
||||||
|
return G.width();
|
||||||
|
}
|
||||||
|
uint plain_size() {
|
||||||
|
return G.height();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int generate (pubkey&, privkey&, prng&, uint m, uint t);
|
int generate (pubkey&, privkey&, prng&, uint m, uint t);
|
||||||
|
|
|
@ -161,3 +161,31 @@ bool matrix::create_goppa_generator (matrix&g, const permutation&p)
|
||||||
s.extend_left_compact (g);
|
s.extend_left_compact (g);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool matrix::mult_vecT_left (const bvector&a, bvector&r)
|
||||||
|
{
|
||||||
|
uint w = width(), h = height();
|
||||||
|
if (a.size() != h) return false;
|
||||||
|
r.resize (w, 0);
|
||||||
|
for (uint i = 0; i < w; ++i) {
|
||||||
|
bool t = 0;
|
||||||
|
for (uint j = 0; j < h; ++j)
|
||||||
|
t ^= item (i) [j] & a[j];
|
||||||
|
r[i] = t;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool matrix::mult_vec_right (const bvector&a, bvector&r)
|
||||||
|
{
|
||||||
|
uint w = width(), h = height();
|
||||||
|
if (a.size() != w) return false;
|
||||||
|
r.resize (h, 0);
|
||||||
|
for (uint i = 0; i < h; ++i) {
|
||||||
|
bool t = 0;
|
||||||
|
for (uint j = 0; j < w; ++j)
|
||||||
|
t ^= item (j) [i] & a[j];
|
||||||
|
r[i] = t;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -32,7 +32,8 @@ ostream& operator<<(ostream&o, ccr::gf2m f)
|
||||||
ostream& operator<< (ostream&o, ccr::matrix m)
|
ostream& operator<< (ostream&o, ccr::matrix m)
|
||||||
{
|
{
|
||||||
uint i, j, h, w;
|
uint i, j, h, w;
|
||||||
h=m.height();w=m.width();
|
h = m.height();
|
||||||
|
w = m.width();
|
||||||
o << "binary " << h << "x" << w << " matrix:" << endl;
|
o << "binary " << h << "x" << w << " matrix:" << endl;
|
||||||
for (i = 0; i < h; ++i) {
|
for (i = 0; i < h; ++i) {
|
||||||
for (j = 0; j < w; ++j) o << m[j][i];
|
for (j = 0; j < w; ++j) o << m[j][i];
|
||||||
|
|
Loading…
Reference in a new issue