Skip to content

Commit 3f327b7

Browse files
hanno-beckermkannwischer
authored andcommitted
Introduce mld_polymat_get_row() helper function
- Add mld_polymat_get_row() to retrieve matrix row pointer - Update mld_polyvec_matrix_pointwise_montgomery() to use helper Addresses #738 (steps 2-3 of #736) Signed-off-by: Hanno Becker <beckphan@amazon.co.uk>
1 parent 207c958 commit 3f327b7

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

mldsa/mldsa_native.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@
273273
/* mldsa/src/polyvec.h */
274274
#undef MLD_POLYVEC_H
275275
#undef mld_polymat
276+
#undef mld_polymat_get_row
276277
#undef mld_polyvec_matrix_expand
277278
#undef mld_polyvec_matrix_pointwise_montgomery
278279
#undef mld_polyveck

mldsa/mldsa_native.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@
269269
/* mldsa/src/polyvec.h */
270270
#undef MLD_POLYVEC_H
271271
#undef mld_polymat
272+
#undef mld_polymat_get_row
272273
#undef mld_polyvec_matrix_expand
273274
#undef mld_polyvec_matrix_pointwise_montgomery
274275
#undef mld_polyveck

mldsa/src/polyvec.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ __contract__(
6666
#endif /* !MLD_USE_NATIVE_NTT_CUSTOM_ORDER */
6767
}
6868

69+
MLD_INTERNAL_API
70+
const mld_polyvecl *mld_polymat_get_row(const mld_polymat *mat,
71+
unsigned int row)
72+
{
73+
return &mat->vec[row];
74+
}
6975

7076
MLD_INTERNAL_API
7177
void mld_polyvec_matrix_expand(mld_polymat *mat,
@@ -172,7 +178,8 @@ void mld_polyvec_matrix_pointwise_montgomery(mld_polyveck *t,
172178
array_abs_bound(t->vec[k0].coeffs, 0, MLDSA_N, MLDSA_Q)))
173179
)
174180
{
175-
mld_polyvecl_pointwise_acc_montgomery(&t->vec[i], &mat->vec[i], v);
181+
const mld_polyvecl *row = mld_polymat_get_row(mat, i);
182+
mld_polyvecl_pointwise_acc_montgomery(&t->vec[i], row, v);
176183
}
177184

178185
mld_assert_abs_bound_2d(t->vec, MLDSA_K, MLDSA_N, MLDSA_Q);

mldsa/src/polyvec.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,21 @@ __contract__(
753753
array_bound(p->vec[k1].coeffs, 0, MLDSA_N, -(1<<(MLDSA_D-1)) + 1, (1<<(MLDSA_D-1)) + 1)))
754754
);
755755

756+
#define mld_polymat_get_row MLD_NAMESPACE_KL(polymat_get_row)
757+
/*************************************************
758+
* Name: mld_polymat_get_row
759+
*
760+
* Description: Retrieve a pointer to a specific row of the matrix.
761+
*
762+
* Arguments: - const mld_polymat *mat: pointer to matrix
763+
* - unsigned int row: row index (must be < MLDSA_K)
764+
*
765+
* Returns pointer to the row (mld_polyvecl)
766+
**************************************************/
767+
MLD_INTERNAL_API
768+
const mld_polyvecl *mld_polymat_get_row(const mld_polymat *mat,
769+
unsigned int row);
770+
756771
#define mld_polyvec_matrix_expand MLD_NAMESPACE_KL(polyvec_matrix_expand)
757772
/*************************************************
758773
* Name: mld_polyvec_matrix_expand

0 commit comments

Comments
 (0)