aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJ08nY2024-04-08 15:26:40 +0200
committerJ08nY2024-04-08 15:26:40 +0200
commit8508c87dab0493ed081c00066ef00d60d2ac95a6 (patch)
treecc66a421986c6e6a3505288c3c2563ed9fb7a02c
parent94a1b1d2c1323860cd89f6432c44745026668448 (diff)
downloadpyecsca-notebook-8508c87dab0493ed081c00066ef00d60d2ac95a6.tar.gz
pyecsca-notebook-8508c87dab0493ed081c00066ef00d60d2ac95a6.tar.zst
pyecsca-notebook-8508c87dab0493ed081c00066ef00d60d2ac95a6.zip
Update EPA to new API (partially).
-rw-r--r--re/epa.ipynb30
1 files changed, 15 insertions, 15 deletions
diff --git a/re/epa.ipynb b/re/epa.ipynb
index 52e3d5e..4fd1289 100644
--- a/re/epa.ipynb
+++ b/re/epa.ipynb
@@ -34,15 +34,14 @@
"from pyecsca.ec.point import Point, InfinityPoint\n",
"from pyecsca.ec.error import NonInvertibleError\n",
"from pyecsca.ec.mult import LTRMultiplier, AccumulationOrder\n",
+ "from pyecsca.ec.context import local\n",
+ "from pyecsca.ec.error import UnsatisfiedAssumptionError\n",
"from pyecsca.ec.formula.base import *\n",
"from pyecsca.ec.formula.fake import FakeAdditionFormula, FakeDoublingFormula, FakePoint\n",
- "from pyecsca.sca.re.tree import build_distinguishing_tree, expand_tree\n",
+ "from pyecsca.ec.formula.unroll import unroll_formula_expr\n",
+ "from pyecsca.sca.re.tree import Map, Tree\n",
"from pyecsca.sca.re.rpa import MultipleContext\n",
- "from pyecsca.sca.re.zvp import unroll_formula_expr\n",
- "from pyecsca.ec.context import local\n",
- "from pyecsca.ec.error import UnsatisfiedAssumptionError\n",
- "from pyecsca.misc.utils import log, warn\n",
- "from pyecsca.misc.cfg import TemporaryConfig"
+ "from pyecsca.misc.utils import log, warn"
]
},
{
@@ -255,10 +254,10 @@
"dbls = list(filter(lambda formula: formula.name.startswith(\"dbl\"), coords.formulas.values()))\n",
"formula_pairs = list(product(adds, dbls))\n",
"\n",
- "#fake_add = FakeAdditionFormula(params.curve.coordinate_model)\n",
- "#fake_dbl = FakeDoublingFormula(params.curve.coordinate_model)\n",
- "#fake_mult = LTRMultiplier(fake_add, fake_dbl, None, False, AccumulationOrder.PeqPR, True, True)\n",
- "#fake_mult.init(params, FakePoint(params.curve.coordinate_model))"
+ "fake_add = FakeAdditionFormula(params.curve.coordinate_model)\n",
+ "fake_dbl = FakeDoublingFormula(params.curve.coordinate_model)\n",
+ "fake_mult = LTRMultiplier(fake_add, fake_dbl, None, False, AccumulationOrder.PeqPR, True, True)\n",
+ "fake_mult.init(params, FakePoint(params.curve.coordinate_model))"
]
},
{
@@ -448,20 +447,21 @@
" \"\"\"\n",
" Distinguish the coordinate system and formulas using EPA given the precomputation.\n",
" \"\"\"\n",
- " tree = build_distinguishing_tree(precomp)\n",
+ " dmap = Map.from_sets(configs, precomp)\n",
+ " tree = Tree.build(configs, dmap)\n",
" log(\"Built distinguishing tree.\")\n",
- " log(RenderTree(tree).by_attr(lambda n: n.name if n.name is not None else n.cfgs))\n",
+ " log(tree.render())\n",
"\n",
- " current_node = tree\n",
+ " current_node = tree.root\n",
" cfgs = list(precomp.keys())\n",
" while current_node.children:\n",
- " best_distinguishing_index = current_node.name\n",
+ " best_distinguishing_index = current_node.dmap_input\n",
" scalar, point = inputs[best_distinguishing_index]\n",
" response = oracle(affine_params, point, scalar)\n",
" log(f\"Oracle response -> {response}\")\n",
" for cfg in cfgs:\n",
" log(cfg, best_distinguishing_index in precomp[cfg])\n",
- " response_map = {child.oracle_response: child for child in current_node.children}\n",
+ " response_map = {child.response: child for child in current_node.children}\n",
" current_node = response_map[response]\n",
" cfgs = current_node.cfgs\n",
" log(cfgs)\n",