Skip to content

Conversation

@jnsiemer
Copy link
Member

Description

This PR revises the API for discrete Gaussian sampling...

  • by removing the parameter n (which was used to define the tailcut) and replacing it by a static mut variable TAILCUT set to 6.0 by standard (as basically any other library).
  • removes need for generating degree-/ entry-many Gaussian samplers for MatQ and PolyOverQ

Testing
Not required - tests were already in place.

Checklist:

  • I have performed a self-review of my own code
    • The code provides good readability and maintainability s.t. it fulfills best practices like talking code, modularity, ...
      • The chosen implementation is not more complex than it has to be
    • My code should work as intended and no side effects occur (e.g. memory leaks)
    • The doc comments fit our style guide

@jnsiemer jnsiemer self-assigned this Nov 20, 2025
@jnsiemer jnsiemer force-pushed the optmise_disc_gauss_api branch from 86790f2 to 5023b2e Compare November 20, 2025 15:37
Copy link
Member

@Marvin-Beckmann Marvin-Beckmann left a comment

Choose a reason for hiding this comment

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

changes look good

Comment on lines +39 to +50
/// This is the global variable used in all `sample_discrete_gauss` and `sample_d`
/// functions. Its value should be in `ω(log(sqrt(n)))`. We set it (as most other libraries)
/// statically to `6.0`.
///
/// You can use and change in an `unsafe` environment.
/// ```compile_fail
/// unsafe { TAILCUT = 4.0 };
/// ```
/// Make sure that the tailcut stays positive and large enough for your purposes.
/// If you use multi-threading, read up on the behaviour of a `static mut` variable.
/// Our tests only cover cases where `TAILCUT = 6.0`.
pub static mut TAILCUT: f64 = 6.0;
Copy link
Member

Choose a reason for hiding this comment

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

nice that it ended up working. We could. consider adding a reference to a library that also does it (but probably optional)

Copy link
Member Author

Choose a reason for hiding this comment

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

dgs does it for example. The discrete Gaussian sampler of sagemath library also takes tailcut=6 as a default. The Micciancio-Walter paper from CRYPTO'17 takes the tailcut to be 6. There are plenty of references (or in other terms: I've never seen anything else :) )

@jnsiemer jnsiemer merged commit 1ee0b9f into dev Nov 20, 2025
2 checks passed
@jnsiemer jnsiemer deleted the optmise_disc_gauss_api branch November 20, 2025 16:33
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.

3 participants