Skip to content

Implement polyvecl_uniform_gamma1 using 4-way Keccak #251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mkannwischer
Copy link
Contributor

This commit adds poly_uniform_gamma1_4x which implements uniform
sampling in [-(MLDSA_GAMMA1 - 1), MLDSA_GAMMA1] using 4-way batched
Keccak. It then implements polyvecl_uniform_gamma1 using
the new batched function.

L = 4 is implemented using one call to poly_uniform_gamma1_4x.
L = 5 is implemented using one call to poly_uniform_gamma1_4x and one call to
poly_uniform_gamma1
L = 7 is implemented using two call to poly_uniform_gamma1_4x (with one
polynomial being wasted).

@mkannwischer mkannwischer force-pushed the poly_uniform_gamma1_4x branch from 67a1c6f to 52e8f98 Compare May 17, 2025 16:41
@mkannwischer mkannwischer marked this pull request as ready for review May 17, 2025 16:56
@mkannwischer mkannwischer requested a review from a team as a code owner May 17, 2025 16:56
This commit adds poly_uniform_gamma1_4x which implements uniform
sampling in [-(MLDSA_GAMMA1 - 1), MLDSA_GAMMA1] using 4-way batched
Keccak. It then implements polyvecl_uniform_gamma1 using
the new batched function.

L = 4 is implemented using one call to poly_uniform_gamma1_4x.
L = 5 is implemented using one call to poly_uniform_gamma1_4x and one call to
poly_uniform_gamma1
L = 7 is implemented using two call to poly_uniform_gamma1_4x (with one
polynomial being wasted).

Signed-off-by: Matthias J. Kannwischer <[email protected]>
The poly_uniform_gamma1 function is the last one using the stream256
instead of the standard keccak APIs.
This commit refactors it to be in-line with the batched implementation as
well as the xof128 function.

The initialization function is removed and inlined into poly_uniform_gamma1.

The CBMC proof is adjusted accordingly.

Signed-off-by: Matthias J. Kannwischer <[email protected]>
@hanno-becker hanno-becker force-pushed the poly_uniform_gamma1_4x branch from 52e8f98 to 142be6c Compare May 17, 2025 18:27
mld_xof256_init(&state);
mld_xof256_absorb(&state, extseed, MLDSA_CRHBYTES + 2);

mld_xof256_squeezeblocks(buf, POLY_UNIFORM_GAMMA1_NBLOCKS, &state);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have a call to mld_xof256_release at the end?

Copy link
Contributor

@hanno-becker hanno-becker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A call to xxx_release() is missing at the end of the refactored poly_uniform_gamma1()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add poly_uniform_gamma1_4x
2 participants