aboutsummaryrefslogtreecommitdiffhomepage
path: root/pyecsca/ec/mod
diff options
context:
space:
mode:
authorJ08nY2024-07-16 15:46:55 +0200
committerJ08nY2024-07-16 15:46:55 +0200
commit8b3999171f5578c12bc7843dc01b0d27f9be54dd (patch)
treec982e67a94328d2f4dbee9aa69c88d72e0623b4f /pyecsca/ec/mod
parentac4b70b8bf6b202168959766410c7965f30b614a (diff)
downloadpyecsca-8b3999171f5578c12bc7843dc01b0d27f9be54dd.tar.gz
pyecsca-8b3999171f5578c12bc7843dc01b0d27f9be54dd.tar.zst
pyecsca-8b3999171f5578c12bc7843dc01b0d27f9be54dd.zip
Fix pow in Mod.
Diffstat (limited to 'pyecsca/ec/mod')
-rw-r--r--pyecsca/ec/mod/base.py9
-rw-r--r--pyecsca/ec/mod/flint.py2
-rw-r--r--pyecsca/ec/mod/gmp.py2
-rw-r--r--pyecsca/ec/mod/raw.py2
-rw-r--r--pyecsca/ec/mod/symbolic.py2
-rw-r--r--pyecsca/ec/mod/test.pyx11
6 files changed, 8 insertions, 20 deletions
diff --git a/pyecsca/ec/mod/base.py b/pyecsca/ec/mod/base.py
index 7893096..7d21f27 100644
--- a/pyecsca/ec/mod/base.py
+++ b/pyecsca/ec/mod/base.py
@@ -259,7 +259,7 @@ class Mod:
with RandomModAction(n) as action:
return action.exit(mod(secrets.randbelow(n), n))
- def __pow__(self, n) -> "Mod":
+ def __pow__(self, n, _=None) -> "Mod":
return NotImplemented
def __str__(self):
@@ -272,11 +272,10 @@ class Undefined(Mod):
__slots__ = ("x", "n")
- def __new__(cls, *args, **kwargs):
- return object.__new__(cls)
-
def __init__(self):
super().__init__(None, None)
+ self.x = None
+ self.n = None
def __add__(self, other):
return NotImplemented
@@ -344,7 +343,7 @@ class Undefined(Mod):
def __hash__(self):
return hash("Undefined") + 1
- def __pow__(self, n):
+ def __pow__(self, n, _=None):
return NotImplemented
diff --git a/pyecsca/ec/mod/flint.py b/pyecsca/ec/mod/flint.py
index 47c3c04..d5fd432 100644
--- a/pyecsca/ec/mod/flint.py
+++ b/pyecsca/ec/mod/flint.py
@@ -208,7 +208,7 @@ if has_flint:
def __hash__(self):
return hash(("FlintMod", self.x, self.n))
- def __pow__(self, n) -> "FlintMod":
+ def __pow__(self, n, _=None) -> "FlintMod":
if type(n) not in (int, flint.fmpz):
raise TypeError
if n == 0:
diff --git a/pyecsca/ec/mod/gmp.py b/pyecsca/ec/mod/gmp.py
index cdeb3b0..87301c0 100644
--- a/pyecsca/ec/mod/gmp.py
+++ b/pyecsca/ec/mod/gmp.py
@@ -155,7 +155,7 @@ if has_gmp:
def __hash__(self):
return hash(("GMPMod", self.x, self.n))
- def __pow__(self, n) -> "GMPMod":
+ def __pow__(self, n, _=None) -> "GMPMod":
if type(n) not in (int, gmpy2.mpz):
raise TypeError
if n == 0:
diff --git a/pyecsca/ec/mod/raw.py b/pyecsca/ec/mod/raw.py
index 5f4c78c..90e0f9d 100644
--- a/pyecsca/ec/mod/raw.py
+++ b/pyecsca/ec/mod/raw.py
@@ -99,7 +99,7 @@ class RawMod(Mod):
def __hash__(self):
return hash(("RawMod", self.x, self.n))
- def __pow__(self, n) -> "RawMod":
+ def __pow__(self, n, _=None) -> "RawMod":
if type(n) is not int:
raise TypeError
if n == 0:
diff --git a/pyecsca/ec/mod/symbolic.py b/pyecsca/ec/mod/symbolic.py
index 0c8a4ba..57e7233 100644
--- a/pyecsca/ec/mod/symbolic.py
+++ b/pyecsca/ec/mod/symbolic.py
@@ -110,7 +110,7 @@ class SymbolicMod(Mod):
def __hash__(self):
return hash(("SymbolicMod", self.x, self.n))
- def __pow__(self, n) -> "SymbolicMod":
+ def __pow__(self, n, _=None) -> "SymbolicMod":
return self.__class__(pow(self.x, n), self.n)
diff --git a/pyecsca/ec/mod/test.pyx b/pyecsca/ec/mod/test.pyx
deleted file mode 100644
index b8c88d3..0000000
--- a/pyecsca/ec/mod/test.pyx
+++ /dev/null
@@ -1,11 +0,0 @@
-cdef class Test:
- def __init__(self):
- print("here")
-
-cdef class SubTest(Test):
- def __init__(self):
- print("sub init")
-
-cdef class OtherTest(Test):
- def __init__(self):
- print("other init")