| 1 | # ML-DSA signing benchmark targets |
| 2 | |
| 3 | ML-DSA signing applies Fiat-Shamir with Aborts, essentially a form of rejection |
| 4 | sampling, which means that the number of iterations required to produce a valid |
| 5 | signature is a random variable with a geometric distribution. This makes simple |
| 6 | benchmarking techniques ineffective, as the variance of the time taken to |
| 7 | produce a signature is very high and would take an impractically large number of |
| 8 | samples to average out. |
| 9 | |
| 10 | This directory provides a set of ASCII messages that, when all signed |
| 11 | deterministically with an empty context and a key derived from an all-zero seed, |
| 12 | produce signatures that require a statistically representative distribution of |
| 13 | rejections. **The time taken to sign all of them can be divided by the number of |
| 14 | signatures to obtain an accurate average signing time.** (A similar technique |
| 15 | can be used to [benchmark RSA key generation](https://words.filippo.io/rsa-keygen-bench/).) |
| 16 | |
| 17 | The rejection reasons are also represented accurately. The relative distribution |
| 18 | of rejections due to only *z*, only *r₀*, or both *z* and *r₀* are all |
| 19 | representative, so these benchmarks can be used regardless of which rejection |
| 20 | condition is checked first (or even to benchmark the difference). |
| 21 | |
| 22 | The distributions are based on both the formulas in Section 3.4 of |
| 23 | [CRYSTALS-Dilithium – Algorithm Specifications and Supporting Documentation |
| 24 | (Version 3.1)](https://pq-crystals.org/dilithium/data/dilithium-specification-round3-20210208.pdf) |
| 25 | and empirical data. Interestingly, the paper only models rejections due to *z* |
| 26 | or *r₀*, and estimates the remaining ones occur “with probability between 1 and |
| 27 | 2%.” In practice, *ct₀* rejections almost never happen, while *h* rejections |
| 28 | happen with probabilities between 0.44% and 1.43% depending on parameter sets. |
| 29 | However, if we ignore the signatures that are rejected due to both *h* and one |
| 30 | or both of *z* and *r₀* (the latter of which seems to have a 10% positive |
| 31 | correlation with *h*), the chance of hitting an *h* rejection goes down to |
| 32 | between 0.06% and 0.29%. They are still accurately represented for completeness. |
| 33 | |
| 34 | Alternate sets generated with the same process are provided. They can be used to |
| 35 | verify the benchmark is implemented correctly: if replacing the original set |
| 36 | with the alternate set leads to the same overall timings, the benchmark is |
| 37 | correct. (This also serves as a test of the dataset generation process itself.) |
| 38 | |
| 39 | The generator is included, although it requires a patched version of the Go |
| 40 | ML-DSA test suite (or another program capable of rapidly generating signatures |
| 41 | and reporting all the rejection checks they fail). |