20 #ifndef __GSDECODER_H__
21 #define __GSDECODER_H__
27 #include <NTL/mat_ZZ_p.h>
28 #include <NTL/mat_GF2E.h>
29 #include "percyresult.h"
31 #include "portfolio.h"
105 typedef pair<unsigned int, unsigned int> pairint;
106 #define Ccache_t map<pairint, F>
109 static F C(Ccache_t &Ccache,
unsigned int n,
unsigned int k)
115 typename Ccache_t::const_iterator Ci = Ccache.find(nk);
116 if (Ci != Ccache.end()) {
145 bool cmp (
const GF2EX& a,
const GF2EX& b);
146 bool cmp (
const ZZ_pX& a,
const ZZ_pX& b);
160 template <
class F,
class vec_F,
class FX,
class FXY,
class mat_F>
171 RSDecoder(
const ZZ &p1,
const ZZ &p2): p1(p1), p2(p2) {}
199 bool Recover (dbsize_t bytes_per_word, nservers_t t, nservers_t h,
200 const vector<nservers_t> &goodservers,
const vector<vector<vec_F> > &values,
202 vector<std::set<dbsize_t> > &decoded,
203 const vector<vec_F> &vec_interp_indices,
204 const nqueries_t multi_only = 0);
212 static string append(
const string &s,
const F &wz,
213 unsigned int bytes_per_word);
233 const vec_F &values,
const vec_F &indices,
234 const vector<unsigned short> &I,
235 const vector<unsigned short> &G,
236 unsigned short &numagree,
unsigned short &numdisagree,
237 vector<unsigned short> &vecagree, FX &phi);
257 vector<FX> findroots(
const FXY &P,
int degreebound);
259 #if defined(TEST_FINDPOLYS) || defined(TIME_FINDPOLYS)
266 vector< RecoveryPoly<FX> > findpolys(
int k,
267 unsigned int t,
const vector<unsigned short> &goodservers,
268 const vec_F &indices,
const vec_F &shares, TestType &testType, DPType
270 vector< RecoveryPoly<FX> > findpolys(
int k,
271 unsigned int t,
const vector<unsigned short> &goodservers,
272 const vec_F &indices,
const vec_F &shares, TestType &testType)
274 DPType dptype;
int gord;
275 return findpolys(k, t, goodservers, indices, shares, testType, dptype,
278 vector< RecoveryPoly<FX> > findpolys(
int k,
279 unsigned int t,
const vector<unsigned short> &goodservers,
280 const vec_F &indices,
const vec_F &shares)
282 TestType testtype; DPType dptype;
int gord;
283 return findpolys(k, t, goodservers, indices, shares, testtype, dptype,
288 vector< RecoveryPoly<FX> > findpolys_best(
unsigned int n,
int ell,
289 unsigned int h,
const vector<unsigned short> &goodservers,
290 const vec_F &indices,
const vec_F &shares, TestType &testType,
291 DPType &dpType,
int &gord);
294 vector< RecoveryPolyMulti<FX> > findpolys_multi(
unsigned int k,
295 unsigned int t,
const vector<unsigned short> &goodservers,
296 const vec_F &indices,
const vector<vec_F> &shares, TestType testType = CH_TK1);
303 vector< RecoveryPoly<FX> > findpolys_gs(
unsigned int k,
unsigned int t,
304 const vector<unsigned short> &goodservers,
305 const vec_F& indices,
const vec_F& shares, TestType testType = KOTTER);
315 vector<RecoveryPoly<FX> > findpolys_brute(
316 int k_signed,
unsigned int t,
317 const vector<unsigned short> &goodservers,
318 const vec_F &indices,
const vec_F &shares);
323 vector<RecoveryPoly<FX> > findpolys_bw(
324 unsigned int ell,
unsigned int h,
325 const vector<unsigned short> &goodservers,
326 const vec_F &indices,
const vec_F &shares);
330 vector<RecoveryPoly<FX> > findpolys_dp (
unsigned int ell,
unsigned int h,
331 const vector<unsigned short> &goodservers,
332 const vec_F &indices,
const vec_F &shares,
333 const DPType,
unsigned int gord);
335 #ifdef INCLUDE_GENERAL_MULTI
337 vector<map<unsigned int, FX> > solve_partial_solution (
338 unsigned int ell,
unsigned int h, map<unsigned int, FX> partial,
339 const vector<vector<FX> >& rows, vector<unsigned int> row_order,
340 const vector<vector<unsigned int> >& order_of_expts);
344 vector<RecoveryPolyMulti<FX> > findpolys_ch_multi(
345 unsigned int ell,
unsigned int h,
unsigned int m,
unsigned int& t,
347 const vector<unsigned short> &goodservers,
348 const vec_F &indices,
const vector<vec_F> &shares);
354 vector<RecoveryPolyMulti<FX> > findpolys_ch_tk1(
355 unsigned int ell,
unsigned int h,
unsigned int m,
356 const vector<unsigned short> &goodservers,
357 const vec_F &indices,
const vector<vec_F> &shares);
360 vector<FX> solve_linsys_FX (vector<vector<FX> >& A, vector<FX>& b,
361 unsigned int modulus = 0);
377 FXY interpolate_kotter(
unsigned int v,
unsigned int t,
378 const vector<unsigned short> &goodservers,
379 const vec_F &indices,
const vec_F &shares);
389 FXY interpolate_cohn_heninger(
unsigned int v,
unsigned int h,
390 const vector<unsigned short> &goodservers,
391 const vec_F &indices,
const vec_F &shares);
400 vector<vector<FX> > reduce_lattice_MS(vector<vector<FX> > lattice,
403 vector<vector<FX> >& aux,
404 const int reduceTo = -1,
const unsigned int reduceNumber = 1);
406 FXY reduce_lattice_opt(vector<FXY> lattice,
const unsigned int n,
407 const unsigned int ell,
const unsigned int k);
418 F evalhasse(
const FXY &g,
unsigned int r,
unsigned int s,
419 F alpha, F beta, Ccache_t &Ccache);
423 void dfs(vector<FX> &res,
436 vector<FX> rr_findroots(
const FXY &P,
int degreebound);
458 bool cmp (
const GF2EX& a,
const GF2EX& b);
459 bool cmp (
const ZZ_pX& a,
const ZZ_pX& b);
462 #include "rsdecoder_impl.h"
vector< map< dbsize_t, F > > recovered
Recovered words by word index.
Definition: rsdecoder.h:97
Reed-Solomon Decoder.
Definition: rsdecoder.h:161
A struct containing a reconstructed polynomial over the field F.
Definition: rsdecoder.h:57
Contains the results (so far) of decoding words.
Definition: rsdecoder.h:87
vector< FX > phis
Reconstructed polynomials.
Definition: rsdecoder.h:81
bool Recover(dbsize_t bytes_per_word, nservers_t t, nservers_t h, const vector< nservers_t > &goodservers, const vector< vector< vec_F > > &values, const vec_F &server_indices, vector< vector< DecoderResult< F > > > &results, vector< std::set< dbsize_t > > &decoded, const vector< vec_F > &vec_interp_indices, const nqueries_t multi_only=0)
The main method to do the Reed-Solomon Decoding.
Definition: rsdecoder_impl.h:2823
vector< nservers_t > G
Server indices that agree.
Definition: rsdecoder.h:79
RecoveryPoly(vector< nservers_t > G, FX phi)
Constructor.
Definition: rsdecoder.h:61
FX phi
Reconstructed polynomial.
Definition: rsdecoder.h:66
DecoderResult(vector< nservers_t > G, vector< map< dbsize_t, F > > recovered)
Constructor.
Definition: rsdecoder.h:91
RSDecoder()
GF2E Constructor.
Definition: rsdecoder.h:166
static string append(const string &s, const F &wz, unsigned int bytes_per_word)
A helper function to append an element of F to a string.
RecoveryPolyMulti(vector< nservers_t > G, vector< FX > phis)
Constructor.
Definition: rsdecoder.h:76
vector< nservers_t > G
Server indices that agree.
Definition: rsdecoder.h:64
static void test_interpolate(unsigned short t, const vec_F &values, const vec_F &indices, const vector< unsigned short > &I, const vector< unsigned short > &G, unsigned short &numagree, unsigned short &numdisagree, vector< unsigned short > &vecagree, FX &phi)
Interpolate some points I and check how many points G agree with the result.
Definition: rsdecoder_impl.h:84
A struct containing a multiple reconstructed polynomials over the field F.
Definition: rsdecoder.h:72
RSDecoder(const ZZ &p1, const ZZ &p2)
ZZ_p Constructor.
Definition: rsdecoder.h:171
vector< nservers_t > G
Server indices that agree.
Definition: rsdecoder.h:95