Skip to content

Commit

Permalink
Getting signing to RSB-check.
Browse files Browse the repository at this point in the history
  • Loading branch information
xvzcf committed Dec 16, 2024
1 parent 537fcf4 commit 9cd8a5a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 25 deletions.
27 changes: 16 additions & 11 deletions ref/common/column_vector.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -134,22 +134,27 @@ namespace column_vector {
}

inline
fn multiply_by_polynomial(reg ptr u32[ROWS_IN_MATRIX_A * COEFFICIENTS_IN_POLYNOMIAL] vector, reg ptr u32[COEFFICIENTS_IN_POLYNOMIAL] f)
-> stack u32[ROWS_IN_MATRIX_A * COEFFICIENTS_IN_POLYNOMIAL]
fn multiply_by_polynomial(
#spill_to_mmx reg ptr u32[ROWS_IN_MATRIX_A * COEFFICIENTS_IN_POLYNOMIAL] vector,
#spill_to_mmx reg ptr u32[COEFFICIENTS_IN_POLYNOMIAL] poly
) -> stack u32[ROWS_IN_MATRIX_A * COEFFICIENTS_IN_POLYNOMIAL]
{
stack u32[ROWS_IN_MATRIX_A * COEFFICIENTS_IN_POLYNOMIAL] fvector;
stack u32[ROWS_IN_MATRIX_A * COEFFICIENTS_IN_POLYNOMIAL] product;

inline int ii;
reg ptr u32[COEFFICIENTS_IN_POLYNOMIAL] fg g;
() = #spill(vector, poly);

for ii = 0 to ROWS_IN_MATRIX_A {
fg = fvector[ii * COEFFICIENTS_IN_POLYNOMIAL : COEFFICIENTS_IN_POLYNOMIAL];
g = vector[ii * COEFFICIENTS_IN_POLYNOMIAL : COEFFICIENTS_IN_POLYNOMIAL];
fg = polynomial::pointwise_montgomery_product(f, g, fg);
fvector[ii * COEFFICIENTS_IN_POLYNOMIAL : COEFFICIENTS_IN_POLYNOMIAL] = fg;
inline int i;
for i = 0 to ROWS_IN_MATRIX_A {
product[i * COEFFICIENTS_IN_POLYNOMIAL : COEFFICIENTS_IN_POLYNOMIAL] =
polynomial::pointwise_montgomery_product(
vector[i * COEFFICIENTS_IN_POLYNOMIAL : COEFFICIENTS_IN_POLYNOMIAL],
poly,
product[i * COEFFICIENTS_IN_POLYNOMIAL : COEFFICIENTS_IN_POLYNOMIAL]
);
() = #unspill(vector, poly);
}

return fvector;
return product;
}

inline
Expand Down
11 changes: 8 additions & 3 deletions ref/common/polynomial.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,13 @@ namespace polynomial {
}

inline
fn make_hint(reg ptr u32[COEFFICIENTS_IN_POLYNOMIAL] f0 f1 hints)
-> reg u32, reg ptr u32[COEFFICIENTS_IN_POLYNOMIAL]
fn make_hint(
reg ptr u32[COEFFICIENTS_IN_POLYNOMIAL] f0 f1,
#spill_to_mmx reg ptr u32[COEFFICIENTS_IN_POLYNOMIAL] hints
) -> reg u32, reg ptr u32[COEFFICIENTS_IN_POLYNOMIAL]
{
reg u32 weight a0 a1 hint;
reg u64 i;
#spill_to_mmx reg u64 i;

reg u64 msf = #init_msf();

Expand All @@ -154,7 +156,10 @@ namespace polynomial {
a1 = f1[i];
a1 = #protect_32(a1, msf);

() = #spill(i, hints);
hint, msf = coefficient::make_hint(a0, a1, msf);
() = #unspill(i, hints);

hints[i] = hint;
weight += hint;
i += 1;
Expand Down
26 changes: 15 additions & 11 deletions ref/common/row_vector.jinc
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,27 @@ namespace row_vector {

inline
fn multiply_by_polynomial(
reg ptr u32[COLUMNS_IN_MATRIX_A * COEFFICIENTS_IN_POLYNOMIAL] vector,
reg ptr u32[COEFFICIENTS_IN_POLYNOMIAL] f
#spill_to_mmx reg ptr u32[COLUMNS_IN_MATRIX_A * COEFFICIENTS_IN_POLYNOMIAL] vector,
#spill_to_mmx reg ptr u32[COEFFICIENTS_IN_POLYNOMIAL] poly
) -> stack u32[COLUMNS_IN_MATRIX_A * COEFFICIENTS_IN_POLYNOMIAL]
{
stack u32[COLUMNS_IN_MATRIX_A * COEFFICIENTS_IN_POLYNOMIAL] fvector;
stack u32[COLUMNS_IN_MATRIX_A * COEFFICIENTS_IN_POLYNOMIAL] product;

inline int ii;
reg ptr u32[COEFFICIENTS_IN_POLYNOMIAL] fg g;
() = #spill(vector, poly);

for ii = 0 to COLUMNS_IN_MATRIX_A {
fg = fvector[ii * COEFFICIENTS_IN_POLYNOMIAL : COEFFICIENTS_IN_POLYNOMIAL];
g = vector[ii * COEFFICIENTS_IN_POLYNOMIAL : COEFFICIENTS_IN_POLYNOMIAL];
fg = polynomial::pointwise_montgomery_product(f, g, fg);
fvector[ii * COEFFICIENTS_IN_POLYNOMIAL : COEFFICIENTS_IN_POLYNOMIAL] = fg;
inline int i;
for i = 0 to COLUMNS_IN_MATRIX_A {
product[i * COEFFICIENTS_IN_POLYNOMIAL : COEFFICIENTS_IN_POLYNOMIAL]
= polynomial::pointwise_montgomery_product(
vector[i * COEFFICIENTS_IN_POLYNOMIAL : COEFFICIENTS_IN_POLYNOMIAL],
poly,
product[i * COEFFICIENTS_IN_POLYNOMIAL : COEFFICIENTS_IN_POLYNOMIAL]
);

() = #unspill(vector, poly);
}

return fvector;
return product;
}

// Compute A * NTT(vector)
Expand Down

0 comments on commit 9cd8a5a

Please sign in to comment.