On Wed, 2 Dec 2026 07:15:33 GMT, Shawn Emery <[email protected]> wrote:
>> test/jdk/sun/security/provider/pqc/ML_KEM_Intrinsic_Test.java line 299:
>>
>>> 297: addPolyJava.invoke(sum2, a, b, c);
>>> 298:
>>> 299: if (!Arrays.equals(sum1, sum2)) {
>>
>> These sums will not be equal on AArch64 systems if intrinsics is used given
>> that only `q` is added to the result, whereas in Java `2*q` is added. The
>> sums will still be congruent modulo `q` if we want to check for that
>> instead.
>>
>> Secondly, with the broader ranges used by this test suite intrinsics could
>> also generate a `-q`. During subsequent Barrett reduction this would be
>> reduced to `q`, which would deviate from mlKemAddPoly()'s comments where the
>> resulting output is in the range of [0, q). This boundary case would not
>> occur in production call paths but is possible and reproducible with the
>> test suite's broader input ranges.
>>
>> I'm leaning towards aligning AArch64 intrinsic with current Java behavior.
>> I'll file a bug for this shortly.
>
> Filed: JDK-8398806: Mismatch between ML-KEM's AddPoly_3 output range for
> AArch64 intrinsics vs. Java
I don't mind refactoring the test check.. should had done it like that to begin
with really, should match the mult check: that one _is_ congruent check
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/33444#discussion_r4777014274