1
0
mirror of https://github.com/biergaizi/codecrypt synced 2024-06-27 09:18:16 +00:00

mce_qd: faster alternant check matrix computation

Save a lot of log/antilog lookups. On my machine, this is 4-6x faster.
This commit is contained in:
Mirek Kratochvil 2014-02-08 09:48:10 +01:00
parent 0978a40372
commit 7a71ca74f0
2 changed files with 20 additions and 5 deletions

@ -82,6 +82,24 @@ public:
sencode* serialize();
bool unserialize (sencode*);
//optimized part of creating alternant check matrix
template<class iter>
inline void add_mults (uint base, uint step, iter begin, iter end) {
if (begin == end || base == 0) return;
*begin = add (*begin, base);
++begin;
if (begin == end || step == 0) return;
uint lb = log[base], ls = log[step];
for (; begin != end; ++begin) {
lb = (lb + ls) % (n - 1);
*begin = add (*begin, antilog[lb]);
}
}
};
#endif

@ -413,11 +413,8 @@ int privkey::decrypt (const bvector & in, bvector & out, bvector & errors)
for (i = 0; i < cipher_size(); ++i) if (in[i]) {
tmp = fld.inv_square //g(Li)^{-2}
(g.eval (permuted_support[i], fld) );
synd[0] = fld.add (synd[0], tmp);
for (j = 1; j < h_size; ++j) {
tmp = fld.mult (tmp, permuted_support[i]);
synd[j] = fld.add (synd[j], tmp);
}
fld.add_mults (tmp, permuted_support[i],
synd.begin(), synd.end() );
}
//decoding