/usr/include/fplll/bkz.h is in libfplll-dev 5.0.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | /* Copyright (C) 2011 Xavier Pujol
(C) 2014-2016 Martin R. Albrecht
(C) 2016 Michael Walter
This file is part of fplll. fplll is free software: you
can redistribute it and/or modify it under the terms of the GNU Lesser
General Public License as published by the Free Software Foundation,
either version 2.1 of the License, or (at your option) any later version.
fplll is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with fplll. If not, see <http://www.gnu.org/licenses/>. */
#ifndef FPLLL_BKZ_H
#define FPLLL_BKZ_H
#include "bkz_param.h"
#include "enum/evaluator.h"
#include "enum/enumerate.h"
#include "lll.h"
FPLLL_BEGIN_NAMESPACE
template <class FT> class BKZAutoAbort
{
public:
/**
@brief
@param m
@param num_rows
@param start_row
@return
*/
BKZAutoAbort(MatGSO<Integer, FT> &m, int num_rows, int start_row = 0)
: m(m), old_slope(numeric_limits<double>::max()), no_dec(-1), num_rows(num_rows),
start_row(start_row)
{
}
bool test_abort(double scale = 1.0, int maxNoDec = 5);
private:
MatGSO<Integer, FT> &m;
double old_slope;
int no_dec;
int num_rows;
int start_row;
};
/* The matrix must be LLL-reduced */
template <class FT> class BKZReduction
{
public:
BKZReduction(MatGSO<Integer, FT> &m, LLLReduction<Integer, FT> &lll_obj, const BKZParam ¶m);
~BKZReduction();
bool svp_preprocessing(int kappa, int block_size, const BKZParam ¶m);
bool svp_postprocessing(int kappa, int block_size, const vector<FT> &solution);
bool dsvp_postprocessing(int kappa, int block_size, const vector<FT> &solution);
/**
Run enumeration to find a new shortest vector in the sublattice B[kappa,kappa+block_size]
@param kappa Start row
@param block_size Block size to use, this may be < param.block_size
@param param Parameters to use for this enumeration (block_size is ignored)
``_ex`` variant is exception handling.
*/
bool svp_reduction(int kappa, int block_size, const BKZParam ¶m, bool dual = false);
bool svp_reduction_ex(int kappa, int block_size, const BKZParam ¶m, bool &clean, bool dual = false)
{
try
{
clean = svp_reduction(kappa, block_size, param, dual);
return true;
}
catch (RedStatus &e)
{
return set_status(e);
}
}
bool tour(const int loop, int &kappa_max, const BKZParam ¶m, int min_row, int max_row);
bool tour_ex(const int loop, int &kappa_max, const BKZParam ¶m, int min_row, int max_row,
bool &clean)
{
try
{
clean = tour(loop, kappa_max, param, min_row, max_row);
return true;
}
catch (RedStatus &e)
{
return set_status(e);
}
}
bool sd_tour(const int loop, const BKZParam ¶m, int min_row, int max_row);
bool sd_tour_ex(const int loop, const BKZParam ¶m, int min_row, int max_row,
bool &clean)
{
try
{
clean = sd_tour(loop, param, min_row, max_row);
return true;
}
catch (RedStatus &e)
{
return set_status(e);
}
}
bool hkz(int &kappa_max, const BKZParam ¶m, int min_row, int max_row);
bool hkz_ex(int &kappa_max, const BKZParam ¶m, int min_row, int max_row, bool &clean)
{
try
{
clean = hkz(kappa_max, param, min_row, max_row);
return true;
}
catch (RedStatus &e)
{
return set_status(e);
}
}
bool slide_tour(const int loop, const BKZParam ¶m, int min_row, int max_row);
bool slide_tour_ex(const int loop, const BKZParam ¶m, int min_row, int max_row, bool &clean)
{
try
{
clean = slide_tour(loop, param, min_row, max_row);
return true;
}
catch (RedStatus &e)
{
return set_status(e);
}
}
bool bkz();
/** Randomize basis between from ``min_row`` and ``max_row`` (exclusive)
1. permute rows
2. apply lower triangular matrix with coefficients in -1,0,1
3. LLL reduce result
@param min_row start in this row
@param max_row stop at this row (exclusive)
@param density number of non-zero coefficients in lower triangular
transformation matrix
**/
void rerandomize_block(int min_row, int max_row, int density);
/** I/O **/
void dump_gso(const std::string& filename, const std::string& prefix, bool append = true);
int status;
/**
Number of nodes visited during enumeration.
*/
long nodes;
private:
void print_tour(const int loop, int min_row, int max_row);
void print_params(const BKZParam ¶m, ostream &out);
bool set_status(int new_status);
const Pruning &get_pruning(int kappa, int block_size, const BKZParam &par) const;
bool trunc_tour(int &kappa_max, const BKZParam ¶m, int min_row, int max_row);
bool trunc_dtour(const BKZParam ¶m, int min_row, int max_row);
const BKZParam ¶m;
int num_rows;
MatGSO<Integer, FT> &m;
LLLReduction<Integer, FT> &lll_obj;
FastEvaluator<FT> evaluator;
FT delta;
const char* algorithm;
// Temporary data
const vector<FT> empty_target, empty_sub_tree;
FT max_dist, delta_max_dist;
double cputime_start;
FT sld_potential;
};
int bkz_reduction(IntMatrix* B, IntMatrix* U, const BKZParam& param, FloatType float_type=FT_DEFAULT, int precision=0);
int bkz_reduction(IntMatrix& b, int block_size, int flags = BKZ_DEFAULT, FloatType float_type=FT_DEFAULT, int precision=0);
int bkz_reduction(IntMatrix& b, IntMatrix& u, int block_size, int flags = BKZ_DEFAULT, FloatType float_type=FT_DEFAULT, int precision=0);
int hkz_reduction(IntMatrix& b, int flags = HKZ_DEFAULT, FloatType float_type=FT_DEFAULT, int precision=0);
FPLLL_END_NAMESPACE
#endif
|