aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJ08nY2023-10-19 10:01:27 +0200
committerJ08nY2023-10-19 10:18:59 +0200
commitee85bee5fbb99a433efe7021290fd41c44c21d35 (patch)
tree48c6f5020db7c7b5763fd17d3010f169322b2410
parentebaacd6f35e1790e863d3c331c10ad6d1cdec9f6 (diff)
downloadpyecsca-notebook-ee85bee5fbb99a433efe7021290fd41c44c21d35.tar.gz
pyecsca-notebook-ee85bee5fbb99a433efe7021290fd41c44c21d35.tar.zst
pyecsca-notebook-ee85bee5fbb99a433efe7021290fd41c44c21d35.zip
Update configuration space notebook with new scalarmult options.
-rw-r--r--configuration_space.ipynb68
1 files changed, 59 insertions, 9 deletions
diff --git a/configuration_space.ipynb b/configuration_space.ipynb
index c4b8ab1..0fa72c0 100644
--- a/configuration_space.ipynb
+++ b/configuration_space.ipynb
@@ -54,7 +54,11 @@
"## Enumerating configurations\n",
"\n",
"The possible configurations can be generated using the `all_configurations()` function.\n",
- "The whole space of configurations is quite huge:"
+ "The whole space of configurations is quite huge.\n",
+ "\n",
+ "> Note that the amount of possible parametrizations of some scalar multipliers is very large (e.g. window size) so **pyecsca** has\n",
+ "> to resctrict this to a reasonable selection. Specifically the function below only considers a few options for window size and\n",
+ "> similar parameters."
]
},
{
@@ -65,7 +69,8 @@
"source": [
"from pyecsca.ec.configuration import all_configurations\n",
"\n",
- "print(sum(1 for _ in all_configurations()))"
+ "total = sum(1 for _ in all_configurations())\n",
+ "print(total)"
]
},
{
@@ -81,6 +86,22 @@
" - `red` of type `Reduction` $*3$\n",
" - `inv` of type `Inversion` $*2$\n",
"\n",
+ "Without these, the space is somewhat smaller:"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "print(total // (6*2*4*4*3*2))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
"To restrict the generated configurations, pass keyword arguments to the\n",
"`all_configurations` matching the names of the attributes of the `Configuration` object."
]
@@ -117,7 +138,11 @@
"metadata": {},
"source": [
"We see that when we fixed all parameters except for the scalar multiplier arguments \n",
- "(see the `LTRMultiplier` constructor) we obtained 560 configurations."
+ "(see the `LTRMultiplier` constructor) we obtained 1120 configurations. That number expresses all of the possible ways to use addition formulas for the `projective` coordinate system in the binary left-to-right multiplier as well as internal options of that multiplier:\n",
+ " - whether it is \"complete\" in a sense that it starts processing at a constant bit (the bit-length od the order)\n",
+ " - whether it is \"double-and-add-always\"\n",
+ " - whether it \"short-circuits\" the formulas, i.e. detects that an exceptional point was input into them and returns correctly\n",
+ " without executing them."
]
},
{
@@ -128,6 +153,13 @@
]
},
{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "We can explore the number of configurations for each of the supported curve models."
+ ]
+ },
+ {
"cell_type": "code",
"execution_count": null,
"metadata": {},
@@ -136,6 +168,7 @@
"from IPython.display import HTML, display\n",
"import tabulate\n",
"from pyecsca.ec.model import *\n",
+ "from pyecsca.ec.mult import ProcessingDirection, AccumulationOrder\n",
"\n",
"model_counts = [[\"Model\", \"All\", \"Without independent options\", \"Without independent options and scaling\", \"Without independent options and scalarmult options\"]]\n",
"totals = [\"Total\", 0, 0, 0, 0]\n",
@@ -143,7 +176,7 @@
"\tname = model.__class__.__name__\n",
"\tcount = sum(1 for _ in all_configurations(model=model, **independent_opts))\n",
"\tcount_no_scl = sum(1 for _ in all_configurations(model=model, **independent_opts, scalarmult={\"scl\": None}))\n",
- "\tcount_no_opts = sum(1 for _ in all_configurations(model=model, **independent_opts, scalarmult={\"scl\": None, \"always\": True, \"short_circuit\": True, \"complete\": False, \"precompute_negation\": True, \"width\": 3}))\n",
+ "\tcount_no_opts = sum(1 for _ in all_configurations(model=model, **independent_opts, scalarmult={\"scl\": None, \"always\": True, \"short_circuit\": True, \"complete\": False, \"precompute_negation\": True, \"width\": 3, \"m\": 3, \"direction\": ProcessingDirection.LTR, \"accumulation_order\": AccumulationOrder.PeqPR, \"recoding_direction\": ProcessingDirection.LTR}))\n",
"\tmodel_counts.append([name, count * (6*2*4*4*3*2), count, count_no_scl, count_no_opts])\n",
"\ttotals[1] += count * (6*2*4*4*3*2)\n",
"\ttotals[2] += count\n",
@@ -161,6 +194,13 @@
]
},
{
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Let's now look at the configuration split for coordinate systems:"
+ ]
+ },
+ {
"cell_type": "code",
"execution_count": null,
"metadata": {},
@@ -174,7 +214,7 @@
"\t\tcoords_name = coords.name\n",
"\t\tcount = sum(1 for _ in all_configurations(model=model, coords=coords, **independent_opts))\n",
"\t\tcount_no_scl = sum(1 for _ in all_configurations(model=model, coords=coords, **independent_opts, scalarmult={\"scl\": None}))\n",
- "\t\tcount_no_opts = sum(1 for _ in all_configurations(model=model, coords=coords, **independent_opts, scalarmult={\"scl\": None, \"always\": True, \"short_circuit\": True, \"complete\": False, \"precompute_negation\": True, \"width\": 3}))\n",
+ "\t\tcount_no_opts = sum(1 for _ in all_configurations(model=model, coords=coords, **independent_opts, scalarmult={\"scl\": None, \"always\": True, \"short_circuit\": True, \"complete\": False, \"precompute_negation\": True, \"width\": 3, \"m\": 3, \"direction\": ProcessingDirection.LTR, \"accumulation_order\": AccumulationOrder.PeqPR, \"recoding_direction\": ProcessingDirection.LTR}))\n",
"\t\tcoords_counts.append([\"\", coords_name, count * (6*2*4*4*3*2), count, count_no_scl, count_no_opts])\n",
"display(HTML(tabulate.tabulate(coords_counts, tablefmt=\"html\", headers=\"firstrow\")))"
]
@@ -194,11 +234,21 @@
"source": [
"from pyecsca.ec.mult import ScalarMultiplier\n",
"\n",
+ "def leaf_subclasses(cls):\n",
+ " subs = cls.__subclasses__()\n",
+ " result = set()\n",
+ " for subclass in subs:\n",
+ " if subclass.__subclasses__():\n",
+ " result.update(leaf_subclasses(subclass))\n",
+ " else:\n",
+ " result.add(subclass)\n",
+ " return result\n",
+ "\n",
"mult_counts = [[\"ScalarMultiplier\", \"All\", \"Without independent options\", \"Without independent options and scaling\", \"Without independent options and scalarmult options\"]]\n",
- "for mult_cls in ScalarMultiplier.__subclasses__():\n",
+ "for mult_cls in leaf_subclasses(ScalarMultiplier):\n",
"\tcount = sum(1 for _ in all_configurations(**independent_opts, scalarmult=mult_cls))\n",
"\tcount_no_scl = sum(1 for _ in all_configurations(**independent_opts, scalarmult={\"cls\": mult_cls, \"scl\": None}))\n",
- "\tcount_no_opts = sum(1 for _ in all_configurations(**independent_opts, scalarmult={\"cls\": mult_cls, \"scl\": None, \"always\": True, \"short_circuit\": True, \"complete\": False, \"precompute_negation\": True, \"width\": 3}))\n",
+ "\tcount_no_opts = sum(1 for _ in all_configurations(**independent_opts, scalarmult={\"cls\": mult_cls, \"scl\": None, \"always\": True, \"short_circuit\": True, \"complete\": False, \"precompute_negation\": True, \"width\": 3, \"m\": 3, \"direction\": ProcessingDirection.LTR, \"accumulation_order\": AccumulationOrder.PeqPR, \"recoding_direction\": ProcessingDirection.LTR}))\n",
"\tmult_counts.append([mult_cls.__name__, count * (6*2*4*4*3*2), count, count_no_scl, count_no_opts])\n",
"display(HTML(tabulate.tabulate(mult_counts, tablefmt=\"html\", headers=\"firstrow\")))\n"
]
@@ -218,7 +268,7 @@
},
"hide_input": false,
"kernelspec": {
- "display_name": "Python 3",
+ "display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
@@ -232,7 +282,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.8.2"
+ "version": "3.11.5"
},
"latex_envs": {
"LaTeX_envs_menu_present": true,