aboutsummaryrefslogtreecommitdiffhomepage
path: root/pyecsca/ec
diff options
context:
space:
mode:
authorJ08nY2023-02-12 19:27:45 +0100
committerJ08nY2023-02-12 19:27:45 +0100
commitc346e7bba997a26badfa4bbe7fad2c4fcb067a17 (patch)
tree40505de29aade49236f1f4eabc4774cf0575e92b /pyecsca/ec
parent7421fce192b581d732eabf4b2948bd8546b4afea (diff)
downloadpyecsca-c346e7bba997a26badfa4bbe7fad2c4fcb067a17.tar.gz
pyecsca-c346e7bba997a26badfa4bbe7fad2c4fcb067a17.tar.zst
pyecsca-c346e7bba997a26badfa4bbe7fad2c4fcb067a17.zip
Save an unnecessary cast in GMPMod.
Diffstat (limited to 'pyecsca/ec')
-rw-r--r--pyecsca/ec/mod.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/pyecsca/ec/mod.py b/pyecsca/ec/mod.py
index add7581..52f4a80 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
+from typing import Type, Dict, Any, Tuple, Union
from public import public
from sympy import Expr, FF
@@ -584,9 +584,9 @@ if has_gmp:
def __new__(cls, *args, **kwargs):
return object.__new__(cls)
- def __init__(self, x: int, n: int):
- self.x = gmpy2.mpz(x % n)
- self.n = gmpy2.mpz(n)
+ def __init__(self, x: Union[int, gmpy2.mpz], n: Union[int, gmpy2.mpz]):
+ self.n = gmpy2.mpz(n) if not isinstance(n, gmpy2.mpz) else n
+ self.x = gmpy2.mpz(x % self.n) if not isinstance(x, gmpy2.mpz) else x % self.n
def inverse(self) -> "GMPMod":
if self.x == 0: