Skip to content

Comments

[crypto] ML-DSA-87 verify (1/24)#29299

Merged
nasahlpa merged 2 commits intolowRISC:masterfrom
andrea-caforio:mldsa87-verify-1
Feb 18, 2026
Merged

[crypto] ML-DSA-87 verify (1/24)#29299
nasahlpa merged 2 commits intolowRISC:masterfrom
andrea-caforio:mldsa87-verify-1

Conversation

@andrea-caforio
Copy link
Contributor

@andrea-caforio andrea-caforio commented Feb 11, 2026

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

  1. doc

Number-theoretic transform

  1. NTT
  2. INTT

Polynomial arithmetic

  1. poly_add, poly_sub, poly_mul
  2. poly_mul_add

XOF

  1. xof_init, xof_poll, xof_finish
  2. xof_absorb
  3. xof_squeeze

Rounding

  1. shift_left
  2. decompose

Reduction

  1. reduce

Infinity norm

  1. norm_check

Sampling

  1. rej_ntt_poly, expand_a
  2. sample_in-ball
  3. challenge_hash

Encoding

  1. decode_z
  2. decode_t1
  3. decode_hint
  4. encode_w1

Vector operations

  1. sig_decode
  2. norm_check_z
  3. A*z, c * t1, Az - ct1
  4. use_hint

Epilogue

  1. app

Copy link
Contributor

@etterli etterli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment on lines 800 to 801
Note that DMEM is actually 4kiB in size, but only the first 3kiB of
the memory is visible through this register interface.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

@andrea-caforio andrea-caforio requested a review from a team as a code owner February 12, 2026 07:27
@andrea-caforio andrea-caforio requested review from hcallahan-lowrisc and removed request for a team February 12, 2026 07:27
@andrea-caforio
Copy link
Contributor Author

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

Correct.

Copy link
Member

@nasahlpa nasahlpa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

| 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 |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please also update the memory sizes here:
https://opentitan.org/book/hw/ip/otbn/doc/theory_of_operation.html#memories

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we can increase both memories to 32KiB without changing the offsets. This is implemented in #29318 .

Copy link
Contributor

@vogelpi vogelpi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @andrea-caforio for the PR, it's great to see this! I've left some comments

@@ -0,0 +1,94 @@
/* Copyright lowRISC contributors (OpenTitan project). */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this go into a README.md instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a README.md now.

| 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 |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 797 to 798
TODO: Document the .bss and .scratchpad split
Note that DMEM is actually 32kiB in size, but only the first XkiB of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we can make a sensible choice for this right from the beginning. It may require some internal discussion first though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#29318 goes with a 16\16 KiB split. This should be sufficient to transfer any PQC related data.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the commit that adjusts the DMEM/IMEM sizes.
It is handled in #29318.

@etterli
Copy link
Contributor

etterli commented Feb 16, 2026

@vogelpi Thanks for explaining the address offset and version problematic. I created a separate PR which increases the IMEM and DMEM. See #29318.

@andrea-caforio

Copy link
Contributor

@h-filali h-filali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @andrea-caforio. I mainly double checked the documentation part. Looks very clean, I like it!


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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit nitpicky but is "occupying one 32-bit memory word" always true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, always.


/*

This directory contains the FIPS-204-compliant and hardened OpenTitan OTBN
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only SCA hardened AFAIK.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copy link
Member

@nasahlpa nasahlpa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the comments. The IMEM and DMEM size increase will be done in #29318.

@nasahlpa nasahlpa added this pull request to the merge queue Feb 18, 2026
Merged via the queue into lowRISC:master with commit 59a9333 Feb 18, 2026
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

SW:cryptolib Crypto library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants