diff --git a/CPA.ipynb b/CPA.ipynb index 019c672..bc5a1e3 100644 --- a/CPA.ipynb +++ b/CPA.ipynb @@ -28,7 +28,7 @@ "outputs": [], "source": [ "from pyecsca.ec.mult import LTRMultiplier\n", - "from pyecsca.ec.mod import Mod\n", + "from pyecsca.ec.mod import mod\n", "from pyecsca.ec.point import Point, InfinityPoint\n", "from pyecsca.ec.model import ShortWeierstrassModel\n", "from pyecsca.ec.curve import EllipticCurve\n", @@ -80,11 +80,11 @@ "model = ShortWeierstrassModel()\n", "coords = model.coordinates[\"projective\"]\n", "p = 0xd7d1247f\n", - "a = Mod(0xa4a44016, p)\n", - "b = Mod(0x73f76716, p)\n", + "a = mod(0xa4a44016, p)\n", + "b = mod(0x73f76716, p)\n", "n = 0xd7d2a475\n", "h = 1\n", - "gx, gy, gz = Mod(0x54eed6d7, p), Mod(0x6f1e55ac, p), Mod(1, p)\n", + "gx, gy, gz = mod(0x54eed6d7, p), mod(0x6f1e55ac, p), mod(1, p)\n", "generator = Point(coords, X=gx, Y=gy, Z=gz)\n", "neutral = InfinityPoint(coords)\n", "\n", diff --git a/DPA.ipynb b/DPA.ipynb index e11dc47..3b5a455 100644 --- a/DPA.ipynb +++ b/DPA.ipynb @@ -28,7 +28,7 @@ "outputs": [], "source": [ "from pyecsca.ec.mult import LTRMultiplier\n", - "from pyecsca.ec.mod import Mod\n", + "from pyecsca.ec.mod import mod\n", "from pyecsca.ec.point import Point, InfinityPoint\n", "from pyecsca.ec.model import ShortWeierstrassModel\n", "from pyecsca.ec.curve import EllipticCurve\n", @@ -76,11 +76,11 @@ "model = ShortWeierstrassModel()\n", "coords = model.coordinates[\"projective\"]\n", "p = 0xd7d1247f\n", - "a = Mod(0xa4a44016, p)\n", - "b = Mod(0x73f76716, p)\n", + "a = mod(0xa4a44016, p)\n", + "b = mod(0x73f76716, p)\n", "n = 0xd7d2a475\n", "h = 1\n", - "gx, gy, gz = Mod(0x54eed6d7, p), Mod(0x6f1e55ac, p), Mod(1, p)\n", + "gx, gy, gz = mod(0x54eed6d7, p), mod(0x6f1e55ac, p), mod(1, p)\n", "generator = Point(coords, X=gx, Y=gy, Z=gz)\n", "neutral = InfinityPoint(coords)\n", "\n", diff --git a/emulator.ipynb b/emulator.ipynb index fb9172e..3a1f32a 100644 --- a/emulator.ipynb +++ b/emulator.ipynb @@ -28,7 +28,7 @@ "outputs": [], "source": [ "from pyecsca.ec.mult import LTRMultiplier\n", - "from pyecsca.ec.mod import Mod\n", + "from pyecsca.ec.mod import mod\n", "from pyecsca.ec.point import Point, InfinityPoint\n", "from pyecsca.ec.model import ShortWeierstrassModel\n", "from pyecsca.ec.curve import EllipticCurve\n", @@ -74,11 +74,11 @@ "model = ShortWeierstrassModel()\n", "coords = model.coordinates[\"projective\"]\n", "p = 0xd7d1247f\n", - "a = Mod(0xa4a44016, p)\n", - "b = Mod(0x73f76716, p)\n", + "a = mod(0xa4a44016, p)\n", + "b = mod(0x73f76716, p)\n", "n = 0xd7d2a475\n", "h = 1\n", - "gx, gy, gz = Mod(0x54eed6d7, p), Mod(0x6f1e55ac, p), Mod(1, p)\n", + "gx, gy, gz = mod(0x54eed6d7, p), mod(0x6f1e55ac, p), mod(1, p)\n", "generator = Point(coords, X=gx, Y=gy, Z=gz)\n", "neutral = InfinityPoint(coords)\n", "\n", diff --git a/re/epa.ipynb b/re/epa.ipynb index 3e50deb..6fa25c6 100644 --- a/re/epa.ipynb +++ b/re/epa.ipynb @@ -34,7 +34,7 @@ "from pyecsca.ec.coordinates import AffineCoordinateModel\n", "from pyecsca.ec.curve import EllipticCurve\n", "from pyecsca.ec.params import DomainParameters, load_params_ectester\n", - "from pyecsca.ec.mod import Mod, miller_rabin, gcd\n", + "from pyecsca.ec.mod import mod, miller_rabin, gcd\n", "from pyecsca.ec.point import Point, InfinityPoint\n", "from pyecsca.ec.error import NonInvertibleError\n", "from pyecsca.ec.mult import LTRMultiplier, AccumulationOrder\n", @@ -155,8 +155,8 @@ " factors = list(results.keys())\n", " xs = list(map(lambda factor: int(results[factor].x), factors))\n", " ys = list(map(lambda factor: int(results[factor].y), factors))\n", - " res_x = Mod(int(crt(factors, xs)[0]), top.curve.prime)\n", - " res_y = Mod(int(crt(factors, ys)[0]), top.curve.prime)\n", + " res_x = mod(int(crt(factors, xs)[0]), top.curve.prime)\n", + " res_y = mod(int(crt(factors, ys)[0]), top.curve.prime)\n", " res = Point(affine, x=res_x, y=res_y)\n", " return res.to_model(top.curve.coordinate_model, top.curve, randomized=randomized)" ] @@ -178,7 +178,7 @@ "source": [ "def project_down(point, subcurve):\n", " \"\"\"Project a point down onto a subcurve.\"\"\"\n", - " return Point(subcurve.coordinate_model, **{name: Mod(int(value), subcurve.prime) for name, value in point.coords.items()})\n", + " return Point(subcurve.coordinate_model, **{name: mod(int(value), subcurve.prime) for name, value in point.coords.items()})\n", "\n", "def split_params(params):\n", " \"\"\"Split composite \"p\" params into subcurves.\"\"\"\n", @@ -189,7 +189,7 @@ " # Construct the curves\n", " for factor in sorted(factors.keys()):\n", " p_i = factor\n", - " parameters_i = {name: Mod(int(value), p_i) for name, value in params.curve.parameters.items()}\n", + " parameters_i = {name: mod(int(value), p_i) for name, value in params.curve.parameters.items()}\n", " curve_i = EllipticCurve(params.curve.model, params.curve.coordinate_model, p_i, params.curve.neutral, parameters_i)\n", " generator_i = project_down(params.generator, curve_i)\n", " params_i = DomainParameters(curve_i, generator_i, 0, 1)\n", @@ -225,8 +225,8 @@ " factors = list(results.keys())\n", " xs = list(map(lambda factor: int(results[factor].x), factors))\n", " ys = list(map(lambda factor: int(results[factor].y), factors))\n", - " res_x = Mod(int(crt(factors, xs)[0]), top.curve.prime)\n", - " res_y = Mod(int(crt(factors, ys)[0]), top.curve.prime)\n", + " res_x = mod(int(crt(factors, xs)[0]), top.curve.prime)\n", + " res_y = mod(int(crt(factors, ys)[0]), top.curve.prime)\n", " return Point(affine, x=res_x, y=res_y)" ] }, diff --git a/re/rpa.ipynb b/re/rpa.ipynb index 3411ca2..6f62c34 100644 --- a/re/rpa.ipynb +++ b/re/rpa.ipynb @@ -45,7 +45,7 @@ "from pyecsca.ec.params import DomainParameters, get_params\n", "from pyecsca.ec.formula import FormulaAction\n", "from pyecsca.ec.point import Point\n", - "from pyecsca.ec.mod import Mod\n", + "from pyecsca.ec.mod import mod\n", "from pyecsca.ec.mult import *\n", "from pyecsca.misc.utils import silent, TaskExecutor\n", "from pyecsca.sca.trace.sampling import downsample_average, downsample_max\n", @@ -94,18 +94,18 @@ "\n", "# A 64-bit prime order curve for testing things out\n", "p = 0xc50de883f0e7b167\n", - "a = Mod(0x4833d7aa73fa6694, p)\n", - "b = Mod(0xa6c44a61c5323f6a, p)\n", - "gx = Mod(0x5fd1f7d38d4f2333, p)\n", - "gy = Mod(0x21f43957d7e20ceb, p)\n", + "a = mod(0x4833d7aa73fa6694, p)\n", + "b = mod(0xa6c44a61c5323f6a, p)\n", + "gx = mod(0x5fd1f7d38d4f2333, p)\n", + "gy = mod(0x21f43957d7e20ceb, p)\n", "n = 0xc50de885003b80eb\n", "h = 1\n", "\n", "# A (0, y) RPA point on the above curve, in affine coords.\n", - "P0_aff = Point(coordsaff, x=Mod(0, p), y=Mod(0x1742befa24cd8a0d, p))\n", + "P0_aff = Point(coordsaff, x=mod(0, p), y=mod(0x1742befa24cd8a0d, p))\n", "\n", - "infty = Point(coords, X=Mod(0, p), Y=Mod(1, p), Z=Mod(0, p))\n", - "g = Point(coords, X=gx, Y=gy, Z=Mod(1, p))\n", + "infty = Point(coords, X=mod(0, p), Y=mod(1, p), Z=mod(0, p))\n", + "g = Point(coords, X=gx, Y=gy, Z=mod(1, p))\n", "\n", "curve = EllipticCurve(model, coords, p, infty, dict(a=a,b=b))\n", "params = DomainParameters(curve, g, n, h)\n", @@ -225,7 +225,7 @@ "outputs": [], "source": [ "k = 108\n", - "kinv = Mod(k, n).inverse()\n", + "kinv = mod(k, n).inverse()\n", "P0_target = curve.affine_multiply(P0_aff, int(kinv)).to_model(coords, curve)\n", "\n", "print(\"Original P0\", P0_aff)\n", diff --git a/re/structural.ipynb b/re/structural.ipynb index 1006b62..0ce8dd1 100644 --- a/re/structural.ipynb +++ b/re/structural.ipynb @@ -30,7 +30,7 @@ "from pyecsca.ec.formula import FormulaAction\n", "from pyecsca.ec.op import OpType\n", "from pyecsca.ec.point import Point\n", - "from pyecsca.ec.mod import Mod\n", + "from pyecsca.ec.mod import mod\n", "from pyecsca.ec.mult import *\n", "from pyecsca.ec.context import DefaultContext, local\n", "from pyecsca.sca.re.rpa import MultipleContext\n", @@ -65,15 +65,15 @@ "\n", "# A 64-bit prime order curve for testing things out\n", "p = 0xc50de883f0e7b167\n", - "a = Mod(0x4833d7aa73fa6694, p)\n", - "b = Mod(0xa6c44a61c5323f6a, p)\n", - "gx = Mod(0x5fd1f7d38d4f2333, p)\n", - "gy = Mod(0x21f43957d7e20ceb, p)\n", + "a = mod(0x4833d7aa73fa6694, p)\n", + "b = mod(0xa6c44a61c5323f6a, p)\n", + "gx = mod(0x5fd1f7d38d4f2333, p)\n", + "gy = mod(0x21f43957d7e20ceb, p)\n", "n = 0xc50de885003b80eb\n", "h = 1\n", "\n", - "infty = Point(coords, X=Mod(0, p), Y=Mod(1, p), Z=Mod(0, p))\n", - "g = Point(coords, X=gx, Y=gy, Z=Mod(1, p))\n", + "infty = Point(coords, X=mod(0, p), Y=mod(1, p), Z=mod(0, p))\n", + "g = Point(coords, X=gx, Y=gy, Z=mod(1, p))\n", "\n", "curve = EllipticCurve(model, coords, p, infty, dict(a=a,b=b))\n", "params = DomainParameters(curve, g, n, h)" diff --git a/re/zvp.ipynb b/re/zvp.ipynb index c406a28..1c4a65e 100644 --- a/re/zvp.ipynb +++ b/re/zvp.ipynb @@ -60,7 +60,7 @@ "from pyecsca.ec.params import DomainParameters, load_params_ecgen\n", "from pyecsca.ec.formula import FormulaAction, AdditionFormula, DoublingFormula\n", "from pyecsca.ec.point import Point\n", - "from pyecsca.ec.mod import Mod, gcd, SymbolicMod\n", + "from pyecsca.ec.mod import mod, gcd, SymbolicMod\n", "from pyecsca.ec.context import DefaultContext, local\n", "from pyecsca.ec.mult import LTRMultiplier, AccumulationOrder\n", "from pyecsca.ec.error import NonInvertibleError, UnsatisfiedAssumptionError\n", @@ -152,8 +152,8 @@ "n = 0xc50de885003b80eb\n", "h = 1\n", "\n", - "infty = Point(coords, X=Mod(0, p), Y=Mod(1, p), Z=Mod(0, p))\n", - "g = Point(coords, X=gx, Y=gy, Z=Mod(1, p))\n", + "infty = Point(coords, X=mod(0, p), Y=mod(1, p), Z=mod(0, p))\n", + "g = Point(coords, X=gx, Y=gy, Z=mod(1, p))\n", "\n", "curve = EllipticCurve(model, coords, p, infty, dict(a=a,b=b))\n", "params = DomainParameters(curve, g, n, h)\n", @@ -518,7 +518,7 @@ " k = ks[0]\n", " else:\n", " # zvp_points assumes (P, [k]P)\n", - " ks_mod = list(map(lambda v: Mod(v, params.order), ks))\n", + " ks_mod = list(map(lambda v: mod(v, params.order), ks))\n", " k = int(ks_mod[1] / ks_mod[0])\n", " polys = polynomials[params][op]\n", " for poly in polys:\n",