aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ08nY2024-01-31 15:57:01 +0100
committerJ08nY2024-01-31 15:57:01 +0100
commit5f0f074e3d8fe8362ebf558c25775961d8af92c2 (patch)
treeefa537e6a3c96c451e2ad46e54482f5e1c4564b8
parentf1175521cc2d56355887ee25347238d2e28717b1 (diff)
downloadpyecsca-5f0f074e3d8fe8362ebf558c25775961d8af92c2.tar.gz
pyecsca-5f0f074e3d8fe8362ebf558c25775961d8af92c2.tar.zst
pyecsca-5f0f074e3d8fe8362ebf558c25775961d8af92c2.zip
-rw-r--r--pyecsca/ec/coordinates.py2
-rw-r--r--pyecsca/ec/divpoly.py6
-rw-r--r--pyecsca/ec/formula/efd.py2
-rw-r--r--pyecsca/ec/formula/expand.py2
4 files changed, 9 insertions, 3 deletions
diff --git a/pyecsca/ec/coordinates.py b/pyecsca/ec/coordinates.py
index f15a64b..f356b66 100644
--- a/pyecsca/ec/coordinates.py
+++ b/pyecsca/ec/coordinates.py
@@ -6,7 +6,7 @@ from typing import List, Any, MutableMapping
from public import public
-from .formula import Formula
+from .formula.base import Formula
from .formula.efd import (
EFDFormula,
AdditionEFDFormula,
diff --git a/pyecsca/ec/divpoly.py b/pyecsca/ec/divpoly.py
index 9956335..798bffd 100644
--- a/pyecsca/ec/divpoly.py
+++ b/pyecsca/ec/divpoly.py
@@ -249,6 +249,12 @@ if has_pari:
def mult_by_n_pari(curve: EllipticCurve, n: int):
pari = cypari2.Pari()
+ # Magic heuristic, plus some constant term for very small polys
+ stacksize = 2 * (n**2 * (40 * curve.prime.bit_length())) + 1000000
+ stacksizemax = 15 * stacksize
+
+ pari.default("debugmem", 0) # silence stack warnings
+ pari.allocatemem(stacksize, stacksizemax, silent=True)
p = pari(curve.prime)
a = pari.Mod(curve.parameters["a"], p)
b = pari.Mod(curve.parameters["b"], p)
diff --git a/pyecsca/ec/formula/efd.py b/pyecsca/ec/formula/efd.py
index edf64de..b74b504 100644
--- a/pyecsca/ec/formula/efd.py
+++ b/pyecsca/ec/formula/efd.py
@@ -6,7 +6,7 @@ from public import public
from importlib_resources.abc import Traversable
from typing import Any
-from . import CodeFormula
+from .code import CodeFormula
from .base import (
Formula,
CodeOp,
diff --git a/pyecsca/ec/formula/expand.py b/pyecsca/ec/formula/expand.py
index 638fcfc..acaf7ea 100644
--- a/pyecsca/ec/formula/expand.py
+++ b/pyecsca/ec/formula/expand.py
@@ -1,7 +1,7 @@
from typing import Set, Callable, Any
from public import public
-from . import Formula
+from .base import Formula
from .efd import EFDFormula
from .fliparoo import recursive_fliparoo
from .metrics import ivs_norm