Skip to content

Comments

[crypto] ML-DSA-87: forward number-theoretic transform (2/24)#29333

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

[crypto] ML-DSA-87: forward number-theoretic transform (2/24)#29333
nasahlpa merged 1 commit intolowRISC:masterfrom
andrea-caforio:mldsa87-verify-2

Conversation

@andrea-caforio
Copy link
Contributor

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

This is an implementation of the forward number-theoretic transform over the
polynomial ring Z_q[X] / (X^256 + 1) using the 512-th root of unity 1753.

Design rationale (from mldsa87_ntt.s):

A NTT operation over a polynomial of 256 32-bit coefficients consists of 8
layers with each layer computing 128 butterflies, i.e., the twiddle factors are
multiplied with 128 coefficients. The 32 WDRs in OTBN can hold 128 coefficients
in 16 WDRs with the rest being used to hold twiddle factors and intermediate
results. This means that with the exception of Layer 1, one half of each
each subsequent Layer 2-8 can be computed completely in-register without the
need to store and load results to DMEM. This 7x1 decomposition of a 8-layer NTT
differs from the 4x4 decomposition first proposed by Becker et al. [1] as it is
more intutive and makes betters use of the register structure of the OTBN.

[1]  https://doi.org/10.46586/tches.v2022.i1.221-244

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 [crypto] ML-DSA-87 verify (1/24) #29299

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 nice, especially due to the nice modularization.

Comment on lines +733 to +734
here. Make sure that these are not placed at the end of the .data section in
the ELF file to guarantee that correct placement of the stack. */
Copy link
Contributor

Choose a reason for hiding this comment

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

How can this be ensured?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can specify the order the input files to gnu-as, for example:

otbn_sim_test(
     name = "mldsa87_keygen_wycheproof_g1_test",
     srcs = mldsa87_srcs + [
         # This is a top-level OTBN application test.
         # Make sure the memory file is placed after all the sources.
         "//sw/otbn/crypto/mldsa87:mldsa87_keygen.s",
         "//sw/otbn/crypto/mldsa87:mldsa87_keygen_mem.s",
         "mldsa87_keygen_test.s",
     ],
     testcase = "mldsa87_keygen_wycheproof_g1_test.hjson",
 )

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. Maybe that the location of mldsa87_ntt.s must not be there is something worth to add to the readme?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right. It should be there. Let me fix it.

@andrea-caforio andrea-caforio force-pushed the mldsa87-verify-2 branch 2 times, most recently from bb70488 to 8ef75ba Compare February 18, 2026 14:29
@andrea-caforio andrea-caforio added the CI:Rerun Rerun failed CI jobs label Feb 18, 2026
@github-actions github-actions bot removed the CI:Rerun Rerun failed CI jobs label Feb 18, 2026
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 the comprehensive documentation, this makes it easier to review :-)

This is an implementation of the forward number-theoretic transform
over the polynomial ring Z_q[X] / (X^256 + 1) using the 512-th root of
unity 1753.

Signed-off-by: Andrea Caforio <andrea.caforio@lowrisc.org>
@nasahlpa nasahlpa added this pull request to the merge queue Feb 19, 2026
Merged via the queue into lowRISC:master with commit ef07088 Feb 19, 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 Type:Enhancement Feature requests, enhancements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants