From 2aec35feb5943e65f7bd823815fee11d30384172 Mon Sep 17 00:00:00 2001 From: suimins Date: Thu, 26 Nov 2026 13:16:03 +0900 Subject: [PATCH] ml-kem: check the shared secret and ek in the semi-expanded decapsulation test In mlkem_decaps_test!, the decapsulated shared secret was discarded (let _ss = dk.decapsulate(&test_c);) and ek was not compared against dk.encapsulation_key(). Update thirdparty/wycheproof from ad6ac186a990 to ee7b4f7e6119 (which adds K and ek to the semi-expanded decapsulation vectors), compare ek after importing dk, assert ExpectedResult::Valid on decapsulation, and compare the returned shared secret with K. --- ml-kem/tests/wycheproof.rs | 9 ++++++++- thirdparty/wycheproof | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ml-kem/tests/wycheproof.rs b/ml-kem/tests/wycheproof.rs index 8882baee..232bc7af 100644 --- a/ml-kem/tests/wycheproof.rs +++ b/ml-kem/tests/wycheproof.rs @@ -248,6 +248,10 @@ macro_rules! mlkem_decaps_test { continue; } let dk = dk_result.unwrap(); + assert_eq!( + test.ek.as_slice(), + dk.encapsulation_key().to_bytes().as_slice() + ); let test_c: Ciphertext = match decode_optional_hex(&test.c, "c") { Some(dk) => dk, @@ -257,7 +261,10 @@ macro_rules! mlkem_decaps_test { } }; - let _ss = dk.decapsulate(&test_c); + assert_eq!(test.result, ExpectedResult::Valid); + let ss = dk.decapsulate(&test_c); + let expected: ml_kem::SharedKey = decode_expected_hex(&test.k, "K"); + assert_eq!(expected, ss); } } } diff --git a/thirdparty/wycheproof b/thirdparty/wycheproof index ad6ac186..ee7b4f7e 160000 --- a/thirdparty/wycheproof +++ b/thirdparty/wycheproof @@ -1 +1 @@ -Subproject commit ad6ac186a990529963a1750e2aaa120f5f289cbc +Subproject commit ee7b4f7e611928cbe163dc6f5e54527bfd166f34