Hi Weijun,
Thank you for your response. I'm happy to hear that you are still
looking into JDK-8384521 and that this is close to being completed. Do
you know when this will be available? Will it make it into JDK 28, or
is it more likely to be part of 29? If needed, we are happy to help
with PR #23934, either for reviews or testing.
Regarding the manual X.509 + SHAKE256 assembly, we could still follow
up with a new API for this, once Context + ExternalMu is available.
Asking Java developers to get this right when calculating by hand will
make errors more likely and result in unverifiable signatures. Native
crypto libraries, like BoringSSL, provide dedicated pre-hash APIs (in
mldsa.h's MLDSA{44,65,87}_prehash_{init,update,finalize}) and having
an API that can map to these would mitigate the error-prone nature of
computing mu by hand.
Other libraries, such as Bouncy Castle, rely on wrapping a public key
inside a private key, org.bouncycastle.jcajce.MLDSAProxyPrivateKey, to
pass it to the ML-DSA-CALCULATE-MU signature instance. This is a
workaround specific to Bouncy Castle that is not generic enough to
cover other providers. It would be good to have a JCA abstraction in
place that allows for more consistent usage.
If having an ML-DSA-specific SPI is too specialized, we could define a
general signature pre-hashing API. This API could accept a public key
that will be used for ML-DSA, while other schemes ignore it. Of
course, this would be done as a follow-up, but it would be good to
have it planned. Would you be open to having a separate JBS issue for
the mu API?
Kind regards,
Sorin
On Tue, 3 Nov 2026 at 14:33, Wei-Jun Wang <[email protected]> wrote:
>
> Hi Sorin,
>
> Thanks for your interest in this issue.
>
> > On Oct 29, 2026, at 09:26, Sorin Basca <[email protected]> wrote:
> >
> > Hello,
> >
> > We would like to inquire about picking up the work on JDK-8384521. We
> > see it remains open and that the earlier exploration in PR #23934 was
> > abandoned due to its large scope.
>
> PR #23934 was automatically closed by our bot because of low traffic. I
> already have a code change for JDK-8384521, which introduced the public API
> described there, and the implementation is just a thin shim on PR #23934. It
> has not been posted because PR #23934 is not integrated yet.
>
> >
> > We would like to propose that we move JDK-8384521 forward with a
> > focused scope. This would include the following:
> >
> > 1. Adding MLDSAParameterSpec.ExternalMu and MLDSAParameterSpec.Context
> > for configuring the Signature instances.
>
> >
> > 2. Providing a standard MessageDigest pre-initialized with the public
> > key and context to stream large messages and produce the 64 byte mu.
> > For this we will add MLDSAParameterSpec.DigestBuilder and
> > MLDSAExternalMuDigestSpi.
>
> The second part of your proposal is too focused on this single usage and does
> not seem to warrant an API, let alone an API/SPI pair that needs to be
> implemented in providers. Calculating it, as you said below, is a little
> delicate but still doable. IMHO, the only tricky part is to find the raw
> public key to calculate tr if one only has the X.509 getEncoded() value of
> the public key. We know there are only 3 standard parameter sets for ML-DSA,
> so the extraction is merely comparing the first few bytes of the public key
> X.509 encoding to 3 known byte sequences and the rest (if the length is
> correct) is the raw public key.
>
> Thank you for offering to contribute but we have already completed most of
> this work. We will continue.
>
> Thanks,
> Weijun
>
> >
> > 3. Complete implementation in the SUN provider.
> >
> > We are aware that mu can be computed by hand with
> > MessageDigest.getInstance("SHAKE256-512") running over tr || 0x00 ||
> > len(ctx) || ctx || M. However, this is error-prone as callers need to
> > perform several steps and a mistake would produce a signature that
> > fails to verify. The typed API would allow providers that already
> > compute mu natively to plug in their own implementation.
> >
> > We are raising this because we have encountered a critical requirement
> > for signing with an externally computed message representative mu when
> > deploying ML-DSA across hardware and isolated cryptographic modules.
> >
> > We have a clean, tested prototype ready and would like to know if you
> > would welcome our help in driving JDK-8384521 forward and whether this
> > scoped design would meet your expectations.
> >
> > Many thanks,
> > Sorin Basca (on behalf of the Google Java Platform & ISE Crypto teams)
>