From f4cae188c430e51ed80be7a7e2c36aa0b6bd5ca5 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Mon, 29 Dec 2025 23:25:15 +0100 Subject: [PATCH] Add extra scalarmult tests --- test/default/scalarmult_ed25519.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/default/scalarmult_ed25519.c b/test/default/scalarmult_ed25519.c index 795647b5..58de56cf 100644 --- a/test/default/scalarmult_ed25519.c +++ b/test/default/scalarmult_ed25519.c @@ -13,6 +13,10 @@ static const unsigned char max_canonical_p[32] = { 0xe4, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f }; +static const unsigned char not_main_subgroup_p[32] = { + 0x95, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, + 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99 +}; static const unsigned char B[32] = { 0x58, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, @@ -69,9 +73,15 @@ main(void) if (crypto_scalarmult_ed25519(q, n, non_canonical_invalid_p) != -1) { printf("crypto_scalarmult_ed25519() didn't fail\n"); } + if (crypto_scalarmult_ed25519(q, n, not_main_subgroup_p) != -1) { + printf("crypto_scalarmult_ed25519() didn't fail (non-subgroup)\n"); + } if (crypto_scalarmult_ed25519(q, n, max_canonical_p) != 0) { printf("crypto_scalarmult_ed25519() failed\n"); } + if (crypto_scalarmult_ed25519_noclamp(q, n, not_main_subgroup_p) != -1) { + printf("crypto_scalarmult_ed25519_noclamp() didn't fail (non-subgroup)\n"); + } n[0] = 9; if (crypto_scalarmult_ed25519(q, n, p) != 0) {