diff options
| -rw-r--r-- | pyecsca/ec/context.py | 4 | ||||
| -rw-r--r-- | pyecsca/ec/curve.py | 14 | ||||
| -rw-r--r-- | pyecsca/ec/formula/base.py | 2 | ||||
| -rw-r--r-- | pyecsca/ec/formula/fliparoo.py | 21 | ||||
| -rw-r--r-- | pyecsca/ec/formula/graph.py | 18 | ||||
| -rw-r--r-- | pyecsca/ec/formula/partitions.py | 3 | ||||
| -rw-r--r-- | pyecsca/ec/formula/switch_sign.py | 7 | ||||
| -rw-r--r-- | pyecsca/ec/model.py | 2 | ||||
| -rw-r--r-- | pyecsca/ec/op.py | 5 | ||||
| -rw-r--r-- | pyecsca/ec/params.py | 4 | ||||
| -rw-r--r-- | pyecsca/ec/point.py | 2 | ||||
| -rw-r--r-- | pyecsca/sca/re/rpa.py | 2 | ||||
| -rw-r--r-- | pyecsca/sca/re/tree.py | 2 | ||||
| -rw-r--r-- | pyecsca/sca/re/zvp.py | 8 | ||||
| -rw-r--r-- | pyecsca/sca/scope/picoscope_sdk.py | 10 | ||||
| -rw-r--r-- | pyecsca/sca/trace_set/hdf5.py | 2 | ||||
| -rw-r--r-- | pyecsca/sca/trace_set/pickle.py | 6 | ||||
| -rw-r--r-- | pyproject.toml | 2 | ||||
| -rw-r--r-- | test/ec/test_divpoly.py | 8 | ||||
| -rw-r--r-- | test/ec/test_formula.py | 2 | ||||
| -rw-r--r-- | test/ec/test_params.py | 2 | ||||
| -rw-r--r-- | test/sca/test_plot.py | 1 | ||||
| -rw-r--r-- | test/sca/test_rpa.py | 12 | ||||
| -rw-r--r-- | test/sca/test_target.py | 6 |
24 files changed, 83 insertions, 62 deletions
diff --git a/pyecsca/ec/context.py b/pyecsca/ec/context.py index 3735c26..7167e32 100644 --- a/pyecsca/ec/context.py +++ b/pyecsca/ec/context.py @@ -248,13 +248,13 @@ class _ContextManager: self.new_context = deepcopy(new_context) def __enter__(self) -> Optional[Context]: - global current + global current # This is OK, skipcq: PYL-W0603 self.old_context = current current = self.new_context return current def __exit__(self, t, v, tb): - global current + global current # This is OK, skipcq: PYL-W0603 current = self.old_context diff --git a/pyecsca/ec/curve.py b/pyecsca/ec/curve.py index 6762724..80bf9ab 100644 --- a/pyecsca/ec/curve.py +++ b/pyecsca/ec/curve.py @@ -71,7 +71,7 @@ class EllipticCurve: try: alocals: Dict[str, Union[Mod, int]] = {} compiled = compile(assumption, "", mode="exec") - exec(compiled, None, alocals) + exec(compiled, None, alocals) # exec is OK here, skipcq: PYL-W0122 for param, value in alocals.items(): if self.parameters[param] != value: raise_unsatisified_assumption( @@ -108,7 +108,7 @@ class EllipticCurve: } locls.update(self.parameters) for line in formulas: - exec(compile(line, "", mode="exec"), None, locls) + exec(compile(line, "", mode="exec"), None, locls) # exec is OK here, skipcq: PYL-W0122 if not isinstance(locls["x"], Mod): locls["x"] = Mod(locls["x"], self.prime) if not isinstance(locls["y"], Mod): @@ -195,7 +195,7 @@ class EllipticCurve: return None locls = {**self.parameters} for line in self.model.base_neutral: - exec(compile(line, "", mode="exec"), None, locls) + exec(compile(line, "", mode="exec"), None, locls) # exec is OK here, skipcq: PYL-W0122 if not isinstance(locls["x"], Mod): locls["x"] = Mod(locls["x"], self.prime) if not isinstance(locls["y"], Mod): @@ -231,7 +231,7 @@ class EllipticCurve: loc = {**self.parameters, **point.coords} else: loc = {**self.parameters, **point.to_affine().coords} - return eval(compile(self.model.equation, "", mode="eval"), loc) + return eval(compile(self.model.equation, "", mode="eval"), loc) # eval is OK here, skipcq: PYL-W0123 def to_coords(self, coordinate_model: CoordinateModel) -> "EllipticCurve": """ @@ -287,7 +287,7 @@ class EllipticCurve: raise ValueError("Encoded point has bad length") x = Mod(int.from_bytes(data, "big"), self.prime) loc = {**self.parameters, "x": x} - rhs = eval(compile(self.model.ysquared, "", mode="eval"), loc) + rhs = eval(compile(self.model.ysquared, "", mode="eval"), loc) # eval is OK here, skipcq: PYL-W0123 if not rhs.is_residue(): raise ValueError("Point not on curve") sqrt = rhs.sqrt() @@ -312,7 +312,7 @@ class EllipticCurve: :return: Lifted (affine) points, if any. """ loc = {**self.parameters, "x": x} - ysquared = eval(compile(self.model.ysquared, "", mode="eval"), loc) + ysquared = eval(compile(self.model.ysquared, "", mode="eval"), loc) # eval is OK here, skipcq: PYL-W0123 if not ysquared.is_residue(): return set() y = ysquared.sqrt() @@ -324,7 +324,7 @@ class EllipticCurve: while True: x = Mod.random(self.prime) loc = {**self.parameters, "x": x} - ysquared = eval(compile(self.model.ysquared, "", mode="eval"), loc) + ysquared = eval(compile(self.model.ysquared, "", mode="eval"), loc) # eval is OK here, skipcq: PYL-W0123 if ysquared.is_residue(): y = ysquared.sqrt() b = Mod.random(2) diff --git a/pyecsca/ec/formula/base.py b/pyecsca/ec/formula/base.py index d9dcbcf..d0a3014 100644 --- a/pyecsca/ec/formula/base.py +++ b/pyecsca/ec/formula/base.py @@ -169,7 +169,7 @@ class Formula(ABC): # Handle an assumption check on value of input points. alocals: Dict[str, Union[Mod, int]] = {**params} compiled = compile(assumption, "", mode="eval") - holds = eval(compiled, None, alocals) + holds = eval(compiled, None, alocals) # eval is OK here, skipcq: PYL-W0123 if not holds: # The assumption doesn't hold, see what is the current configured action and do it. raise_unsatisified_assumption( diff --git a/pyecsca/ec/formula/fliparoo.py b/pyecsca/ec/formula/fliparoo.py index 4af0f18..7338b24 100644 --- a/pyecsca/ec/formula/fliparoo.py +++ b/pyecsca/ec/formula/fliparoo.py @@ -59,6 +59,9 @@ class Fliparoo: def __eq__(self, other): return self.graph == other.graph and self.nodes == other.nodes + # unhashable at the moment + __hash__ = None # type: ignore + def deepcopy(self): ngraph = self.graph.deepcopy() nchain = [mirror_node(node, self.graph, ngraph) for node in self.nodes] @@ -79,7 +82,7 @@ class Fliparoo: class MulFliparoo(Fliparoo): def __init__(self, chain: List[CodeOpNode], graph: FormulaGraph): super().__init__(chain, graph) - operations = set(node.op.operator for node in self.nodes) + operations = {node.op.operator for node in self.nodes} if len(operations) != 1 or list(operations)[0] != OpType.Mult: raise BadFliparoo self.operator = OpType.Mult @@ -88,7 +91,7 @@ class MulFliparoo(Fliparoo): class AddSubFliparoo(Fliparoo): def __init__(self, chain: List[CodeOpNode], graph: FormulaGraph): super().__init__(chain, graph) - operations = set(node.op.operator for node in self.nodes) + operations = {node.op.operator for node in self.nodes} if not operations.issubset([OpType.Add, OpType.Sub]): raise BadFliparoo @@ -96,7 +99,7 @@ class AddSubFliparoo(Fliparoo): class AddFliparoo(Fliparoo): def __init__(self, chain: List[CodeOpNode], graph: FormulaGraph): super().__init__(chain, graph) - operations = set(node.op.operator for node in self.nodes) + operations = {node.op.operator for node in self.nodes} if len(operations) != 1 or list(operations)[0] != OpType.Add: raise BadFliparoo self.operator = OpType.Add @@ -226,11 +229,13 @@ class DummyNode(Node): def __repr__(self): return "Dummy node" + @property def label(self): - pass + return None + @property def result(self): - pass + return None def generate_fliparood_formulas( @@ -263,7 +268,8 @@ def generate_fliparood_graphs(fliparoo: Fliparoo) -> Iterator[FormulaGraph]: for signed_subgraph in signed_subgraphs: graph = signed_subgraph.supergraph - assert signed_subgraph.components == 1 + if signed_subgraph.components != 1: + raise ValueError final_signed_node = signed_subgraph.nodes[0] if final_signed_node.sign != 1: continue @@ -306,7 +312,8 @@ def reconnect_fliparoo_outputs(graph: FormulaGraph, last_node: Node): dummy = next(filter(lambda x: isinstance(x, DummyNode), graph.nodes)) dummy.reconnect_outgoing_nodes(last_node) graph.remove_node(dummy) - assert not list(filter(lambda x: isinstance(x, DummyNode), graph.nodes)) + if any(map(lambda x: isinstance(x, DummyNode), graph.nodes)): + raise ValueError def combine_all_pairs_signed_nodes( diff --git a/pyecsca/ec/formula/graph.py b/pyecsca/ec/formula/graph.py index c335635..59b51dd 100644 --- a/pyecsca/ec/formula/graph.py +++ b/pyecsca/ec/formula/graph.py @@ -100,7 +100,7 @@ class CodeOpNode(Node): def __init__(self, op: CodeOp): super().__init__() self.op = op - assert self.op.operator in [ + if self.op.operator not in [ OpType.Sub, OpType.Add, OpType.Id, @@ -110,7 +110,8 @@ class CodeOpNode(Node): OpType.Pow, OpType.Inv, OpType.Neg, - ], self.op.operator + ]: + raise ValueError @classmethod def from_str(cls, result: str, left, operator, right): @@ -226,10 +227,7 @@ class FormulaGraph: if side is None: continue if isinstance(side, int): - if side in constants: - parent_node = constants[side] - else: - parent_node = ConstantNode(side) + parent_node = constants.get(side, ConstantNode(side)) self.nodes.append(parent_node) self.roots.append(parent_node) else: @@ -266,7 +264,13 @@ class FormulaGraph: assumptions = [deepcopy(assumption) for assumption in self.assumptions] for klass in CodeFormula.__subclasses__(): if klass.shortname == self.shortname: - return klass(self.name if name is None else self.name + "-" + name, code, self.coordinate_model, parameters, assumptions) + return klass( + self.name if name is None else self.name + "-" + name, + code, + self.coordinate_model, + parameters, + assumptions, + ) raise ValueError(f"Bad formula type: {self.shortname}") def networkx_graph(self) -> nx.DiGraph: diff --git a/pyecsca/ec/formula/partitions.py b/pyecsca/ec/formula/partitions.py index d31519f..4f44631 100644 --- a/pyecsca/ec/formula/partitions.py +++ b/pyecsca/ec/formula/partitions.py @@ -256,6 +256,9 @@ class Partition: lo, ro = other.parts return (l == lo and r == ro) or (l == ro and r == lo) + # unhashable at the moment + __hash__ = None # type: ignore + def compute_partitions(n: int) -> List[Partition]: partitions = [Partition(n)] diff --git a/pyecsca/ec/formula/switch_sign.py b/pyecsca/ec/formula/switch_sign.py index f8f5f17..b0efb56 100644 --- a/pyecsca/ec/formula/switch_sign.py +++ b/pyecsca/ec/formula/switch_sign.py @@ -26,7 +26,7 @@ def subnode_lists(graph: FormulaGraph): def switch_sign(graph: FormulaGraph, node_combination) -> FormulaGraph: nodes_i = [graph.node_index(node) for node in node_combination] graph = graph.deepcopy() - node_combination = set(graph.nodes[node_i] for node_i in nodes_i) + node_combination = {graph.nodes[node_i] for node_i in nodes_i} output_signs = {out: 1 for out in graph.output_names} queue = [] @@ -67,7 +67,7 @@ def sign_test(output_signs: Dict[str, int], coordinate_model: Any): if scale is None: raise BadSignSwitch apoint = scale(p, point)[0] - if set(apoint.coords.values()) != set([Mod(1, p)]): + if set(apoint.coords.values()) != {Mod(1, p)}: raise BadSignSwitch @@ -107,7 +107,8 @@ def switch_sign_propagate( return [] if node.output_node: output_signs[node.result] *= -1 - assert node.is_mul or node.is_pow or node.is_inv or node.is_div + if not (node.is_mul or node.is_pow or node.is_inv or node.is_div): + raise ValueError return [(child, node.result) for child in node.outgoing_nodes] diff --git a/pyecsca/ec/model.py b/pyecsca/ec/model.py index ec51a43..df80e76 100644 --- a/pyecsca/ec/model.py +++ b/pyecsca/ec/model.py @@ -43,7 +43,7 @@ class EFDCurveModel(CurveModel): self.__load(efd_name) def __load(self, efd_name: str): - self.__class__._loaded = True + self.__class__._loaded = True # skipcq: PYL-W0212 self.__class__.coordinates = {} self.__class__.parameter_names = [] self.__class__.coordinate_names = [] diff --git a/pyecsca/ec/op.py b/pyecsca/ec/op.py index 0a87c81..5f57bfa 100644 --- a/pyecsca/ec/op.py +++ b/pyecsca/ec/op.py @@ -14,8 +14,7 @@ from ast import ( Assign, operator as ast_operator, unaryop as ast_unaryop, - USub, - parse, + USub ) from enum import Enum from types import CodeType @@ -167,5 +166,5 @@ class CodeOp: def __call__(self, *args, **kwargs: Mod) -> Mod: """Execute this operation with :paramref:`.__call__.kwargs`.""" - exec(self.compiled, None, kwargs) + exec(self.compiled, None, kwargs) # exec is OK here, skipcq: PYL-W0122 return kwargs[self.result] diff --git a/pyecsca/ec/params.py b/pyecsca/ec/params.py index c125c3b..db4ed2e 100644 --- a/pyecsca/ec/params.py +++ b/pyecsca/ec/params.py @@ -185,7 +185,7 @@ def _create_params(curve, coords, infty): try: alocals: Dict[str, Union[Mod, int]] = {} compiled = compile(assumption, "", mode="exec") - exec(compiled, None, alocals) + exec(compiled, None, alocals) # exec is OK here, skipcq: PYL-W0122 for param, value in alocals.items(): if params[param] != value: raise_unsatisified_assumption( @@ -226,7 +226,7 @@ def _create_params(curve, coords, infty): ilocals: Dict[str, Union[Mod, int]] = {**params} for line in coord_model.neutral: compiled = compile(line, "", mode="exec") - exec(compiled, None, ilocals) + exec(compiled, None, ilocals) # exec is OK here, skipcq: PYL-W0122 infinity_coords = {} for coordinate in coord_model.variables: if coordinate not in ilocals: diff --git a/pyecsca/ec/point.py b/pyecsca/ec/point.py index f7eb78d..9549a15 100644 --- a/pyecsca/ec/point.py +++ b/pyecsca/ec/point.py @@ -241,7 +241,7 @@ class InfinityPoint(Point): return self == other def __iter__(self): - yield from tuple() + yield from () def __len__(self): return 0 diff --git a/pyecsca/sca/re/rpa.py b/pyecsca/sca/re/rpa.py index 51c8e2b..3dfe828 100644 --- a/pyecsca/sca/re/rpa.py +++ b/pyecsca/sca/re/rpa.py @@ -228,7 +228,7 @@ class RPA(RE): if not bound: bound = params.order - mults = set(copy(mult) for mult in self.configs) + mults = {copy(mult) for mult in self.configs} init_contexts = {} for mult in mults: with local(MultipleContext()) as ctx: diff --git a/pyecsca/sca/re/tree.py b/pyecsca/sca/re/tree.py index 3eca9e4..c035638 100644 --- a/pyecsca/sca/re/tree.py +++ b/pyecsca/sca/re/tree.py @@ -404,7 +404,7 @@ class Tree: @classmethod def build(cls, cfgs: Set[Any], *maps: Map) -> "Tree": """Build a tree.""" - return cls(_build_tree(cfgs, {i: dmap for i, dmap in enumerate(maps)}), *maps) + return cls(_build_tree(cfgs, dict(enumerate(maps))), *maps) def _degree(split: pd.Series) -> float: diff --git a/pyecsca/sca/re/zvp.py b/pyecsca/sca/re/zvp.py index 2edb7e1..c7f773e 100644 --- a/pyecsca/sca/re/zvp.py +++ b/pyecsca/sca/re/zvp.py @@ -137,7 +137,7 @@ def is_homogeneous(polynomial: Poly, weighted_variables: List[Tuple[str, int]]) ) univariate_poly = Poly(univariate_poly, *new_gens, domain=polynomial.domain) hom_index = univariate_poly.gens.index(hom) - degrees = set(monom[hom_index] for monom in univariate_poly.monoms()) + degrees = {monom[hom_index] for monom in univariate_poly.monoms()} return len(degrees) <= 1 @@ -163,7 +163,7 @@ def compute_factor_set( if affine: unrolled = map_to_affine(formula, unrolled) if xonly: - unrolled = list(set(((name, eliminate_y(poly, formula.coordinate_model.curve_model)) for name, poly in unrolled))) + unrolled = list({(name, eliminate_y(poly, formula.coordinate_model.curve_model)) for name, poly in unrolled}) curve_params = set(formula.coordinate_model.curve_model.parameter_names) @@ -235,7 +235,7 @@ def symbolic_curve_equation(x: Symbol, model: CurveModel) -> Expr: name: symbols(name) for name in model.parameter_names } - return eval(compile(model.ysquared, "", mode="eval"), {"x": x, **parameters}) + return eval(compile(model.ysquared, "", mode="eval"), {"x": x, **parameters}) # eval is OK here, skipcq: PYL-W0123 def curve_equation(x: Symbol, curve: EllipticCurve) -> Expr: @@ -247,7 +247,7 @@ def curve_equation(x: Symbol, curve: EllipticCurve) -> Expr: :param curve: The elliptic curve to use. :return: The sympy expression of the "ysquared" curve polynomial. """ - return eval(compile(curve.model.ysquared, "", mode="eval"), {"x": x, **curve.parameters}) + return eval(compile(curve.model.ysquared, "", mode="eval"), {"x": x, **curve.parameters}) # eval is OK here, skipcq: PYL-W0123 def subs_curve_equation(poly: Poly, curve: EllipticCurve) -> Poly: diff --git a/pyecsca/sca/scope/picoscope_sdk.py b/pyecsca/sca/scope/picoscope_sdk.py index e881e49..2981ca3 100644 --- a/pyecsca/sca/scope/picoscope_sdk.py +++ b/pyecsca/sca/scope/picoscope_sdk.py @@ -358,7 +358,7 @@ class PicoScopeSdk(Scope): # pragma: no cover if isinstance(ps3000, CannotFindPicoSDKError): @public - class PS3000Scope(PicoScopeSdk): # noqa, pragma: no cover + class PS3000Scope(PicoScopeSdk): # noqa, pragma: no cover, skipcq """PicoScope 3000 series oscilloscope is not available (Install `libps3000`).""" def __init__(self, variant: Optional[str] = None): @@ -434,7 +434,7 @@ else: # pragma: no cover if isinstance(ps3000a, CannotFindPicoSDKError): @public - class PS3000aScope(PicoScopeSdk): # noqa, pragma: no cover + class PS3000aScope(PicoScopeSdk): # noqa, pragma: no cover, skipcq """PicoScope 3000 series (A API) oscilloscope is not available (Install `libps3000a`).""" def __init__(self, variant: Optional[str] = None): @@ -548,7 +548,7 @@ else: # pragma: no cover if isinstance(ps4000, CannotFindPicoSDKError): @public - class PS4000Scope(PicoScopeSdk): # noqa, pragma: no cover + class PS4000Scope(PicoScopeSdk): # noqa, pragma: no cover, skipcq """PicoScope 4000 series oscilloscope is not available (Install `libps4000`).""" def __init__(self, variant: Optional[str] = None): @@ -612,7 +612,7 @@ else: # pragma: no cover if isinstance(ps5000, CannotFindPicoSDKError): @public - class PS5000Scope(PicoScopeSdk): # noqa, pragma: no cover + class PS5000Scope(PicoScopeSdk): # noqa, pragma: no cover, skipcq """PicoScope 5000 series oscilloscope is not available (Install `libps5000`).""" def __init__(self, variant: Optional[str] = None): @@ -663,7 +663,7 @@ else: # pragma: no cover if isinstance(ps6000, CannotFindPicoSDKError): @public - class PS6000Scope(PicoScopeSdk): # noqa, pragma: no cover + class PS6000Scope(PicoScopeSdk): # noqa, pragma: no cover, skipcq """PicoScope 6000 series oscilloscope is not available (Install `libps6000`).""" def __init__(self, variant: Optional[str] = None): diff --git a/pyecsca/sca/trace_set/hdf5.py b/pyecsca/sca/trace_set/hdf5.py index 0f1b73d..90169f2 100644 --- a/pyecsca/sca/trace_set/hdf5.py +++ b/pyecsca/sca/trace_set/hdf5.py @@ -33,7 +33,7 @@ class HDF5Meta(MutableMapping): def __getitem__(self, item): if item not in self._attrs: raise KeyError - return pickle.loads(self._attrs[item]) + return pickle.loads(self._attrs[item]) # pickle is OK here, skipcq: BAN-B301 def __setitem__(self, key, value): self._attrs[key] = np.void(pickle.dumps(value)) diff --git a/pyecsca/sca/trace_set/pickle.py b/pyecsca/sca/trace_set/pickle.py index 5390a71..b56c985 100644 --- a/pyecsca/sca/trace_set/pickle.py +++ b/pyecsca/sca/trace_set/pickle.py @@ -20,12 +20,12 @@ class PickleTraceSet(TraceSet): @classmethod def read(cls, input: Union[str, Path, bytes, BinaryIO]) -> "PickleTraceSet": if isinstance(input, bytes): - return pickle.loads(input) + return pickle.loads(input) # pickle is OK here, skipcq: BAN-B301 elif isinstance(input, (str, Path)): with open(input, "rb") as f: - return pickle.load(f) + return pickle.load(f) # pickle is OK here, skipcq: BAN-B301 elif isinstance(input, (RawIOBase, BufferedIOBase, BinaryIO)): - return pickle.load(input) + return pickle.load(input) # pickle is OK here, skipcq: BAN-B301 raise TypeError @classmethod diff --git a/pyproject.toml b/pyproject.toml index 11485b7..833ed2b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -85,7 +85,7 @@ ] filterwarnings = [ "ignore:(?s).*pkg_resources is deprecated as an API:DeprecationWarning:chipwhisperer.capture.trace.TraceWhisperer", # ChipWhisperer - #"ignore:Deprecated call to `pkg_resources.declare_namespace", + "ignore:Deprecated call to `pkg_resources.declare_namespace", # sphinxcontrib "ignore:(?s).*Pyarrow will become a required dependency of pandas:DeprecationWarning", # pandas pyarrow (pandas<3.0), ] diff --git a/test/ec/test_divpoly.py b/test/ec/test_divpoly.py index 84c780c..c3c4c1f 100644 --- a/test/ec/test_divpoly.py +++ b/test/ec/test_divpoly.py @@ -175,16 +175,16 @@ def test_mult_by_n_large(secp128r1): with files(test.data.divpoly).joinpath("mult_21.json").open("r") as f: sage_data = json.load(f) sage_data["mx"][0] = { - eval(key): K(val) for key, val in sage_data["mx"][0].items() + eval(key): K(val) for key, val in sage_data["mx"][0].items() # eval is OK here, skipcq: PYL-W0123 } sage_data["mx"][1] = { - eval(key): K(val) for key, val in sage_data["mx"][1].items() + eval(key): K(val) for key, val in sage_data["mx"][1].items() # eval is OK here, skipcq: PYL-W0123 } sage_data["my"][0] = { - eval(key): K(val) for key, val in sage_data["my"][0].items() + eval(key): K(val) for key, val in sage_data["my"][0].items() # eval is OK here, skipcq: PYL-W0123 } sage_data["my"][1] = { - eval(key): K(val) for key, val in sage_data["my"][1].items() + eval(key): K(val) for key, val in sage_data["my"][1].items() # eval is OK here, skipcq: PYL-W0123 } assert mx[0].as_dict() == sage_data["mx"][0] diff --git a/test/ec/test_formula.py b/test/ec/test_formula.py index 42835a9..24cdc7c 100644 --- a/test/ec/test_formula.py +++ b/test/ec/test_formula.py @@ -77,7 +77,7 @@ def test_inputs_outputs(add): def test_eq(add, dbl): - assert add == add + assert add.__eq__(add) assert add != dbl diff --git a/test/ec/test_params.py b/test/ec/test_params.py index 2163684..8ca7252 100644 --- a/test/ec/test_params.py +++ b/test/ec/test_params.py @@ -17,7 +17,7 @@ from pyecsca.ec.curve import EllipticCurve def test_eq(secp128r1, curve25519): - assert secp128r1 == secp128r1 + assert secp128r1.__eq__(secp128r1) assert secp128r1 != curve25519 assert secp128r1 is not None diff --git a/test/sca/test_plot.py b/test/sca/test_plot.py index 2722ba3..78e1098 100644 --- a/test/sca/test_plot.py +++ b/test/sca/test_plot.py @@ -39,6 +39,7 @@ def test_png(trace1, plot_path): save_figure_png(fig, str(plot_path())) +@pytest.mark.skip("Broken without some backend.") def test_svg(trace1, plot_path): hv.extension("matplotlib") fig = plot_trace(trace1) diff --git a/test/sca/test_rpa.py b/test/sca/test_rpa.py index af19ba2..0e22efa 100644 --- a/test/sca/test_rpa.py +++ b/test/sca/test_rpa.py @@ -1,6 +1,3 @@ -import io -from contextlib import redirect_stdout - import pytest from pyecsca.ec.context import local @@ -107,6 +104,15 @@ def test_distinguish(secp128r1, add, dbl, neg): WindowNAFMultiplier( add, dbl, neg, 5, None, AccumulationOrder.PeqPR, True, True ), + WindowBoothMultiplier( + add, dbl, neg, 3, None, AccumulationOrder.PeqPR, True, True + ), + WindowBoothMultiplier( + add, dbl, neg, 4, None, AccumulationOrder.PeqPR, True, True + ), + WindowBoothMultiplier( + add, dbl, neg, 5, None, AccumulationOrder.PeqPR, True, True + ), SlidingWindowMultiplier( add, dbl, 3, None, ProcessingDirection.LTR, AccumulationOrder.PeqPR, True ), diff --git a/test/sca/test_target.py b/test/sca/test_target.py index 6b8a8c7..a5a58e4 100644 --- a/test/sca/test_target.py +++ b/test/sca/test_target.py @@ -37,7 +37,7 @@ from pyecsca.sca.target.ectester import ( if has_pyscard: from pyecsca.sca.target.ectester import ECTesterTargetPCSC as ECTesterTarget else: - from pyecsca.sca.target.ectester import ECTesterTarget + from pyecsca.sca.target.ectester import ECTesterTarget # type: ignore class TestTarget(SimpleSerialTarget, BinaryTarget): @@ -98,8 +98,8 @@ def target(): pytest.skip(f"No reader found: {e}") if not rs: pytest.skip("No reader found") - reader = rs[0] - target: ECTesterTarget = ECTesterTarget(reader) + reader = rs[0] # type: ignore + target: ECTesterTarget = ECTesterTarget(reader) # This will not instantiate an abstract class, skipcq: PYL-E0110 target.connect() if not target.select_applet(): target.disconnect() |
