aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorJ08nY2023-11-24 16:41:09 +0100
committerJ08nY2023-11-24 16:41:09 +0100
commitf287c07f693ffd21a2ba9399f4006e348cbb0d10 (patch)
tree6c8b9468c05126cf0b17ef53213acf88aa4b7ad6 /test
parented091bddcec83ec4a292ce6faa0151e6f00efcb5 (diff)
downloadpyecsca-f287c07f693ffd21a2ba9399f4006e348cbb0d10.tar.gz
pyecsca-f287c07f693ffd21a2ba9399f4006e348cbb0d10.tar.zst
pyecsca-f287c07f693ffd21a2ba9399f4006e348cbb0d10.zip
Add Botan x25519 ladder (from curve25519_donna).
Diffstat (limited to 'test')
-rw-r--r--test/data/formulas/ladd-botan-x255194
-rw-r--r--test/data/formulas/ladd-botan-x25519.op318
-rw-r--r--test/sca/test_structural.py7
3 files changed, 29 insertions, 0 deletions
diff --git a/test/data/formulas/ladd-botan-x25519 b/test/data/formulas/ladd-botan-x25519
new file mode 100644
index 0000000..ae1571d
--- /dev/null
+++ b/test/data/formulas/ladd-botan-x25519
@@ -0,0 +1,4 @@
+source Botan 3.2.0 https://github.com/randombit/botan/blob/3.2.0/src/lib/pubkey/curve25519/donna.cpp#L299
+coords xz
+parameter am24
+assume am24 = (a-2)/4
diff --git a/test/data/formulas/ladd-botan-x25519.op3 b/test/data/formulas/ladd-botan-x25519.op3
new file mode 100644
index 0000000..b375514
--- /dev/null
+++ b/test/data/formulas/ladd-botan-x25519.op3
@@ -0,0 +1,18 @@
+Z1new = X2 - Z2
+X1new = X2 + Z2
+Z2new = X3 - Z3
+X2new = X3 + Z3
+xxprime = X2new * Z1new
+zzprime = Z2new * X1new
+zzprime_new = xxprime - zzprime
+xxprime_new = xxprime + zzprime
+X5 = xxprime_new^2
+zzzprime = zzprime_new^2
+Z5 = zzzprime * X1
+xx = X1new^2
+zz = Z1new^2
+X4 = xx * zz
+zz = xx - zz
+zzz = zz * am24
+zzz = zzz + xx
+Z4 = zz * zzz
diff --git a/test/sca/test_structural.py b/test/sca/test_structural.py
index b323f58..970e4fc 100644
--- a/test/sca/test_structural.py
+++ b/test/sca/test_structural.py
@@ -238,6 +238,13 @@ def test_formula_similarity(secp128r1):
("other", "Curve25519"),
DoublingEFDFormula,
],
+ [
+ "ladd-botan-x25519",
+ MontgomeryModel,
+ "xz",
+ ("other", "Curve25519"),
+ LadderEFDFormula,
+ ],
],
)
def test_formula_correctness(name, model, coords, param_spec, formula_type):