aboutsummaryrefslogtreecommitdiffhomepage
path: root/pyecsca/ec
diff options
context:
space:
mode:
authorJ08nY2023-07-29 16:08:03 +0200
committerJ08nY2023-07-29 16:08:03 +0200
commit58b3e0f862ab13f7125d40c9360b4b348366370a (patch)
treee6dc34a67e75585ed0125e133d6c7bc8e21dc2d4 /pyecsca/ec
parentb003b1d2437b842beafca0f13bea368c92a422fe (diff)
downloadpyecsca-58b3e0f862ab13f7125d40c9360b4b348366370a.tar.gz
pyecsca-58b3e0f862ab13f7125d40c9360b4b348366370a.tar.zst
pyecsca-58b3e0f862ab13f7125d40c9360b4b348366370a.zip
Add ZVP formula unroll.
Diffstat (limited to 'pyecsca/ec')
-rw-r--r--pyecsca/ec/formula.py1
-rw-r--r--pyecsca/ec/mod.py10
2 files changed, 5 insertions, 6 deletions
diff --git a/pyecsca/ec/formula.py b/pyecsca/ec/formula.py
index 267aba0..7855622 100644
--- a/pyecsca/ec/formula.py
+++ b/pyecsca/ec/formula.py
@@ -40,6 +40,7 @@ class OpResult:
return self.name
def __repr__(self):
+ # TODO: This repr is broken for square and neg and inv.
char = self.op.op_str
parents = char.join(str(parent) for parent in self.parents)
return f"{self.name} = {parents}"
diff --git a/pyecsca/ec/mod.py b/pyecsca/ec/mod.py
index 2d0893c..301bd70 100644
--- a/pyecsca/ec/mod.py
+++ b/pyecsca/ec/mod.py
@@ -10,7 +10,7 @@ dispatches to the implementation chosen by the runtime configuration of the libr
import random
import secrets
from functools import wraps, lru_cache
-from typing import Type, Dict, Any, Tuple, Union
+from typing import Type, Dict, Any, Tuple, Union, Optional
from public import public
from sympy import Expr, FF
@@ -564,13 +564,11 @@ class SymbolicMod(Mod):
return hash(("SymbolicMod", self.x, self.n))
def __pow__(self, n) -> "SymbolicMod":
- try:
- x = pow(self.x, n, self.n)
- except TypeError:
- x = pow(self.x, n) % self.n
- return SymbolicMod(x, self.n)
+ return self.__class__(pow(self.x, n), self.n)
+_mod_classes["symbolic"] = SymbolicMod
+
if has_gmp:
@lru_cache