diff options
| author | Andrej Bátora | 2023-10-05 20:18:51 +0200 |
|---|---|---|
| committer | Andrej Bátora | 2023-10-05 20:18:51 +0200 |
| commit | 509ffef3df7a98cc8cceccbb7d1ca3e8440ea4f5 (patch) | |
| tree | 7f6688e1dd94b90c9d3a1a1e47ba9285986a0d6b | |
| parent | 71bac00f26e745c929d318b607d1794568fc6514 (diff) | |
| download | pyecsca-509ffef3df7a98cc8cceccbb7d1ca3e8440ea4f5.tar.gz pyecsca-509ffef3df7a98cc8cceccbb7d1ca3e8440ea4f5.tar.zst pyecsca-509ffef3df7a98cc8cceccbb7d1ca3e8440ea4f5.zip | |
typing fixes
| -rw-r--r-- | pyecsca/sca/attack/CPA.py | 3 | ||||
| -rw-r--r-- | pyecsca/sca/target/emulator.py | 12 |
2 files changed, 8 insertions, 7 deletions
diff --git a/pyecsca/sca/attack/CPA.py b/pyecsca/sca/attack/CPA.py index 3ef57b0..e46181e 100644 --- a/pyecsca/sca/attack/CPA.py +++ b/pyecsca/sca/attack/CPA.py @@ -7,6 +7,7 @@ from pyecsca.sca.trace import Trace from public import public from scipy.stats import pearsonr from pyecsca.sca.attack.leakage_model import LeakageModel +from typing import Any import numpy as np from numpy.typing import NDArray @@ -45,7 +46,7 @@ class CPA(): result = ctx.actions.get_by_index([0, action_index])[0] return result.output_points[0].X - def compute_correlation_trace(self, guessed_scalar: int, target_bit: int) -> list[any]: + def compute_correlation_trace(self, guessed_scalar: int, target_bit: int) -> list[Any]: correlation_trace = [] intermediate_values = [] for i in range(len(self.points)): diff --git a/pyecsca/sca/target/emulator.py b/pyecsca/sca/target/emulator.py index 0f097e5..8d74bf6 100644 --- a/pyecsca/sca/target/emulator.py +++ b/pyecsca/sca/target/emulator.py @@ -2,16 +2,16 @@ from pyecsca.ec.coordinates import CoordinateModel from pyecsca.ec.mod import Mod from pyecsca.ec.model import CurveModel from pyecsca.ec.params import DomainParameters -from pyecsca.ec.point import Point, InfinityPoint +from pyecsca.ec.point import Point from pyecsca.ec.mult import ScalarMultiplier from pyecsca.ec.key_generation import KeyGeneration from pyecsca.ec.key_agreement import KeyAgreement from pyecsca.ec.signature import Signature, SignatureResult from pyecsca.ec.formula import FormulaAction -from pyecsca.ec.context import Context, DefaultContext, local +from pyecsca.ec.context import DefaultContext, local from pyecsca.sca.attack import LeakageModel -from pyecsca.sca.trace import Trace, average, subtract -from typing import Mapping, Union, Optional, Tuple +from pyecsca.sca.trace import Trace +from typing import Optional, Tuple from public import public from .base import Target import numpy as np @@ -23,7 +23,7 @@ class EmulatorTarget(Target): coords: CoordinateModel mult: ScalarMultiplier params: Optional[DomainParameters] - leakage_model: LeakageModel + leakage_model: Optional[LeakageModel] privkey: Optional[Mod] pubkey: Optional[Point] @@ -55,7 +55,7 @@ class EmulatorTarget(Target): traces.append(trace) return points, traces - def emulate_ecdh_traces(self, num_of_traces: int) -> Tuple[list[Trace], list[Trace]]: + def emulate_ecdh_traces(self, num_of_traces: int) -> Tuple[list[Point], list[Trace]]: other_pubs = [self.params.curve.affine_random().to_model(self.coords, self.params.curve) for _ in range(num_of_traces)] traces = [] for pub in other_pubs: |
