diff options
| author | J08nY | 2023-09-29 22:15:06 +0200 |
|---|---|---|
| committer | J08nY | 2023-09-29 22:15:06 +0200 |
| commit | cad492f2718fbdc1c2f24876add693726494f0cc (patch) | |
| tree | 7d0f658da6c4a1bab0926d84d2e307e0f9f31c97 /pyecsca/codegen/builder.py | |
| parent | e773dfb631f925952203f8c040f72f8e5c3f8836 (diff) | |
| download | pyecsca-codegen-cad492f2718fbdc1c2f24876add693726494f0cc.tar.gz pyecsca-codegen-cad492f2718fbdc1c2f24876add693726494f0cc.tar.zst pyecsca-codegen-cad492f2718fbdc1c2f24876add693726494f0cc.zip | |
Add wNAF scalarmult, more options implemented for other scalarmults.
Diffstat (limited to 'pyecsca/codegen/builder.py')
| -rw-r--r-- | pyecsca/codegen/builder.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/pyecsca/codegen/builder.py b/pyecsca/codegen/builder.py index 2cd572b..d0ec648 100644 --- a/pyecsca/codegen/builder.py +++ b/pyecsca/codegen/builder.py @@ -13,7 +13,7 @@ from pyecsca.ec.configuration import (Multiplication, Squaring, Reduction, HashT from pyecsca.ec.coordinates import CoordinateModel from pyecsca.ec.formula import Formula, AdditionFormula from pyecsca.ec.model import CurveModel -from pyecsca.ec.mult import ScalarMultiplier +from pyecsca.ec.mult import ScalarMultiplier, AccumulationOrder, ProcessingDirection from .render import render from .common import Platform, DeviceConfiguration, MULTIPLIERS, wrap_enum, get_model, get_coords @@ -40,7 +40,7 @@ def get_multiplier(ctx: click.Context, param, value: Optional[str]) -> Optional[ if value is None: return None res = re.match( - "(?P<name>[a-zA-Z\-]+)\((?P<args>([a-zA-Z_]+ *= *[a-zA-Z0-9]+, ?)*?([a-zA-Z_]+ *= *[a-zA-Z0-9]+)*)\)", + "(?P<name>[a-zA-Z\-]+)\((?P<args>([a-zA-Z_]+ *= *[a-zA-Z0-9.]+, ?)*?([a-zA-Z_]+ *= *[a-zA-Z0-9.]+)*)\)", value) if not res: raise click.BadParameter("Couldn't parse multiplier spec: {}.".format(value)) @@ -61,7 +61,10 @@ def get_multiplier(ctx: click.Context, param, value: Optional[str]) -> Optional[ raise click.BadParameter( "Multiplier {} requires formulas: {}, got {}.".format(mult_class.__name__, mult_class.requires, classes)) - kwargs = eval("dict(" + args + ")") + globs = dict(globals()) + globs["AccumulationOrder"] = AccumulationOrder + globs["ProcessingDirection"] = ProcessingDirection + kwargs = eval("dict(" + args + ")", globs) required = set( filter(lambda formula: any(isinstance(formula, cls) for cls in mult_class.requires), formulas)) |
