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

secp256k1: Return normalized val from DecompressY. #3441

Merged
merged 1 commit into from
Sep 19, 2024

Commits on Sep 12, 2024

  1. secp256k1: Return normalized val from DecompressY.

    The result of the DecompressY function, as the documentation describes,
    currently returns a value that either has a maximum magnitude of 1 or 2
    which also implies that it is not necessarily normalized either.  This
    means the caller is currently responsible for normalization.
    
    While there is no logic issue with that approach, it does mean that
    callers realistically have to unconditionally normalize the result for
    almost all realistic use cases even though it might not actually need
    it.
    
    Those extra normalizations can result in a minor average comparative
    performance loss when amortized across millions of point decompressions.
    Further, putting the responsibility on the caller makes it easier make a
    mistake.
    
    To improve both of those cases, this updates the DecompressY function to
    normalize the result in all cases when the result is a valid point on
    the secp256k1 curve (aka the function returns true) before returning it
    and updates the callers accordingly.
    
    This change also means the result will now always have a max magnitude
    of 1.
    davecgh committed Sep 12, 2024
    Configuration menu
    Copy the full SHA
    7333f80 View commit details
    Browse the repository at this point in the history