aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pyecsca/ec/configuration.py2
-rw-r--r--pyecsca/ec/context.py6
-rw-r--r--pyecsca/ec/coordinates.py2
-rw-r--r--pyecsca/ec/curve.py2
-rw-r--r--pyecsca/ec/error.py2
-rw-r--r--pyecsca/ec/formula.py12
-rw-r--r--pyecsca/ec/key_agreement.py2
-rw-r--r--pyecsca/ec/key_generation.py2
-rw-r--r--pyecsca/ec/mod.py12
-rw-r--r--pyecsca/ec/model.py2
-rw-r--r--pyecsca/ec/mult.py2
-rw-r--r--pyecsca/ec/naf.py2
-rw-r--r--pyecsca/ec/op.py2
-rw-r--r--pyecsca/ec/params.py3
-rw-r--r--pyecsca/ec/point.py2
-rw-r--r--pyecsca/ec/signature.py5
-rw-r--r--pyecsca/ec/transformations.py2
-rw-r--r--pyecsca/misc/cfg.py3
-rw-r--r--pyecsca/sca/re/rpa.py2
-rw-r--r--pyecsca/sca/scope/base.py2
-rw-r--r--pyecsca/sca/scope/chipwhisperer.py11
-rw-r--r--pyecsca/sca/scope/picoscope_alt.py2
-rw-r--r--pyecsca/sca/scope/picoscope_sdk.py8
-rw-r--r--pyecsca/sca/target/ISO7816.py2
-rw-r--r--pyecsca/sca/target/PCSC.py2
-rw-r--r--pyecsca/sca/target/base.py2
-rw-r--r--pyecsca/sca/target/binary.py2
-rw-r--r--pyecsca/sca/target/chipwhisperer.py2
-rw-r--r--pyecsca/sca/target/ectester.py2
-rw-r--r--pyecsca/sca/target/flash.py2
-rw-r--r--pyecsca/sca/target/serial.py2
-rw-r--r--pyecsca/sca/target/simpleserial.py5
-rw-r--r--pyecsca/sca/trace/align.py2
-rw-r--r--pyecsca/sca/trace/combine.py2
-rw-r--r--pyecsca/sca/trace/edit.py2
-rw-r--r--pyecsca/sca/trace/filter.py2
-rw-r--r--pyecsca/sca/trace/match.py2
-rw-r--r--pyecsca/sca/trace/plot.py2
-rw-r--r--pyecsca/sca/trace/process.py2
-rw-r--r--pyecsca/sca/trace/sampling.py2
-rw-r--r--pyecsca/sca/trace/test.py2
-rw-r--r--pyecsca/sca/trace/trace.py6
-rw-r--r--pyecsca/sca/trace_set/base.py2
-rw-r--r--pyecsca/sca/trace_set/hdf5.py2
-rw-r--r--pyecsca/sca/trace_set/inspector.py2
-rw-r--r--pyecsca/sca/trace_set/pickle.py2
-rw-r--r--setup.py5
47 files changed, 79 insertions, 69 deletions
diff --git a/pyecsca/ec/configuration.py b/pyecsca/ec/configuration.py
index 04ee41c..79b7f4c 100644
--- a/pyecsca/ec/configuration.py
+++ b/pyecsca/ec/configuration.py
@@ -1,4 +1,4 @@
-"""This module provides a way to work with and enumerate implementation configurations."""
+"""Provides a way to work with and enumerate implementation configurations."""
from dataclasses import dataclass
from enum import Enum
from itertools import product
diff --git a/pyecsca/ec/context.py b/pyecsca/ec/context.py
index 5357907..a0fd3c2 100644
--- a/pyecsca/ec/context.py
+++ b/pyecsca/ec/context.py
@@ -1,5 +1,5 @@
"""
-This module provides classes for tracing the execution of operations.
+Provides classes for tracing the execution of operations.
The operations include key generation, scalar multiplication, formula execution and individual operation evaluation.
These operations are traced in `Context` classes using `Actions`. Different contexts trace actions differently.
@@ -170,10 +170,10 @@ class NullContext(Context):
"""Context that does not trace any actions."""
def enter_action(self, action: Action) -> None:
- pass
+ pass # Nothing to enter as no action is traced.
def exit_action(self, action: Action) -> None:
- pass
+ pass # Nothing to exit as no action is traced.
@public
diff --git a/pyecsca/ec/coordinates.py b/pyecsca/ec/coordinates.py
index a9a8a8b..c131aca 100644
--- a/pyecsca/ec/coordinates.py
+++ b/pyecsca/ec/coordinates.py
@@ -1,4 +1,4 @@
-"""This module provides a coordinate model class."""
+"""Provides a coordinate model class."""
from ast import parse, Module
from os.path import join
from typing import List, Any, MutableMapping
diff --git a/pyecsca/ec/curve.py b/pyecsca/ec/curve.py
index 4a14139..a032e3c 100644
--- a/pyecsca/ec/curve.py
+++ b/pyecsca/ec/curve.py
@@ -1,4 +1,4 @@
-"""This module provides an elliptic curve class."""
+"""Provides an elliptic curve class."""
from ast import Module
from copy import copy
from typing import MutableMapping, Union, List, Optional
diff --git a/pyecsca/ec/error.py b/pyecsca/ec/error.py
index 87ca335..cf71c42 100644
--- a/pyecsca/ec/error.py
+++ b/pyecsca/ec/error.py
@@ -1,4 +1,4 @@
-"""This module contains exceptions and warnings used in the library."""
+"""Contains exceptions and warnings used in the library."""
import warnings
from public import public
from ..misc.cfg import getconfig
diff --git a/pyecsca/ec/formula.py b/pyecsca/ec/formula.py
index aac239f..994709c 100644
--- a/pyecsca/ec/formula.py
+++ b/pyecsca/ec/formula.py
@@ -1,4 +1,4 @@
-"""This module provides an abstract base class of a formula along with concrete instantiations."""
+"""Provides an abstract base class of a formula along with concrete instantiations."""
from abc import ABC, abstractmethod
from ast import parse, Expression
from astunparse import unparse
@@ -181,7 +181,7 @@ class Formula(ABC):
f"This formula couldn't be executed due to an unsupported assumption ({assumption_string})."
)
- def resolve(expression):
+ def resolve(expression, k):
if not expression.args:
return expression
args = []
@@ -189,13 +189,13 @@ class Formula(ABC):
if isinstance(arg, Rational):
a = arg.p
b = arg.q
- arg = k(a) / k(b)
+ res = k(a) / k(b)
else:
- arg = resolve(arg)
- args.append(arg)
+ res = resolve(arg, k)
+ args.append(res)
return expression.func(*args)
- expr = resolve(expr)
+ expr = resolve(expr, k)
poly = Poly(expr, symbols(param), domain=k)
roots = poly.ground_roots()
for root in roots:
diff --git a/pyecsca/ec/key_agreement.py b/pyecsca/ec/key_agreement.py
index 2141547..555005f 100644
--- a/pyecsca/ec/key_agreement.py
+++ b/pyecsca/ec/key_agreement.py
@@ -1,4 +1,4 @@
-"""This module provides an implementation of ECDH (Elliptic Curve Diffie-Hellman)."""
+"""Provides an implementation of ECDH (Elliptic Curve Diffie-Hellman)."""
import hashlib
from typing import Optional, Any
diff --git a/pyecsca/ec/key_generation.py b/pyecsca/ec/key_generation.py
index abc963d..43a20cd 100644
--- a/pyecsca/ec/key_generation.py
+++ b/pyecsca/ec/key_generation.py
@@ -1,4 +1,4 @@
-"""This module provides a key generator for elliptic curve keypairs."""
+"""Provides a key generator for elliptic curve keypairs."""
from typing import Tuple
from public import public
diff --git a/pyecsca/ec/mod.py b/pyecsca/ec/mod.py
index 47bf2b3..add7581 100644
--- a/pyecsca/ec/mod.py
+++ b/pyecsca/ec/mod.py
@@ -1,5 +1,5 @@
"""
-This module provides several implementations of an element of ℤₙ.
+Provides several implementations of an element of ℤₙ.
The base class :py:class:`Mod` dynamically
dispatches to the implementation chosen by the runtime configuration of the library
@@ -35,7 +35,7 @@ def gcd(a, b):
return gcd(b, a)
while abs(b) > 0:
- q, r = divmod(a, b)
+ _, r = divmod(a, b)
a, b = b, r
return a
@@ -43,9 +43,9 @@ def gcd(a, b):
@public
def extgcd(a, b):
- """Extended Euclid's greatest common denominator algorithm."""
+ """Compute the extended Euclid's greatest common denominator algorithm."""
if abs(b) > abs(a):
- (x, y, d) = extgcd(b, a)
+ x, y, d = extgcd(b, a)
return y, x, d
if abs(b) == 0:
@@ -198,7 +198,7 @@ class Mod:
def sqrt(self) -> "Mod":
"""
- The modular square root of this element (only implemented for prime modulus).
+ Compute the modular square root of this element (only implemented for prime modulus).
Uses the `Tonelli-Shanks <https://en.wikipedia.org/wiki/Tonelli–Shanks_algorithm>`_ algorithm.
"""
@@ -274,7 +274,7 @@ class RawMod(Mod):
def inverse(self) -> "RawMod":
if self.x == 0:
raise_non_invertible()
- x, y, d = extgcd(self.x, self.n)
+ x, _, d = extgcd(self.x, self.n)
if d != 1:
raise_non_invertible()
return RawMod(x, self.n)
diff --git a/pyecsca/ec/model.py b/pyecsca/ec/model.py
index e714991..bea5554 100644
--- a/pyecsca/ec/model.py
+++ b/pyecsca/ec/model.py
@@ -1,4 +1,4 @@
-"""This module provides curve model classes for the supported curve models."""
+"""Provides curve model classes for the supported curve models."""
from ast import parse, Expression, Module
from os.path import join
from typing import List, MutableMapping
diff --git a/pyecsca/ec/mult.py b/pyecsca/ec/mult.py
index dc89237..53e593e 100644
--- a/pyecsca/ec/mult.py
+++ b/pyecsca/ec/mult.py
@@ -1,4 +1,4 @@
-"""This module provides several classes implementing different scalar multiplication algorithms."""
+"""Provides several classes implementing different scalar multiplication algorithms."""
from abc import ABC, abstractmethod
from copy import copy
from typing import Mapping, Tuple, Optional, MutableMapping, ClassVar, Set, Type
diff --git a/pyecsca/ec/naf.py b/pyecsca/ec/naf.py
index 2595a4e..fd1fa47 100644
--- a/pyecsca/ec/naf.py
+++ b/pyecsca/ec/naf.py
@@ -1,4 +1,4 @@
-"""This module provides functions for computing the Non-Adjacent Form (NAF) of integers."""
+"""Provides functions for computing the Non-Adjacent Form (NAF) of integers."""
from public import public
from typing import List
diff --git a/pyecsca/ec/op.py b/pyecsca/ec/op.py
index 406bd1f..d656bc3 100644
--- a/pyecsca/ec/op.py
+++ b/pyecsca/ec/op.py
@@ -1,4 +1,4 @@
-"""This module provides a class for a code operation."""
+"""Provides a class for a code operation."""
from ast import (
Module,
walk,
diff --git a/pyecsca/ec/params.py b/pyecsca/ec/params.py
index 63cdf05..1feb61b 100644
--- a/pyecsca/ec/params.py
+++ b/pyecsca/ec/params.py
@@ -1,5 +1,5 @@
"""
-This module provides functions for obtaining domain parameters from the `std-curves <https://github.com/J08nY/std-curves>`_ repository.
+Provides functions for obtaining domain parameters from the `std-curves <https://github.com/J08nY/std-curves>`_ repository.
It also provides a domain parameter class and a class for a whole category of domain parameters.
"""
@@ -340,6 +340,7 @@ def get_params(
json_path = join("std", category, "curves.json")
with resource_stream(__name__, json_path) as f:
category_json = json.load(f)
+ curve = None
for curve in category_json["curves"]:
if curve["name"] == name:
break
diff --git a/pyecsca/ec/point.py b/pyecsca/ec/point.py
index b12b312..b28e130 100644
--- a/pyecsca/ec/point.py
+++ b/pyecsca/ec/point.py
@@ -1,4 +1,4 @@
-"""This module provides a :py:class:`.Point` class and a special :py:class:`.InfinityPoint` class for the point at infinity."""
+"""Provides a :py:class:`.Point` class and a special :py:class:`.InfinityPoint` class for the point at infinity."""
from copy import copy
from typing import Mapping, TYPE_CHECKING
diff --git a/pyecsca/ec/signature.py b/pyecsca/ec/signature.py
index d9b49f7..a65adbc 100644
--- a/pyecsca/ec/signature.py
+++ b/pyecsca/ec/signature.py
@@ -1,4 +1,4 @@
-"""This module provides an implementation of ECDSA (Elliptic Curve Digital Signature Algorithm)."""
+"""Provides an implementation of ECDSA (Elliptic Curve Digital Signature Algorithm)."""
import hashlib
from typing import Optional, Any
@@ -42,6 +42,9 @@ class SignatureResult:
return False
return self.r == other.r and self.s == other.s
+ def __hash__(self):
+ return hash((self.r, self.s)) + 11
+
def __str__(self):
return f"(r={self.r}, s={self.s})"
diff --git a/pyecsca/ec/transformations.py b/pyecsca/ec/transformations.py
index 9d3d650..894421f 100644
--- a/pyecsca/ec/transformations.py
+++ b/pyecsca/ec/transformations.py
@@ -1,4 +1,4 @@
-"""This module provides functions for transforming curves to different models."""
+"""Provides functions for transforming curves to different models."""
from public import public
from sympy import FF, symbols, Poly
diff --git a/pyecsca/misc/cfg.py b/pyecsca/misc/cfg.py
index 54579d9..2affb27 100644
--- a/pyecsca/misc/cfg.py
+++ b/pyecsca/misc/cfg.py
@@ -1,5 +1,5 @@
"""
-This module provides functions for runtime configuration of the toolkit.
+Provides functions for runtime configuration of the toolkit.
This includes how errors are handled, or which :py:class:`~pyecsca.ec.mod.Mod` implementation is used.
"""
@@ -179,6 +179,7 @@ class TemporaryConfig:
cfg.some_property = some_value
...
"""
+
token: Optional[Token]
def __init__(self):
diff --git a/pyecsca/sca/re/rpa.py b/pyecsca/sca/re/rpa.py
index 4330fb4..51b9738 100644
--- a/pyecsca/sca/re/rpa.py
+++ b/pyecsca/sca/re/rpa.py
@@ -1,5 +1,5 @@
"""
-This module provides functionality inspired by the Refined-Power Analysis attack by Goubin.
+Provides functionality inspired by the Refined-Power Analysis attack by Goubin.
A Refined Power-Analysis Attack on Elliptic Curve Cryptosystems, Louis Goubin, PKC '03
`<https://dl.acm.org/doi/10.5555/648120.747060>`_
diff --git a/pyecsca/sca/scope/base.py b/pyecsca/sca/scope/base.py
index 76b1272..08befda 100644
--- a/pyecsca/sca/scope/base.py
+++ b/pyecsca/sca/scope/base.py
@@ -1,4 +1,4 @@
-"""This module provides an abstract base class for oscilloscopes."""
+"""Provides an abstract base class for oscilloscopes."""
from enum import Enum, auto
from typing import Tuple, Sequence, Optional
diff --git a/pyecsca/sca/scope/chipwhisperer.py b/pyecsca/sca/scope/chipwhisperer.py
index 5df98dd..3706c0e 100644
--- a/pyecsca/sca/scope/chipwhisperer.py
+++ b/pyecsca/sca/scope/chipwhisperer.py
@@ -1,4 +1,4 @@
-"""This module provides an oscilloscope class using the ChipWhisperer-Lite scope."""
+"""Provides an oscilloscope class using the ChipWhisperer-Lite scope."""
from typing import Optional, Tuple, Sequence, Set
import numpy as np
@@ -32,13 +32,12 @@ class ChipWhispererScope(Scope): # pragma: no cover
raise ValueError("ChipWhisperer does not support pretrig samples.")
self.scope.clock.clkgen_freq = frequency
self.scope.adc.samples = posttrig
- # TODO: Fix this, broken with new CW api.
- return self.scope.clock.freq_ctr, self.scope.adc.samples
+ return self.scope.clock.clkgen_freq, self.scope.adc.samples
def setup_channel(
self, channel: str, coupling: str, range: float, offset: float, enable: bool
) -> None:
- pass
+ pass # Nothing to setup
def setup_trigger(
self,
@@ -57,7 +56,7 @@ class ChipWhispererScope(Scope): # pragma: no cover
self.scope.trigger.triggers = " OR ".join(self.triggers)
def setup_capture(self, channel: str, enable: bool) -> None:
- pass
+ pass # Nothing to setup
def arm(self) -> None:
self.scope.arm()
@@ -77,7 +76,7 @@ class ChipWhispererScope(Scope): # pragma: no cover
)
def stop(self) -> None:
- pass
+ pass # Nothing to do
def close(self) -> None:
self.scope.dis()
diff --git a/pyecsca/sca/scope/picoscope_alt.py b/pyecsca/sca/scope/picoscope_alt.py
index e8f17a5..900d796 100644
--- a/pyecsca/sca/scope/picoscope_alt.py
+++ b/pyecsca/sca/scope/picoscope_alt.py
@@ -1,4 +1,4 @@
-"""This module provides an oscilloscope class for the PicoScope branded oscilloscopes using the alternative `pico-python <https://github.com/colinoflynn/pico-python>`_ bindings."""
+"""Provides an oscilloscope class for the PicoScope branded oscilloscopes using the alternative `pico-python <https://github.com/colinoflynn/pico-python>`_ bindings."""
from time import time_ns, sleep
import numpy as np
from typing import Optional, Tuple, Sequence, Union
diff --git a/pyecsca/sca/scope/picoscope_sdk.py b/pyecsca/sca/scope/picoscope_sdk.py
index 3ee54cf..05ba34e 100644
--- a/pyecsca/sca/scope/picoscope_sdk.py
+++ b/pyecsca/sca/scope/picoscope_sdk.py
@@ -1,4 +1,4 @@
-"""This module provides an oscilloscope class for PicoScope branded oscilloscopes using the official `picosdk-python-wrappers <https://github.com/picotech/picosdk-python-wrappers>`_."""
+"""Provides an oscilloscope class for PicoScope branded oscilloscopes using the official `picosdk-python-wrappers <https://github.com/picotech/picosdk-python-wrappers>`_."""
import ctypes
from math import log2, floor
from time import time_ns, sleep
@@ -344,7 +344,7 @@ class PicoScopeSdk(Scope): # pragma: no cover
if isinstance(ps3000, CannotFindPicoSDKError):
@public
- class PS3000Scope(PicoScopeSdk): # pragma: no cover
+ class PS3000Scope(PicoScopeSdk): # noqa, pragma: no cover
"""PicoScope 3000 series oscilloscope is not available (Install `libps3000`)."""
def __init__(self, variant: Optional[str] = None):
@@ -411,7 +411,7 @@ else: # pragma: no cover
if isinstance(ps4000, CannotFindPicoSDKError):
@public
- class PS4000Scope(PicoScopeSdk): # pragma: no cover
+ class PS4000Scope(PicoScopeSdk): # noqa, pragma: no cover
"""PicoScope 4000 series oscilloscope is not available (Install `libps4000`)."""
def __init__(self, variant: Optional[str] = None):
@@ -474,7 +474,7 @@ else: # pragma: no cover
if isinstance(ps5000, CannotFindPicoSDKError):
@public
- class PS5000Scope(PicoScopeSdk): # pragma: no cover
+ class PS5000Scope(PicoScopeSdk): # noqa, pragma: no cover
"""PicoScope 5000 series oscilloscope is not available (Install `libps5000`)."""
def __init__(self, variant: Optional[str] = None):
diff --git a/pyecsca/sca/target/ISO7816.py b/pyecsca/sca/target/ISO7816.py
index cca09d5..4441f94 100644
--- a/pyecsca/sca/target/ISO7816.py
+++ b/pyecsca/sca/target/ISO7816.py
@@ -1,4 +1,4 @@
-"""This module provides classes for working with ISO7816-4 APDUs and an abstract base class for an ISO7816-4 based target."""
+"""Provides classes for working with ISO7816-4 APDUs and an abstract base class for an ISO7816-4 based target."""
from abc import abstractmethod, ABC
from dataclasses import dataclass
from typing import Optional
diff --git a/pyecsca/sca/target/PCSC.py b/pyecsca/sca/target/PCSC.py
index ca77d12..f36843f 100644
--- a/pyecsca/sca/target/PCSC.py
+++ b/pyecsca/sca/target/PCSC.py
@@ -1,4 +1,4 @@
-"""This module provides a smartcard target communicating via PC/SC (Personal Computer/Smart Card)."""
+"""Provides a smartcard target communicating via PC/SC (Personal Computer/Smart Card)."""
from typing import Union
from public import public
diff --git a/pyecsca/sca/target/base.py b/pyecsca/sca/target/base.py
index 0c24f8d..53106d5 100644
--- a/pyecsca/sca/target/base.py
+++ b/pyecsca/sca/target/base.py
@@ -1,4 +1,4 @@
-"""This module provides an abstract base class for targets."""
+"""Provides an abstract base class for targets."""
from abc import ABC, abstractmethod
from public import public
diff --git a/pyecsca/sca/target/binary.py b/pyecsca/sca/target/binary.py
index 9e782f6..310b9e2 100644
--- a/pyecsca/sca/target/binary.py
+++ b/pyecsca/sca/target/binary.py
@@ -1,4 +1,4 @@
-"""This module provides a binary target class which represents a target that is a runnable binary on the host."""
+"""Provides a binary target class which represents a target that is a runnable binary on the host."""
import subprocess
from subprocess import Popen
from typing import Optional, Union, List
diff --git a/pyecsca/sca/target/chipwhisperer.py b/pyecsca/sca/target/chipwhisperer.py
index 47e3ab0..49daef3 100644
--- a/pyecsca/sca/target/chipwhisperer.py
+++ b/pyecsca/sca/target/chipwhisperer.py
@@ -1,5 +1,5 @@
"""
-This module provides a `ChipWhisperer <https://github.com/newaetech/chipwhisperer/>`_ target class.
+Provides a `ChipWhisperer <https://github.com/newaetech/chipwhisperer/>`_ target class.
ChipWhisperer is a side-channel analysis tool and framework. A ChipWhisperer target is one
that uses the ChipWhisperer's SimpleSerial communication protocol and is communicated with
diff --git a/pyecsca/sca/target/ectester.py b/pyecsca/sca/target/ectester.py
index 4057e61..a4a13c2 100644
--- a/pyecsca/sca/target/ectester.py
+++ b/pyecsca/sca/target/ectester.py
@@ -1,4 +1,4 @@
-"""This module provides an `ECTester <https://github.com/crocs-muni/ECTester/>`_ target class."""
+"""Provides an `ECTester <https://github.com/crocs-muni/ECTester/>`_ target class."""
from abc import ABC
from binascii import hexlify
from enum import IntEnum, IntFlag
diff --git a/pyecsca/sca/target/flash.py b/pyecsca/sca/target/flash.py
index b644c27..95c078d 100644
--- a/pyecsca/sca/target/flash.py
+++ b/pyecsca/sca/target/flash.py
@@ -1,4 +1,4 @@
-"""This module provides a mix-in class of a flashable target (e.g. one where the code gets flashed to it before running)."""
+"""Provides a mix-in class of a flashable target (e.g. one where the code gets flashed to it before running)."""
from public import public
from abc import ABC, abstractmethod
diff --git a/pyecsca/sca/target/serial.py b/pyecsca/sca/target/serial.py
index fba5d69..3b81851 100644
--- a/pyecsca/sca/target/serial.py
+++ b/pyecsca/sca/target/serial.py
@@ -1,4 +1,4 @@
-"""This module provides an abstract serial target, that communicates by writing and reading a stream of bytes."""
+"""Provides an abstract serial target, that communicates by writing and reading a stream of bytes."""
from abc import abstractmethod
from public import public
diff --git a/pyecsca/sca/target/simpleserial.py b/pyecsca/sca/target/simpleserial.py
index 882ac93..aeb5c5f 100644
--- a/pyecsca/sca/target/simpleserial.py
+++ b/pyecsca/sca/target/simpleserial.py
@@ -1,4 +1,5 @@
-"""This module provides an abstract target class communicating using the `ChipWhisperer's <https://github.com/newaetech/chipwhisperer/>`_ SimpleSerial protocol."""
+"""Provides an abstract target class communicating using the `ChipWhisperer's <https://github.com/newaetech/chipwhisperer/>`_ SimpleSerial protocol."""
+from abc import ABC
from time import time_ns, sleep
from typing import Mapping, Union
@@ -35,7 +36,7 @@ class SimpleSerialMessage:
@public
-class SimpleSerialTarget(SerialTarget):
+class SimpleSerialTarget(SerialTarget, ABC):
"""A SimpleSerial target, sends and receives SimpleSerial messages over a serial link."""
def recv_msgs(self, timeout: int) -> Mapping[str, SimpleSerialMessage]:
diff --git a/pyecsca/sca/trace/align.py b/pyecsca/sca/trace/align.py
index 598a62e..71815b8 100644
--- a/pyecsca/sca/trace/align.py
+++ b/pyecsca/sca/trace/align.py
@@ -1,4 +1,4 @@
-"""This module provides functions for aligning traces in a trace set to a reference trace within it."""
+"""Provides functions for aligning traces in a trace set to a reference trace within it."""
import numpy as np
from copy import deepcopy
from fastdtw import fastdtw, dtw
diff --git a/pyecsca/sca/trace/combine.py b/pyecsca/sca/trace/combine.py
index 9df6059..622a325 100644
--- a/pyecsca/sca/trace/combine.py
+++ b/pyecsca/sca/trace/combine.py
@@ -1,4 +1,4 @@
-"""This module provides functions for combining traces sample-wise."""
+"""Provides functions for combining traces sample-wise."""
from typing import Callable, Optional, Tuple
import numpy as np
diff --git a/pyecsca/sca/trace/edit.py b/pyecsca/sca/trace/edit.py
index 707c1a3..52338e6 100644
--- a/pyecsca/sca/trace/edit.py
+++ b/pyecsca/sca/trace/edit.py
@@ -1,4 +1,4 @@
-"""This module provides functions for editing traces as if they were tapes you can trim, reverse, etc."""
+"""Provides functions for editing traces as if they were tapes you can trim, reverse, etc."""
import numpy as np
from public import public
from typing import Union, Tuple, Any, Optional
diff --git a/pyecsca/sca/trace/filter.py b/pyecsca/sca/trace/filter.py
index 48d065c..40ec13e 100644
--- a/pyecsca/sca/trace/filter.py
+++ b/pyecsca/sca/trace/filter.py
@@ -1,4 +1,4 @@
-"""This module provides functions for filtering traces using digital (low/high/band)-pass and bandstop filters."""
+"""Provides functions for filtering traces using digital (low/high/band)-pass and bandstop filters."""
from public import public
from scipy.signal import butter, lfilter
from typing import Union, Tuple
diff --git a/pyecsca/sca/trace/match.py b/pyecsca/sca/trace/match.py
index bcd4334..ae41dff 100644
--- a/pyecsca/sca/trace/match.py
+++ b/pyecsca/sca/trace/match.py
@@ -1,4 +1,4 @@
-"""This module provides functions for matching a pattern within a trace to it."""
+"""Provides functions for matching a pattern within a trace to it."""
import numpy as np
from scipy.signal import find_peaks
from public import public
diff --git a/pyecsca/sca/trace/plot.py b/pyecsca/sca/trace/plot.py
index 63fa2dd..fd38a9e 100644
--- a/pyecsca/sca/trace/plot.py
+++ b/pyecsca/sca/trace/plot.py
@@ -1,4 +1,4 @@
-"""This module provides functions for plotting traces."""
+"""Provides functions for plotting traces."""
from functools import reduce
import holoviews as hv
diff --git a/pyecsca/sca/trace/process.py b/pyecsca/sca/trace/process.py
index dac24ed..eee487c 100644
--- a/pyecsca/sca/trace/process.py
+++ b/pyecsca/sca/trace/process.py
@@ -1,4 +1,4 @@
-"""This module provides functions for sample-wise processing of single traces."""
+"""Provides functions for sample-wise processing of single traces."""
from typing import cast
import numpy as np
diff --git a/pyecsca/sca/trace/sampling.py b/pyecsca/sca/trace/sampling.py
index c92a478..b04ec5e 100644
--- a/pyecsca/sca/trace/sampling.py
+++ b/pyecsca/sca/trace/sampling.py
@@ -1,4 +1,4 @@
-"""This module provides downsampling functions for traces."""
+"""Provides downsampling functions for traces."""
from typing import cast
import numpy as np
diff --git a/pyecsca/sca/trace/test.py b/pyecsca/sca/trace/test.py
index a0d98a5..82afc19 100644
--- a/pyecsca/sca/trace/test.py
+++ b/pyecsca/sca/trace/test.py
@@ -1,4 +1,4 @@
-"""This module provides statistical tests usable on groups of traces sample-wise (Welch's and Student's t-test, ...)."""
+"""Provides statistical tests usable on groups of traces sample-wise (Welch's and Student's t-test, ...)."""
from typing import Sequence, Optional, Tuple
import numpy as np
diff --git a/pyecsca/sca/trace/trace.py b/pyecsca/sca/trace/trace.py
index 0d5d027..367125b 100644
--- a/pyecsca/sca/trace/trace.py
+++ b/pyecsca/sca/trace/trace.py
@@ -1,4 +1,4 @@
-"""This module provides the Trace class."""
+"""Provides the Trace class."""
import weakref
from typing import Any, Mapping, Sequence, Optional
from copy import copy, deepcopy
@@ -76,6 +76,10 @@ class Trace:
return False
return np.array_equal(self.samples, other.samples) and self.meta == other.meta
+ def __hash__(self):
+ # This will have collisions, but those can be sorted out by the equality check above.
+ return hash(str(self.samples)) + hash(self.meta)
+
def with_samples(self, samples: ndarray) -> "Trace":
"""
Construct a copy of this trace, with the same metadata, but samples replaced by `samples`.
diff --git a/pyecsca/sca/trace_set/base.py b/pyecsca/sca/trace_set/base.py
index d2e5791..d757615 100644
--- a/pyecsca/sca/trace_set/base.py
+++ b/pyecsca/sca/trace_set/base.py
@@ -1,4 +1,4 @@
-"""This module provides a base traceset class."""
+"""Provides a base traceset class."""
from pathlib import Path
from typing import List, Union, BinaryIO
diff --git a/pyecsca/sca/trace_set/hdf5.py b/pyecsca/sca/trace_set/hdf5.py
index dabb266..a3e72aa 100644
--- a/pyecsca/sca/trace_set/hdf5.py
+++ b/pyecsca/sca/trace_set/hdf5.py
@@ -1,5 +1,5 @@
"""
-This module provides a traceset implemented on top of the Hierarchical Data Format (HDF5).
+Provides a traceset implemented on top of the Hierarchical Data Format (HDF5).
This traceset can be loaded "inplace" which means that it is not fully loaded into memory, and only parts of traces that
are operated on are in memory. This is very useful for working with huge sets of traces that do not fit in memory.
diff --git a/pyecsca/sca/trace_set/inspector.py b/pyecsca/sca/trace_set/inspector.py
index 00e8273..2c9d581 100644
--- a/pyecsca/sca/trace_set/inspector.py
+++ b/pyecsca/sca/trace_set/inspector.py
@@ -1,4 +1,4 @@
-"""This module provides a traceset implementation based on Riscure's Inspector traceset format (``.trs``)."""
+"""Provides a traceset implementation based on Riscure's Inspector traceset format (``.trs``)."""
import struct
from enum import IntEnum
from io import BytesIO, RawIOBase, BufferedIOBase, UnsupportedOperation
diff --git a/pyecsca/sca/trace_set/pickle.py b/pyecsca/sca/trace_set/pickle.py
index 08def8a..5390a71 100644
--- a/pyecsca/sca/trace_set/pickle.py
+++ b/pyecsca/sca/trace_set/pickle.py
@@ -1,5 +1,5 @@
"""
-This module provides a traceset implementation based on Python's pickle format.
+Provides a traceset implementation based on Python's pickle format.
This implementation of the traceset is thus very generic.
"""
diff --git a/setup.py b/setup.py
index eddc9fc..fbd423c 100644
--- a/setup.py
+++ b/setup.py
@@ -27,7 +27,7 @@ setup(
# install_package_data=True,
python_requires='>=3.8',
install_requires=[
- "numpy",
+ "numpy==1.23.5",
"scipy",
"sympy>=1.7.1",
"atpublic",
@@ -40,7 +40,8 @@ setup(
"matplotlib",
"datashader",
"xarray",
- "astunparse"
+ "astunparse",
+ "numba==0.56.4"
],
extras_require={
"picoscope_sdk": ["picosdk"],