Conversation
Marvin-Beckmann
left a comment
There was a problem hiding this comment.
mostly minor comments, but looks good as an example in general. I feel like the simplifications that you have made compared to the standard should be either collected at one place, or mentioned more explicitly in the documentation
| // qfall-schemes is free software: you can redistribute it and/or modify it under | ||
| // the terms of the Mozilla Public License Version 2.0 as published by the | ||
| // Mozilla Foundation. See <https://mozilla.org/en-US/MPL/2.0/>. | ||
|
|
There was a problem hiding this comment.
The benchmark files never have a file description. Any (doc-) comments that are part of the benchmarks aren't available in the documentation anyway. So, these comments are really "just" for developers.
| //! **WARNING:** This implementation is a toy implementation of the basics below | ||
| //! ML-DSA and is mostly supposed to showcase the prototyping capabilities of the `qFALL` library. | ||
| //! It omits certain strict encoding/decoding constraints, specific byte-level hash prunings, | ||
| //! and NTT-representations defined in FIPS 204. |
There was a problem hiding this comment.
The NTT representations for the ring used here are supported by our library, so it could be worth considering using those in the toy example, if it makes sense
There was a problem hiding this comment.
To optionally introduce NTT for this implementation (by basically using a binary toggle parameter), I'd need to basically give two implementations (one with NTT, one without). This would add significant overhead to each function. Therefore, I'd recommend against it for now. Once our NTT actually outperforms / is eye-to-eye Karatsuba, I'd reconsider.
| /// | ||
| /// Parameters: | ||
| /// - `vector`: The vector of polynomials to be split. | ||
| /// |
There was a problem hiding this comment.
Example missing; for schemes this could be fine. Not gonna comment the same for the other subfunctions
There was a problem hiding this comment.
How about moving these functions to the tools crate as these seem to be reused in other schemes such as Mitaka, etc.
So, there might be value to present them as a "broadly" utilised tool that could be useful for other signature schemes as well.
There was a problem hiding this comment.
More specifically, I'd consider pushing the power2round, decompose, and make_hint, use_hint functions to the tools-crate.
| /// Samples a polynomial with a specific Hamming weight from a seed. | ||
| /// | ||
| /// This generates the challenge polynomial `c` used during signing and verification. | ||
| /// It ensures that exactly `tau` coefficients are set to either `1` or `-1`, | ||
| /// and all other coefficients are `0`. | ||
| /// | ||
| /// Parameters: | ||
| /// - `seed`: A 32-byte seed used to deterministically generate the polynomial. | ||
| /// | ||
| /// Returns a [`PolyOverZ`] representing the challenge polynomial. |
There was a problem hiding this comment.
for the context of representation it is probably ok not to do the actual computation, but the changes should be expressed more in the function description.
I guess that you use the hash-digest as a seed here, but I would prefer to use the unmodified version here.
|
|
||
| for row in 0..vec_r_1.get_num_rows() { | ||
| for col in 0..vec_r_1.get_num_columns() { | ||
| let v_1_entry: PolyOverZ = unsafe { vec_v_1.get_entry_unchecked(row, col) }; |
There was a problem hiding this comment.
same comment regarding separation
|
|
||
| for row in 0..r_vector.get_num_rows() { | ||
| for col in 0..r_vector.get_num_columns() { | ||
| let entry_r_0 = unsafe { vec_r_0.get_entry_unchecked(row, col) }; |
| fn hamming_weight(matrix: &MatPolyOverZ) -> u64 { | ||
| let mut count = 0; | ||
|
|
||
| let entries = matrix.get_entries_rowwise(); | ||
| for entry in entries { | ||
| for i in 0..=entry.get_degree() { | ||
| if 0 != unsafe { entry.get_coeff_unchecked(i) } { | ||
| count += 1; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| count | ||
| } |
There was a problem hiding this comment.
replace with version from math, once that is on dev
Description
This PR implements...
Testing
Checklist:
Benchmarks
Quickly run benchmarks on my old laptop