Skip to content
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

tests: simplify random_fe_non_zero (remove loop limit and unneeded normalize) #1395

Merged

Commits on Aug 17, 2023

  1. tests: simplify random_fe_non_zero (remove loop limit and unneeded …

    …normalize)
    
    `random_fe_non_zero` contains a loop iteration limit that ensures that
    we abort if `random_fe` ever yielded zero more than ten times in a row.
    This construct was first introduced in PR bitcoin-core#19 (commit 09ca4f3) for
    random non-square field elements and was later refactored into the
    non-zero helper in PR bitcoin-core#25 (commit 6d6102f). The copy-over to the
    exhaustive tests happened recently in PR bitcoin-core#1118 (commit 0f86420).
    
    This case seems to be practically irrelevant and I'd argue for keeping
    things simple and removing it; if there's really a worry that the test's
    random generator is heavily biased towards certain values or value
    ranges then there should consequently be checks at other places too
    (e.g. directly in `random_fe` for 256-bit values that repeatedly
    overflow, i.e. >= p).
    
    Also, the _fe_normalize call is not needed and can be removed, as the
    result of `random_fe` is already normalized.
    theStack committed Aug 17, 2023
    Configuration menu
    Copy the full SHA
    dc55141 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    c45b7c4 View commit details
    Browse the repository at this point in the history