bkz.bkz_schnorr_euchner_progress_check
bkz_se_pc(basis_matrix, block_size, enum_algo)
Executes the BKZ reduction algorithm as presented in
Lattice Basis Reduction: Improved Practical Algorithms and Solving Subset Sum Problems
by C. P. Schnorr, M. Euchner (1994), with an additional progress tracking mechanism
to monitor Gram-Schmidt vector lengths and prevent rare infinite loop scenarios. In high dimensions,
rare cases can occur where the algorithm repeatedly injects a short vector x
into the basis, only for lll_deep_insert to remove it immediately afterward. This creates a false
sense of improvement in basis quality, causing the algorithm to run indefinitely. The implemented
tracking mechanism detects and mitigates this behavior.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
basis_matrix
|
ndarray
|
A 2D NumPy array of shape (n, n) representing a lattice basis, where each column is a basis vector. |
required |
block_size
|
int
|
The BKZ block size, determining the width of the local enumeration window. Larger values improve reduction quality but increase runtime. |
required |
enum_algo
|
string
|
A string key selecting the enumeration algorithm variant from |
required |
Notes
- Our implementation uses 0-based indices (
0,...,n-1) for basis and block boundaries, whereas the original Schnorr–Euchner paper uses 1-based indices (1,...,n).
Returns:
| Type | Description |
|---|---|
tuple
|
|
Source code in bkz/bkz_schnorr_euchner_progress_check.py
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 | |
structural_changes(gs_norms_before, gs_norms_after, block_size)
Detect whether a processed block experienced a material structural change
in its Gram–Schmidt squared norms. The check compares gs_norms_before and gs_norms_after using np.allclose
with a dimension-aware absolute tolerance: atol = max(max(gs_norms_before), max(gs_norms_after), 1.0) * (block_size * 1e-12)
and zero relative tolerance rtol = 0. This normalization scales the tolerance
to the magnitude of the block’s GS norms and the block size, making the check
robust across dimensions and numeric ranges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gs_norms_before
|
ndarray
|
1D array of GS squared norms for the block before the candidate injection and deep insertion; shape (block_size,). |
required |
gs_norms_after
|
ndarray
|
1D array of GS squared norms for the block after deep insertion; shape (block_size,). |
required |
block_size
|
int
|
The BKZ block size. Used to scale the absolute tolerance. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in bkz/bkz_schnorr_euchner_progress_check.py
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 | |