From 06928b6e90078d72c2fda44b0accd07f522b9450 Mon Sep 17 00:00:00 2001 From: latent-9 <296084221+latent-9@users.noreply.github.com> Date: Sat, 22 Aug 2026 13:38:37 +1200 Subject: [PATCH] test(ed25519-verify): add mixed-order strict-parity regression vectors Fold order-2 and order-4 torsion into prime-order public keys and assert the cofactorless strict preset agrees with ed25519-dalek's verify_strict on them. These vectors fail on the code before the runtime scalar negation was removed (PR #10) and pass on main. The maintainer fix replaces scalar::negate with a negated basepoint constant; these vectors lock in that parity behavior. --- ed25519-verify/tests/verify_instruction.rs | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/ed25519-verify/tests/verify_instruction.rs b/ed25519-verify/tests/verify_instruction.rs index 767730b..64f114c 100644 --- a/ed25519-verify/tests/verify_instruction.rs +++ b/ed25519-verify/tests/verify_instruction.rs @@ -23,6 +23,35 @@ const NON_CANONICAL_SMALL_ORDER_COMPRESSED: [u8; PUBKEY_SERIALIZED_SIZE] = [ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f, ]; +/// Mixed-order verification vectors: an honest prime-order key with a low-order +/// torsion point folded in, so the encoding is neither prime-order nor +/// small-order and slips past the small-order gate into the cofactorless +/// equation. The `A` key carries an order-2 component and the `A4` key an +/// order-4 component. Both signatures are valid ZIP-215 signatures over +/// `MIXED_ORDER_MESSAGE`, so `dalek_verify_strict` and this preset must return +/// the same verdict on them. +const MIXED_ORDER_MESSAGE: &[u8] = b"mixed order strict parity"; +const MIXED_ORDER_A_PUBLIC_KEY: [u8; PUBKEY_SERIALIZED_SIZE] = [ + 0x25, 0x0b, 0x30, 0x28, 0x13, 0x63, 0x7e, 0x1e, 0x93, 0x88, 0xeb, 0xb5, 0xb2, 0xe3, 0x1f, 0x23, + 0x5f, 0xcc, 0x69, 0x9e, 0x20, 0xce, 0xc3, 0x31, 0x46, 0xdf, 0xce, 0xec, 0xb9, 0x70, 0x49, 0xf7, +]; +const MIXED_ORDER_A_SIGNATURE: [u8; SIGNATURE_SERIALIZED_SIZE] = [ + 0x4f, 0xaa, 0x93, 0x76, 0x3d, 0x07, 0x02, 0x31, 0x6d, 0xde, 0xf0, 0x5a, 0x79, 0x21, 0xb3, 0x0b, + 0x30, 0xe8, 0x15, 0x30, 0xb4, 0x4c, 0xf9, 0xf3, 0x57, 0x73, 0xff, 0xee, 0x16, 0xf6, 0x86, 0x38, + 0x84, 0x46, 0xf8, 0x41, 0x77, 0xd7, 0xd8, 0x4e, 0x9d, 0x68, 0xf3, 0xc8, 0xdc, 0x2d, 0x57, 0xe6, + 0x75, 0x5e, 0xe3, 0xa1, 0xa3, 0x6a, 0x07, 0x49, 0x0b, 0xb0, 0xf0, 0x16, 0x76, 0xa7, 0x4e, 0x0e, +]; +const MIXED_ORDER_A4_PUBLIC_KEY: [u8; PUBKEY_SERIALIZED_SIZE] = [ + 0x8c, 0x7e, 0xe4, 0xbc, 0x55, 0x23, 0x75, 0xef, 0xb8, 0xd8, 0x78, 0x97, 0x68, 0xe4, 0x23, 0xeb, + 0xde, 0xfd, 0x6c, 0x40, 0xdd, 0xe6, 0x34, 0x49, 0x78, 0xc2, 0x87, 0x10, 0x54, 0xaa, 0xf0, 0x35, +]; +const MIXED_ORDER_A4_SIGNATURE: [u8; SIGNATURE_SERIALIZED_SIZE] = [ + 0x4f, 0xaa, 0x93, 0x76, 0x3d, 0x07, 0x02, 0x31, 0x6d, 0xde, 0xf0, 0x5a, 0x79, 0x21, 0xb3, 0x0b, + 0x30, 0xe8, 0x15, 0x30, 0xb4, 0x4c, 0xf9, 0xf3, 0x57, 0x73, 0xff, 0xee, 0x16, 0xf6, 0x86, 0x38, + 0xe4, 0xe0, 0xd9, 0xdf, 0x0e, 0x38, 0x15, 0xec, 0x36, 0x74, 0xe3, 0x4a, 0x33, 0x1b, 0x54, 0x99, + 0x22, 0x89, 0x02, 0x7c, 0x81, 0xe8, 0x6d, 0x7f, 0x11, 0xbf, 0x33, 0xb1, 0xba, 0x5b, 0x07, 0x0f, +]; + fn signed_payload( message: &[u8], ) -> ( @@ -436,6 +465,16 @@ fn dalek_verify_strict_preset_matches_dalek() { &SMALL_ORDER_PUBLIC_KEY_COMPRESSED, good_message, ), + ( + &MIXED_ORDER_A_SIGNATURE, + &MIXED_ORDER_A_PUBLIC_KEY, + MIXED_ORDER_MESSAGE, + ), + ( + &MIXED_ORDER_A4_SIGNATURE, + &MIXED_ORDER_A4_PUBLIC_KEY, + MIXED_ORDER_MESSAGE, + ), ]; for (index, (signature, public_key, message)) in cases.iter().enumerate() {