aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJ08nY2024-01-23 21:21:18 +0100
committerJ08nY2024-01-23 21:21:18 +0100
commit304561e9542fe7bfb91abb3e8e8c6d1a1a1f3781 (patch)
tree154b3bfc0879229ff16dac0de0e6f42d53b4af26
parentf195c8b8b79029281907575567d3ef093cd0bb22 (diff)
downloadpyecsca-304561e9542fe7bfb91abb3e8e8c6d1a1a1f3781.tar.gz
pyecsca-304561e9542fe7bfb91abb3e8e8c6d1a1a1f3781.tar.zst
pyecsca-304561e9542fe7bfb91abb3e8e8c6d1a1a1f3781.zip
Ditch unused method.
-rw-r--r--pyecsca/sca/re/zvp.py61
1 files changed, 0 insertions, 61 deletions
diff --git a/pyecsca/sca/re/zvp.py b/pyecsca/sca/re/zvp.py
index 527c6ea..f1c5f3d 100644
--- a/pyecsca/sca/re/zvp.py
+++ b/pyecsca/sca/re/zvp.py
@@ -637,64 +637,3 @@ def addition_chain(
ks = tuple(mctx.points[parent] for parent in parents)
chain.append((formula_type, ks))
return chain
-
-
-def precomp_zvp_points(
- chain: List[Tuple[str, Tuple[int, ...]]],
- formulas: Mapping[str, Formula],
- params: DomainParameters,
- bound: int = 25,
- filter_nonhomo: bool = True
-) -> List[Mapping[Poly, Set[Point]]]:
- """
- Precompute ZVP points for a given addition chain using given formula mapping.
-
- :param chain: The addition chain.
- :param formulas: Mapping of formula shortnames (e.g. "add") to formulas
- :param params: The domain parameters to compute on.
- :param bound: The bound for hard DCP cases.
- :param filter_nonhomo: Whether to filter non-homogenous intermediate polynomials (will lead to false positives if False).
- :return: A list with an entry for each formula application in the chain. Each entry is a mapping of intermediate polynomial to set of points.
- """
- factor_sets = {
- formula: compute_factor_set(formula, filter_nonhomo=filter_nonhomo) for formula in formulas.values()
- }
- # A bit of a hack to rename the poly variables for double as zvp_points expects that.
- # TODO: Handle this better in the zvp_points function (to also be able to handle ladders and other stuff).
- for formula in formulas.values():
- if isinstance(formula, DoublingFormula):
- fset = factor_sets[formula]
- new_fset = set()
- for poly in fset:
- pl = poly.copy()
- for symbol in poly.free_symbols:
- original = str(symbol)
- if original.endswith("1"):
- new = original.replace("1", "2")
- pl = pl.subs(original, new)
- new_fset.add(pl)
- factor_sets[formula] = new_fset
- result: List[Mapping[Poly, Set[Point]]] = []
- for op, ks in chain:
- if op not in formulas:
- continue
- formula = formulas[op]
- factor_set = factor_sets[formula]
- if len(ks) == 1:
- k = ks[0]
- else:
- # zvp_points assumes (P, [k]P)
- ks_mod = list(map(lambda v: Mod(v, params.order), ks))
- k = int(ks_mod[1] / ks_mod[0])
- points = {}
-
- for poly in factor_set:
- only_1 = all((not str(gen).endswith("2")) for gen in poly.gens) # type: ignore[attr-defined]
- only_2 = all((not str(gen).endswith("1")) for gen in poly.gens) # type: ignore[attr-defined]
- # This is the hard case where a dlog needs to be substituted, so bound it.
- if not (only_1 or only_2) and k > bound:
- continue
-
- points[poly] = zvp_points(poly, params.curve, k, params.order)
- result.append(points)
- return result