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

math/big: ModSqrt returns wrong value when aliasing parameters #22265

Closed
FiloSottile opened this issue Oct 14, 2017 · 2 comments
Closed

math/big: ModSqrt returns wrong value when aliasing parameters #22265

FiloSottile opened this issue Oct 14, 2017 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@FiloSottile
Copy link
Contributor

What version of Go are you using (go version)?

go 1.9

What operating system and processor architecture are you using (go env)?

  • darwin_amd64
  • Playground

What did you do?

Aliased z and x in ModSqrt, as allowed by the package docs and not disallowed by the function docs.

y.ModSqrt(y, p.P)

https://play.golang.org/p/MsOief8jlg

What did you expect to see?

The same result as new(big.Int).ModSqrt(y, p.P).

What did you see instead?

An incorrect value is computed.

@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Oct 14, 2017
@ianlancetaylor ianlancetaylor added this to the Go1.10 milestone Oct 14, 2017
@FiloSottile
Copy link
Contributor Author

The optimized path modSqrt3Mod4Prime introduced by ea0491b starts with z.Set(p), which when aliasing will improperly set x = p, too.

@gopherbot
Copy link

Change https://golang.org/cl/70832 mentions this issue: math/big: fix ModSqrt optimized path for x = z

@golang golang locked and limited conversation to collaborators Oct 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants