[crypto] ML-DSA-87 verify (1/24)#29299
Conversation
etterli
left a comment
There was a problem hiding this comment.
Looks good to me except that the memory increase should probably be an atomic commit which also touches the RTL and DV. The reason is that otherwise the DV and potentially IBEX SW breaks.
I think increasing the memories should touch the same files as in this commit: etterli/opentitan-otbn-pqc-isa@b0ce32d
| Note that DMEM is actually 4kiB in size, but only the first 3kiB of | ||
| the memory is visible through this register interface. |
There was a problem hiding this comment.
| TODO: Document the .bss and .scratchpad split | |
| Note that DMEM is actually 32kiB in size, but only the first XkiB of | |
| the memory is visible through this register interface. |
0d2d6bb to
85f561a
Compare
Correct. |
85f561a to
c50f149
Compare
nasahlpa
left a comment
There was a problem hiding this comment.
Thanks Andi, this looks good to me.
Could you please:
- Increase the memory sizes in the documentation as well
- Fix the linting issue in otbn_reg_pkg.sv
hw/ip/otbn/doc/registers.md
Outdated
| | otbn.[`IMEM`](#imem) | 0x4000 | 8192 | Instruction Memory Access | | ||
| | otbn.[`DMEM`](#dmem) | 0x8000 | 3072 | Data Memory Access | | ||
| | otbn.[`IMEM`](#imem) | 0x8000 | 16384 | Instruction Memory Access | | ||
| | otbn.[`DMEM`](#dmem) | 0x10000 | 32768 | Data Memory Access | |
There was a problem hiding this comment.
Can you please also update the memory sizes here:
https://opentitan.org/book/hw/ip/otbn/doc/theory_of_operation.html#memories
There was a problem hiding this comment.
This is actually autogenerated. I am working on a proper PR which increases the memories. It takes more than just adding the changes I previously mentioned.
There was a problem hiding this comment.
Please note that if you move the start address of DMEM (or IMEM), you introduce a backwards incompatible change with respect to Ibex software. If we do this, we have to not just do a minor version increase to 1.2.0 but a major one 2.0.0. IIRC, we should be able to increase DMEM to 32 KiB and IMEM to 16 KiB without changing start addresses.
There was a problem hiding this comment.
Yes, we can increase both memories to 32KiB without changing the offsets. This is implemented in #29318 .
vogelpi
left a comment
There was a problem hiding this comment.
Thanks @andrea-caforio for the PR, it's great to see this! I've left some comments
sw/otbn/crypto/mldsa87/mldsa87.s
Outdated
| @@ -0,0 +1,94 @@ | |||
| /* Copyright lowRISC contributors (OpenTitan project). */ | |||
There was a problem hiding this comment.
Should this go into a README.md instead?
There was a problem hiding this comment.
It's a README.md now.
hw/ip/otbn/doc/registers.md
Outdated
| | otbn.[`IMEM`](#imem) | 0x4000 | 8192 | Instruction Memory Access | | ||
| | otbn.[`DMEM`](#dmem) | 0x8000 | 3072 | Data Memory Access | | ||
| | otbn.[`IMEM`](#imem) | 0x8000 | 16384 | Instruction Memory Access | | ||
| | otbn.[`DMEM`](#dmem) | 0x10000 | 32768 | Data Memory Access | |
There was a problem hiding this comment.
Please note that if you move the start address of DMEM (or IMEM), you introduce a backwards incompatible change with respect to Ibex software. If we do this, we have to not just do a minor version increase to 1.2.0 but a major one 2.0.0. IIRC, we should be able to increase DMEM to 32 KiB and IMEM to 16 KiB without changing start addresses.
hw/ip/otbn/data/otbn.hjson
Outdated
| TODO: Document the .bss and .scratchpad split | ||
| Note that DMEM is actually 32kiB in size, but only the first XkiB of |
There was a problem hiding this comment.
Ideally we can make a sensible choice for this right from the beginning. It may require some internal discussion first though.
There was a problem hiding this comment.
#29318 goes with a 16\16 KiB split. This should be sufficient to transfer any PQC related data.
There was a problem hiding this comment.
I removed the commit that adjusts the DMEM/IMEM sizes.
It is handled in #29318.
h-filali
left a comment
There was a problem hiding this comment.
Thanks @andrea-caforio. I mainly double checked the documentation part. Looks very clean, I like it!
sw/otbn/crypto/mldsa87/mldsa87.s
Outdated
|
|
||
| The implementation is structured hierarchically where the bottom layer consists | ||
| of routines that operate on polynomials in Z_q[X] / (X^256 + 1) composed of | ||
| 256 24-bit coefficients in the ring Z_q each occupying one 32-bit memory word |
There was a problem hiding this comment.
A bit nitpicky but is "occupying one 32-bit memory word" always true?
There was a problem hiding this comment.
Yes, always.
sw/otbn/crypto/mldsa87/mldsa87.s
Outdated
|
|
||
| /* | ||
|
|
||
| This directory contains the FIPS-204-compliant and hardened OpenTitan OTBN |
There was a problem hiding this comment.
I'm projecting here. :-)
This file documents the high-level implementation choices and should be the initial contact point when navigating to the `mldsa87` directory. Signed-off-by: Andrea Caforio <andrea.caforio@lowrisc.org>
Two Bazel build files are required for the ML-DSA-87 apps: One for the sources files and another one for the unit tests. Signed-off-by: Andrea Caforio <andrea.caforio@lowrisc.org>
c50f149 to
f37a11e
Compare
First PR of the series adding package documentation and Bazel build files.
This is a series of PRs that in their composition result in FIPS-204-compliant OTBN implementation of ML-DSA-87 verify.
Resources
Preamble
docNumber-theoretic transform
NTTINTTPolynomial arithmetic
poly_add,poly_sub,poly_mulpoly_mul_addXOF
xof_init,xof_poll,xof_finishxof_absorbxof_squeezeRounding
shift_leftdecomposeReduction
reduceInfinity norm
norm_checkSampling
rej_ntt_poly,expand_asample_in-ballchallenge_hashEncoding
decode_zdecode_t1decode_hintencode_w1Vector operations
sig_decodenorm_check_zA*z,c * t1,Az - ct1use_hintEpilogue
app