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:
parent
0978a40372
commit
7a71ca74f0
18
src/gf2m.h
18
src/gf2m.h
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue