aboutsummaryrefslogtreecommitdiff
path: root/pyecsca/ec/error.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyecsca/ec/error.py')
-rw-r--r--pyecsca/ec/error.py37
1 files changed, 28 insertions, 9 deletions
diff --git a/pyecsca/ec/error.py b/pyecsca/ec/error.py
index 26e7945..fac4aac 100644
--- a/pyecsca/ec/error.py
+++ b/pyecsca/ec/error.py
@@ -1,23 +1,28 @@
-"""
-This module contains exceptions and warnings used in the library.
-"""
+"""This module contains exceptions and warnings used in the library."""
from public import public
from ..misc.cfg import getconfig
@public
class NonInvertibleError(ArithmeticError):
+ """Non-invertible element was inverted."""
+
pass
@public
class NonInvertibleWarning(UserWarning):
+ """Non-invertible element was inverted."""
+
pass
def raise_non_invertible():
- """Raise either :py:class:`NonInvertibleError` or :py:class:`NonInvertiblerWarning` or ignore.
- Depends on the current config value of `no_inverse_action`."""
+ """
+ Raise either :py:class:`NonInvertibleError` or :py:class:`NonInvertiblerWarning` or ignore.
+
+ Depends on the current config value of :py:attr:`Config.ec.no_inverse_action`.
+ """
cfg = getconfig()
if cfg.ec.no_inverse_action == "error":
raise NonInvertibleError("Element not invertible.")
@@ -27,17 +32,24 @@ def raise_non_invertible():
@public
class NonResidueError(ArithmeticError):
+ """Non-residue element was square-rooted."""
+
pass
@public
class NonResidueWarning(UserWarning):
+ """Non-residue element was square-rooted."""
+
pass
def raise_non_residue():
- """Raise either :py:class:`NonResidueError` or :py:class:`NonResidueWarning` or ignore.
- Depends on the current config value of `non_residue_action`."""
+ """
+ Raise either :py:class:`NonResidueError` or :py:class:`NonResidueWarning` or ignore.
+
+ Depends on the current config value of :py:attr:`Config.ec.non_residue_action`.
+ """
cfg = getconfig()
if cfg.ec.non_residue_action == "error":
raise NonResidueError("No square root exists.")
@@ -47,17 +59,24 @@ def raise_non_residue():
@public
class UnsatisfiedAssumptionError(ValueError):
+ """Unsatisfied assumption was hit."""
+
pass
@public
class UnsatisfiedAssumptionWarning(UserWarning):
+ """Unsatisfied assumption was hit."""
+
pass
def raise_unsatisified_assumption(action: str, msg: str):
- """Raise either :py:class:`UnsatisfiedAssumptionError` or :py:class:`UnsatisfiedAssumptionWarning` or ignore.
- Depends on the value of `action`."""
+ """
+ Raise either :py:class:`UnsatisfiedAssumptionError` or :py:class:`UnsatisfiedAssumptionWarning` or ignore.
+
+ Depends on the value of :paramref:`~.raise_unsatisified_assumption.action`.
+ """
if action == "error":
raise UnsatisfiedAssumptionError(msg)
elif action == "warning":