diff options
| author | J08nY | 2024-05-21 20:48:14 +0200 |
|---|---|---|
| committer | J08nY | 2024-05-21 20:48:14 +0200 |
| commit | dda535b3600fc3385df996da47afdecb3b3df0ef (patch) | |
| tree | 57aa7d34d880776458b31c36b471b908768f1869 | |
| parent | 2a804b2dea0bd480a89f9decb72f35010d3436d6 (diff) | |
| download | pyecsca-dda535b3600fc3385df996da47afdecb3b3df0ef.tar.gz pyecsca-dda535b3600fc3385df996da47afdecb3b3df0ef.tar.zst pyecsca-dda535b3600fc3385df996da47afdecb3b3df0ef.zip | |
Add some more missing docs.
| -rw-r--r-- | pyecsca/ec/coordinates.py | 1 | ||||
| -rw-r--r-- | pyecsca/misc/utils.py | 7 | ||||
| -rw-r--r-- | pyecsca/sca/re/base.py | 5 | ||||
| -rw-r--r-- | pyecsca/sca/target/ectester.py | 3 |
4 files changed, 16 insertions, 0 deletions
diff --git a/pyecsca/ec/coordinates.py b/pyecsca/ec/coordinates.py index f356b66..03aae77 100644 --- a/pyecsca/ec/coordinates.py +++ b/pyecsca/ec/coordinates.py @@ -60,6 +60,7 @@ class CoordinateModel: @public class AffineCoordinateModel(CoordinateModel): + """An affine coordinate model (there is really only one per curve model).""" name = "affine" full_name = "Affine coordinates" diff --git a/pyecsca/misc/utils.py b/pyecsca/misc/utils.py index e525fe0..f19009e 100644 --- a/pyecsca/misc/utils.py +++ b/pyecsca/misc/utils.py @@ -10,10 +10,12 @@ from concurrent.futures import ProcessPoolExecutor, as_completed, Future def pexec(s): + """Parse with exec.""" return parse(s, mode="exec") def peval(s): + """Parse with eval.""" return parse(s, mode="eval") @@ -55,7 +57,9 @@ class TaskExecutor(ProcessPoolExecutor): """A simple ProcessPoolExecutor that keeps tracks of tasks that were submitted to it.""" keys: List[Any] + """A list of keys that identify the futures.""" futures: List[Future] + """A list of futures submitted to the executor.""" def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -63,6 +67,7 @@ class TaskExecutor(ProcessPoolExecutor): self.futures = [] def submit_task(self, key: Any, fn, /, *args, **kwargs): + """Submit a task (function `fn`), identified by `key` and with `args` and `kwargs`.""" future = self.submit(fn, *args, **kwargs) self.futures.append(future) self.keys.append(key) @@ -70,9 +75,11 @@ class TaskExecutor(ProcessPoolExecutor): @property def tasks(self): + """A list of tasks that were submitted to this executor.""" return list(zip(self.keys, self.futures)) def as_completed(self) -> Generator[tuple[Any, Future], Any, None]: + """Like `concurrent.futures.as_completed`, but yields a pair of key and future.""" for future in as_completed(self.futures): i = self.futures.index(future) yield self.keys[i], future diff --git a/pyecsca/sca/re/base.py b/pyecsca/sca/re/base.py index 1340a68..742e930 100644 --- a/pyecsca/sca/re/base.py +++ b/pyecsca/sca/re/base.py @@ -8,16 +8,21 @@ from .tree import Tree @public class RE(ABC): + """A base class for Reverse-Engineering methods.""" tree: Optional[Tree] = None + """The RE tree (if any).""" configs: Set[Any] + """The set of configurations to reverse-engineer.""" def __init__(self, configs: Set[Any]): self.configs = configs @abstractmethod def build_tree(self, *args, **kwargs): + """Build the RE tree.""" pass @abstractmethod def run(self, *args, **kwargs): + """Run the reverse-engineering (and obtain a result set of possible configurations).""" pass diff --git a/pyecsca/sca/target/ectester.py b/pyecsca/sca/target/ectester.py index 394d86f..512f51c 100644 --- a/pyecsca/sca/target/ectester.py +++ b/pyecsca/sca/target/ectester.py @@ -17,6 +17,8 @@ from ...ec.point import Point class ShiftableFlag(IntFlag): # pragma: no cover + """An `IntFlag` that can be shifted.""" + def __lshift__(self, other): val = int(self) << other for e in self.__class__: @@ -92,6 +94,7 @@ class ExportEnum(IntEnum): # pragma: no cover @classmethod def from_bool(cls, val: bool): + """Construct an `ExportEnum` from a boolean.""" return cls.EXPORT_TRUE if val else cls.EXPORT_FALSE |
