aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/ec/test_mult.py
diff options
context:
space:
mode:
authorJ08nY2023-08-24 17:28:41 +0200
committerJ08nY2023-08-24 17:28:41 +0200
commit2bd18931be9a00bcee3e6e1e50de8188b7f15a07 (patch)
tree9a07344ac37e7e797be0c831cd8fd3c0ea1b951d /test/ec/test_mult.py
parentb5801a2acfdd149cdb5b24985992e43afdfb9311 (diff)
downloadpyecsca-2bd18931be9a00bcee3e6e1e50de8188b7f15a07.tar.gz
pyecsca-2bd18931be9a00bcee3e6e1e50de8188b7f15a07.tar.zst
pyecsca-2bd18931be9a00bcee3e6e1e50de8188b7f15a07.zip
Add FixedWindowLTRMultiplier.
Diffstat (limited to 'test/ec/test_mult.py')
-rw-r--r--test/ec/test_mult.py28
1 files changed, 27 insertions, 1 deletions
diff --git a/test/ec/test_mult.py b/test/ec/test_mult.py
index c7edd03..f481148 100644
--- a/test/ec/test_mult.py
+++ b/test/ec/test_mult.py
@@ -9,7 +9,7 @@ from pyecsca.ec.mult import (
WindowNAFMultiplier,
SimpleLadderMultiplier,
DifferentialLadderMultiplier,
- CoronMultiplier,
+ CoronMultiplier, FixedWindowLTRMultiplier,
)
from pyecsca.ec.point import InfinityPoint, Point
from .utils import cartesian
@@ -208,6 +208,20 @@ def test_window_naf(secp128r1, name, add, dbl, neg, width, scale):
assert_pt_equality(res_precompute, res, scale)
+@pytest.mark.parametrize("name,add,dbl,width,scale",
+ [
+ ("scaled", "add-1998-cmo", "dbl-1998-cmo", 5, "z"),
+ ("complete", "add-2016-rcb", "dbl-2016-rcb", 5, None),
+ ("none", "add-1998-cmo", "dbl-1998-cmo", 5, None),
+ ])
+def test_fixed_window(secp128r1, name, add, dbl, width, scale):
+ formulas = get_formulas(secp128r1.curve.coordinate_model, add, dbl, scale)
+ mult = FixedWindowLTRMultiplier(*formulas[:2], width)
+ mult.init(secp128r1, secp128r1.generator)
+ res = mult.multiply(157 * 789)
+ print(res)
+
+
@pytest.mark.parametrize("name,num,add,dbl",
cartesian(
[
@@ -308,6 +322,18 @@ def test_basic_multipliers(secp128r1, name, num, add, dbl):
res_coron = coron.multiply(num)
assert res_coron == res_ltr
+ fixed = FixedWindowLTRMultiplier(
+ secp128r1.curve.coordinate_model.formulas[add],
+ secp128r1.curve.coordinate_model.formulas[dbl],
+ 8,
+ secp128r1.curve.coordinate_model.formulas["z"],
+ )
+ with pytest.raises(ValueError):
+ fixed.multiply(1)
+ fixed.init(secp128r1, secp128r1.generator)
+ res_fixed = fixed.multiply(num)
+ assert res_fixed == res_ltr
+
def test_init_fail(curve25519, secp128r1):
mult = DifferentialLadderMultiplier(