-
Notifications
You must be signed in to change notification settings - Fork 301
Add ML-DSA test vectors (FIPS 204 standard). #146
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
@gendx Was it intentional to put the test vectors in the schema dir? I think we'd probably want them in |
@cpu No that was a typo. Moved them to the suitable directory now :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't done a deep dive on the test vector content yet, but had some feedback on the schemas and splitting these up further based on which have seeds available. I also filed #147 to remind myself to put more of this into docs.
Thanks for picking this up again. I hope we can get it merged sooner than later.
"$ref": "#/definitions/MlDsaSignTestVector" | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For each object in your new schemas can you please add additionalProperties: false
to avoid allowing extra unspec'd fields, and a required
list with the required fields:
"required": [ ... ],
"additionalProperties": false
"privateSeed": { | ||
"type": "string", | ||
"format": "HexBytes", | ||
"description": "[optional] 32-byte seed that generated the private key (absent if unknown or if the private key is malformed)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's split the tests that don't have a seed from the ones that do at the schema/testcase level instead of making it an optional field in one common test type.
"definitions": { | ||
"MlDsaSignTestGroup": { | ||
"type": "object", | ||
"properties": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add a source
property ref'ing the common.json
definition:
"source": {
"$ref": "common.json#/definitions/Source"
},
"generatorVersion": { | ||
"type": "string", | ||
"description": "the version of the test vectors." | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be marked deprecated "deprecated": true
to match the other schemas. I think it's probably premature to avoid including it all-together (?)
@@ -0,0 +1,98 @@ | |||
{ | |||
"type": "object", | |||
"definitions": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all of my comments from the other schema file also apply here but I won't duplicate them :-)
"sig": { | ||
"type": "string", | ||
"format": "HexBytes", | ||
"description": "The encoded signature (empty in case of failure)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe clearer as:
"description": "The encoded signature (empty in case of failure)" | |
"description": "The encoded signature (empty in case of expected failure)" |
This PR adds test vectors for ML-DSA, for the FIPS 204 standard. It's a restart of #112 without the pre-standard versions (round 3, ipd).
These tests aim to cover the following cases:
s1
ors2
vectors out of the[-eta, eta]
range.t1
component set to zero (allowing trivial forgeries, but the verification algorithm should still accept signatures for this key).z_max
equalsgamma1 - beta - 1
andgamma1 - beta
,r0_max
equalsgamma2 - beta - 1
andgamma2 - beta
,h_ones
equalsomega
andomega + 1
,|ct0|_max
equalsgamma2 - 1
andgamma2
.expand_a
,expand_s
,rej_ntt_poly
andrej_bounded_poly
functions.power_2_round
function: when the remainder (found int0
) is equal to 4096 or -4095,decompose
(viahigh_bits
orlow_bits
): when the conditionr_plus - r_0 = q - 1
happens.Beyond the baseline API, also covered are:
context
value: empty (default), regular length, or context too long.What isn't covered:
Notable difference(s) from the previous pull request (#112):
"algorithm": "ML-DSA-44"
) to make it easier to consume without looking at file names.privateSeed
field) when meaningful and known. It's notably absent for:|ct0|_max
(note that it's possible to generate similar vectors with a known seed but using a lot of brute-force).