Skip to content

Commit

Permalink
Slight refactoring.
Browse files Browse the repository at this point in the history
  • Loading branch information
xvzcf committed Dec 3, 2024
1 parent f78fd10 commit 91f26c3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 15 deletions.
18 changes: 6 additions & 12 deletions ref/ml_dsa_65/encoding/gamma1.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ref/ml_dsa_65/encoding/signature.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions ref/ml_dsa_65/sample/error_vectors.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand Down

0 comments on commit 91f26c3

Please sign in to comment.