-
Notifications
You must be signed in to change notification settings - Fork 23
Add support for PreHash ML-DSA #498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
2e2aa6e
to
1d14404
Compare
Something that is not yet clear to me is if the pre hashing step should be included in mldsa-native or if it should be performed by the consumer. If one strictly follows the NIST algorithms one should include it. The reason for not including it was that the use case of PreHash ML-DSA is that the message is too large for the signer/verifier to process it internally. I am not sure what we want here. The prospect of including 12 hash functions is not nice. |
I looked into how other crypto libraries are implementing this and it indeed seems to include the hashing internally. This PR will have to change and I will have to add a bunch of hash implementations. Probably going to take SHA-2 from https://github.com/pq-code-package/slhdsa-c. |
NIST provide some more details on this https://csrc.nist.gov/csrc/media/Projects/post-quantum-cryptography/documents/faq/fips204-sec6-03192025.pdf They do mention HashML-DSA:
Exciting stuff, looking forward to reviewing this. This also makes me think, with 3 variants: PureML-DSA, HashML-DSA, ExternalMuML-DSA all as options (plus various |
1d14404
to
227d20e
Compare
This commit adds two functions crypto_sign_signature_pre_hash and crypto_sign_verify_pre_hash implementing the pre-hashing mode of ML-DSA. The message to signed is formatted as 0x01 || ctxlen (1 byte) || ctx || oid || H(m) where H(m) is the pre-hash and oid is the object identifier of the used hash algorithm. The ACVP client is adjusted to support the pre-hashing test cases for SHAKE256. The other hash functions will be added separately. Resolves #39 Signed-off-by: Matthias J. Kannwischer <[email protected]>
Signed-off-by: Matthias J. Kannwischer <[email protected]>
f0beae2
to
06fde00
Compare
Signed-off-by: Matthias J. Kannwischer <[email protected]>
06fde00
to
b28a953
Compare
@jakemas @hanno-becker @rod-chapman Any better ideas? |
This commit adds two functions crypto_sign_signature_pre_hash
and crypto_sign_verify_pre_hash implementing the pre-hashing mode of ML-DSA.
Instead of receiving a message, they receive a pre-hashed message.
Details can be found in Algorithm 4 and 5 in FIPS204.
The message to signed is formatted as
0x01 || ctxlen (1 byte) || ctx || oid || ph
where ph is the pre-hash and oid is the object identifier of the used hash
algorithm.
The ACVP client is adjusted to support the pre-hashing test cases. Note that
the ACVP testvectors only contain the message, not the pre-hash. I opted for
computing the hash in the ACVP Python client as for that we do not have to
add implementations for the 12 hash functions.
CBMC proofs for the new functions are added.