diff options
| author | J08nY | 2021-01-16 03:20:52 +0100 |
|---|---|---|
| committer | J08nY | 2021-01-16 03:20:52 +0100 |
| commit | cb397341f7e7b0647157ca8225d9dbeda14c7d2b (patch) | |
| tree | baba28dbdf860aa6a43ca9ccc91823cb7662a889 /test | |
| parent | b453b249dc25c008db5c069c55e0a51a91e68229 (diff) | |
| download | pyecsca-cb397341f7e7b0647157ca8225d9dbeda14c7d2b.tar.gz pyecsca-cb397341f7e7b0647157ca8225d9dbeda14c7d2b.tar.zst pyecsca-cb397341f7e7b0647157ca8225d9dbeda14c7d2b.zip | |
Add Context for tracing multiples, usable for RPA.
Diffstat (limited to 'test')
| -rw-r--r-- | test/sca/test_rpa.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/sca/test_rpa.py b/test/sca/test_rpa.py new file mode 100644 index 0000000..b442ce2 --- /dev/null +++ b/test/sca/test_rpa.py @@ -0,0 +1,31 @@ +from unittest import TestCase + +from parameterized import parameterized + +from pyecsca.ec.context import local +from pyecsca.ec.mult import LTRMultiplier +from pyecsca.ec.params import get_params +from pyecsca.sca.re.rpa import MultipleContext + + +class MultipleContextTests(TestCase): + + @parameterized.expand([ + ("10", 10), + ("2355498743", 2355498743), + ("325385790209017329644351321912443757746", 325385790209017329644351321912443757746), + ("13613624287328732", 13613624287328732) + ]) + def test_basic(self, name, scalar): + secp128r1 = get_params("secg", "secp128r1", "projective") + base = secp128r1.generator + coords = secp128r1.curve.coordinate_model + add = coords.formulas["add-1998-cmo"] + dbl = coords.formulas["dbl-1998-cmo"] + scl = coords.formulas["z"] + mult = LTRMultiplier(add, dbl, scl, always=False, complete=False, short_circuit=True) + with local(MultipleContext()) as ctx: + mult.init(secp128r1, base) + mult.multiply(scalar) + muls = list(ctx.points.values()) + self.assertEqual(muls[-1], scalar) |
