w128_t calc_parity(dSFMT& dsfmt, const GF2X& irreducible) { AlgorithmCalculateParity<w128_t, dSFMT> cp; cp.searchParity(dsfmt, irreducible); return dsfmt.getParityValue(); }
/** * search parameters using all_in_one function in the file search_all.hpp * @param opt command line options * @param count number of parameters user requested * @return 0 if this ends normally */ int search(options& opt, int count) { MersenneTwister64 mt(opt.seed); dSFMT g(opt.mexp); cout << "seed = " << dec << opt.seed << endl; if (opt.verbose) { time_t t = time(NULL); cout << "search start at " << ctime(&t); } if (opt.fixed) { g.setFixed(true); g.setFixedSL1(opt.fixedSL1); } AlgorithmReducibleRecursionSearch<w128_t> ars(g, mt); int i = 0; AlgorithmCalculateParity<w128_t, dSFMT> cp; cout << "# " << g.getHeaderString() << ", delta52" << endl; while (i < count) { if (ars.start(opt.mexp * 100)) { GF2X irreducible = ars.getIrreducibleFactor(); GF2X characteristic = ars.getCharacteristicPolynomial(); //cout << "deg irreducible = " << dec << deg(irreducible) << endl; //cout << "deg characteristic = " << dec << deg(characteristic) // << endl; //cout << "deg quotient = " << dec << deg(quotient) << endl; if (deg(irreducible) != opt.mexp) { cout << "error" << endl; return -1; } getLCMPoly(characteristic, g); GF2X quotient = characteristic / irreducible; w128_t fixpoint = calc_fixpoint(g, irreducible, quotient); g.setFixPoint(fixpoint); cp.searchParity(g, irreducible); w128_t seed = {{1, 0, 0, 0}}; g.seed(seed); if (!anni(g)) { return -1; } annihilate<w128_t>(&g, quotient); int veq52[52]; DSFMTInfo info; info.bitSize = 128; info.elementNo = 2; int delta52 = calc_dSFMT_equidistribution<w128_t, dSFMT>(g, veq52, 52, info, opt.mexp); cout << g.getParamString(); cout << dec << delta52 << endl; i++; } else { cout << "search failed" << endl; break; } } if (opt.verbose) { time_t t = time(NULL); cout << "search end at " << ctime(&t) << endl; } return 0; }
/** * search parameters using all_in_one function in the file search_all.hpp * @param opt command line options * @param count number of parameters user requested * @return 0 if this ends normally */ int search(options& opt, int count) { MersenneTwister mt(opt.seed); sfmt g(opt.mexp); cout << "seed = " << dec << opt.seed << endl; if (opt.verbose) { time_t t = time(NULL); cout << "search start at " << ctime(&t); } AlgorithmReducibleRecursionSearch<w128_t, uint32_t> ars(g, mt); int i = 0; AlgorithmCalculateParity<w128_t, sfmt> cp; cout << "# " << g.getHeaderString() << ", delta32, delta64, delta128" << endl; while (i < count) { if (ars.start(opt.mexp * 100)) { GF2X irreducible = ars.getIrreducibleFactor(); GF2X characteristic = ars.getCharacteristicPolynomial(); GF2X quotient = characteristic / irreducible; //cout << "deg irreducible = " << dec << deg(irreducible) << endl; //cout << "deg characteristic = " << dec << deg(characteristic) // << endl; //cout << "deg quotient = " << dec << deg(quotient) << endl; if (deg(irreducible) != opt.mexp) { cout << "error" << endl; return -1; } cp.searchParity(g, irreducible); w128_t seed = {{1, 0, 0, 0}}; g.seed(seed); if (!anni(g)) { return -1; } //annihilate<w128_t>(&g, quotient); //AlgorithmReducibleEquidistribution<w128_t, sfmt, uint32_t> // re(g, irreducible, 128); AlgorithmEquidistribution<w128_t, uint32_t> re(g, 128, opt.mexp); int veq[128]; int delta128 = 0; int delta32 = 0; int delta64 = 0; delta128 = re.get_all_equidist(veq); int veq32[32]; SIMDInfo info; info.bitMode = 32; info.elementNo = 4; info.bitSize = 128; delta32 = calc_SIMD_equidistribution<w128_t, sfmt>(g, veq32, 32, info, opt.mexp); int veq64[64]; info.bitMode = 64; info.elementNo = 2; delta64 = calc_SIMD_equidistribution<w128_t, sfmt>(g, veq64, 64, info, opt.mexp); cout << g.getParamString(); cout << dec << delta32 << "," << delta64 << "," << delta128 << endl; #if 0 cout << "32bit veq" << endl; for (int j = 0; j < 32; j++) { cout << "k(" << dec << (j + 1) << ") = " << dec << veq32[j] << endl; } cout << "64bit veq" << endl; for (int j = 0; j < 64; j++) { cout << "k(" << dec << (j + 1) << ") = " << dec << veq64[j] << endl; } cout << "1282bit veq" << endl; for (int j = 0; j < 128; j++) { cout << "k(" << dec << (j + 1)<< ") = " << dec << veq[j] << endl; } #endif i++; } else { cout << "search failed" << endl; break; } } if (opt.verbose) { time_t t = time(NULL); cout << "search end at " << ctime(&t) << endl; } return 0; }
w128_t calc_parity(sfmt& sf, const GF2X& irreducible) { AlgorithmCalculateParity<w128_t, sfmt> cp; cp.searchParity(sf, irreducible); return sf.getParityValue(); }