From 91f26c3dd95d76d9b9cd95323f998caff94124e0 Mon Sep 17 00:00:00 2001 From: xvzcf Date: Tue, 3 Dec 2024 12:09:14 -0500 Subject: [PATCH] Slight refactoring. --- ref/ml_dsa_65/encoding/gamma1.jinc | 18 ++++++------------ ref/ml_dsa_65/encoding/signature.jinc | 2 +- ref/ml_dsa_65/sample/error_vectors.jinc | 4 ++-- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/ref/ml_dsa_65/encoding/gamma1.jinc b/ref/ml_dsa_65/encoding/gamma1.jinc index a246355..d2b801b 100644 --- a/ref/ml_dsa_65/encoding/gamma1.jinc +++ b/ref/ml_dsa_65/encoding/gamma1.jinc @@ -125,24 +125,18 @@ namespace gamma1 { inline fn decode( reg ptr u8[GAMMA1_ENCODED_SIZE] encoded, - #spill_to_mmx reg ptr u32[COLUMNS_IN_MATRIX_A * COEFFICIENTS_IN_POLYNOMIAL] decoded + reg ptr u32[COLUMNS_IN_MATRIX_A * COEFFICIENTS_IN_POLYNOMIAL] decoded ) -> reg ptr u32[COLUMNS_IN_MATRIX_A * COEFFICIENTS_IN_POLYNOMIAL] { - reg ptr u8[ENCODED_GAMMA1_POLYNOMIAL_SIZE] encoded_gamma1_polynomial; - reg ptr u32[COEFFICIENTS_IN_POLYNOMIAL] decoded_gamma1_polynomial; - inline int i; for i = 0 to COLUMNS_IN_MATRIX_A { - encoded_gamma1_polynomial = encoded[i * ENCODED_GAMMA1_POLYNOMIAL_SIZE : ENCODED_GAMMA1_POLYNOMIAL_SIZE]; - - decoded_gamma1_polynomial = decoded[i * COEFFICIENTS_IN_POLYNOMIAL : COEFFICIENTS_IN_POLYNOMIAL]; - - () = #spill(decoded); - decoded_gamma1_polynomial = decode_to_polynomial(encoded_gamma1_polynomial, decoded_gamma1_polynomial); - () = #unspill(decoded); - decoded[i * COEFFICIENTS_IN_POLYNOMIAL : COEFFICIENTS_IN_POLYNOMIAL] = decoded_gamma1_polynomial; + decoded[i * COEFFICIENTS_IN_POLYNOMIAL : COEFFICIENTS_IN_POLYNOMIAL] = + decode_to_polynomial( + encoded[i * ENCODED_GAMMA1_POLYNOMIAL_SIZE : ENCODED_GAMMA1_POLYNOMIAL_SIZE], + decoded[i * COEFFICIENTS_IN_POLYNOMIAL : COEFFICIENTS_IN_POLYNOMIAL] + ); } return decoded; diff --git a/ref/ml_dsa_65/encoding/signature.jinc b/ref/ml_dsa_65/encoding/signature.jinc index 19e49c2..7cfc132 100644 --- a/ref/ml_dsa_65/encoding/signature.jinc +++ b/ref/ml_dsa_65/encoding/signature.jinc @@ -26,7 +26,7 @@ namespace signature { inline int k; inline bool condition; - signature[0:48] = #copy(commitment_hash); + signature[0:COMMITMENT_HASH_SIZE] = #copy(commitment_hash); for k = 0 to COLUMNS_IN_MATRIX_A { polynomial_encoded = signature[START_OF_GAMMA1 + (k * ENCODED_GAMMA1_POLYNOMIAL_SIZE) : ENCODED_GAMMA1_POLYNOMIAL_SIZE]; diff --git a/ref/ml_dsa_65/sample/error_vectors.jinc b/ref/ml_dsa_65/sample/error_vectors.jinc index fa97ddb..c8f6709 100644 --- a/ref/ml_dsa_65/sample/error_vectors.jinc +++ b/ref/ml_dsa_65/sample/error_vectors.jinc @@ -67,7 +67,7 @@ fn rejection_sample_less_than_eta( if (b) { msf = #update_msf(b, msf); - temp = 4; + temp = ETA; temp -= try_coefficient; error[sampled] = temp; @@ -88,7 +88,7 @@ fn rejection_sample_less_than_eta( if (b) { msf = #update_msf(b, msf); - temp = 4; + temp = ETA; temp -= try_coefficient; error[sampled] = temp;