1 /* 2 * Copyright 2024-2025 The OpenSSL Project Authors. All Rights Reserved. 3 * 4 * Licensed under the Apache License 2.0 (the "License"). You may not use 5 * this file except in compliance with the License. You can obtain a copy 6 * in the file LICENSE in the source distribution or at 7 * https://www.openssl.org/source/license.html 8 */ 9 10 #include "ml_dsa_local.h" 11 #include "ml_dsa_vector.h" 12 #include "ml_dsa_matrix.h" 13 14 /* 15 * Matrix multiply of a k*l matrix of polynomials by a 1 * l vector of 16 * polynomials to produce a 1 * k vector of polynomial results. 17 * i.e. t = a * s 18 * 19 * @param a A k * l matrix of polynomials in NTT form 20 * @param s A 1 * l vector of polynomials in NTT form 21 * @param t 1 * k vector of polynomial results in NTT form 22 */ ossl_ml_dsa_matrix_mult_vector(const MATRIX * a,const VECTOR * s,VECTOR * t)23void ossl_ml_dsa_matrix_mult_vector(const MATRIX *a, const VECTOR *s, 24 VECTOR *t) 25 { 26 size_t i, j; 27 POLY *poly = a->m_poly; 28 29 vector_zero(t); 30 31 for (i = 0; i < a->k; i++) { 32 for (j = 0; j < a->l; j++) { 33 POLY product; 34 35 ossl_ml_dsa_poly_ntt_mult(poly++, &s->poly[j], &product); 36 poly_add(&product, &t->poly[i], &t->poly[i]); 37 } 38 } 39 } 40