From c399a0373a111bd88ccd423f65b701a8e209f559 Mon Sep 17 00:00:00 2001 From: J08nY Date: Tue, 4 Jun 2024 16:58:26 +0200 Subject: Fix new tree API use. --- CPA.ipynb | 9 ++++----- DPA.ipynb | 9 ++++----- re/epa.ipynb | 2 +- re/structural.ipynb | 6 +++--- simulation.ipynb | 30 +++++++++++++++++++----------- 5 files changed, 31 insertions(+), 25 deletions(-) diff --git a/CPA.ipynb b/CPA.ipynb index 6275613..019c672 100644 --- a/CPA.ipynb +++ b/CPA.ipynb @@ -457,7 +457,7 @@ ], "metadata": { "kernelspec": { - "display_name": "venv", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -471,10 +471,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.18" - }, - "orig_nbformat": 4 + "version": "3.11.8" + } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/DPA.ipynb b/DPA.ipynb index ee6e44d..e11dc47 100644 --- a/DPA.ipynb +++ b/DPA.ipynb @@ -588,7 +588,7 @@ ], "metadata": { "kernelspec": { - "display_name": "venv", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -602,10 +602,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.18" - }, - "orig_nbformat": 4 + "version": "3.11.8" + } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/re/epa.ipynb b/re/epa.ipynb index 654e7ad..3e50deb 100644 --- a/re/epa.ipynb +++ b/re/epa.ipynb @@ -570,7 +570,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.4" + "version": "3.11.8" } }, "nbformat": 4, diff --git a/re/structural.ipynb b/re/structural.ipynb index 6c9cc86..1006b62 100644 --- a/re/structural.ipynb +++ b/re/structural.ipynb @@ -155,7 +155,7 @@ " if isinstance(action, FormulaAction) and action.formula == formula:\n", " actions.append(action)\n", "\n", - " ctx.actions.walk(callback)\n", + " ctx.actions[0].walk(callback)\n", " return len(actions)\n", "\n", "def simulate_trace(ctx):\n", @@ -169,7 +169,7 @@ " trace.append(leak)\n", " trace.extend([0] * 20)\n", "\n", - " ctx.actions.walk(callback)\n", + " ctx.actions[0].walk(callback)\n", " return Trace(np.array(trace))\n", "\n", "traces = []\n", @@ -309,7 +309,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.11.8" } }, "nbformat": 4, diff --git a/simulation.ipynb b/simulation.ipynb index 078f0d7..97db137 100644 --- a/simulation.ipynb +++ b/simulation.ipynb @@ -6,7 +6,7 @@ "source": [ "# Simulation\n", "\n", - "**pyecsca** is able to simulate computation of key generation, ECDH and ECDSA while tracing particular actions performed by the implementation as well as intermediate values. These traces are collected by the context (see the `Context` and `DefaultContext` classes). There is always one context active. For performance reasons, by default it is a `NullContext` instance, which does not trace anything.\n", + "**pyecsca** is able to simulate computation of key generation, ECDH and ECDSA while tracing particular actions performed by the implementation as well as intermediate values. These traces are collected by the context (see the `Context` and `DefaultContext` classes). There is always one context active. For performance reasons, by default no context is active.\n", "\n", "These traces are useful for attacks which rely on computing particular intermediate values during the ECC computation." ] @@ -171,13 +171,14 @@ "metadata": {}, "outputs": [], "source": [ - "tree = ecdh_ctx.actions\n", + "first_ecdh = ecdh_ctx.actions[0]\n", + "second_ecdh = ecdh_ctx.actions[1]\n", "\n", - "ecdh_action, subtree = tree.get_by_index([0])\n", - "\n", - "scalarmult_action, subtree = subtree.get_by_index([0])\n", + "ecdh = first_ecdh.get_by_index([])\n", + "scalarmult = first_ecdh.get_by_index([0])\n", "recovered_private = 1\n", - "for formula_call in subtree:\n", + "for formula_node in scalarmult.children:\n", + " formula_call = formula_node.action\n", " if formula_call.formula.shortname == \"add\":\n", " recovered_private |= 1\n", " elif formula_call.formula.shortname == \"dbl\":\n", @@ -202,16 +203,23 @@ "metadata": {}, "outputs": [], "source": [ - "action, subtree = tree.get_by_index([1, 0, 1])\n", - "print(repr(action))" + "node = first_ecdh.get_by_index([0, 1])\n", + "print(repr(node.action))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "The `[1,0,1]` path given above represented a walk through the execution trace, taking the second child of the root, then the first child then the second again." + "The `[0,1]` path given above represented a walk through the execution trace, taking the first child (a scalar multiplication) and then a second child (a second formula application)." ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -221,7 +229,7 @@ }, "hide_input": false, "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -235,7 +243,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.1" + "version": "3.11.8" }, "latex_envs": { "LaTeX_envs_menu_present": true, -- cgit v1.3.1