• David Leon Gil's avatar
    math/big: use optimized formula in ModSqrt for 3 mod 4 primes · ea0491b7
    David Leon Gil authored
    For primes which are 3 mod 4, using Tonelli-Shanks is slower
    and more complicated than using the identity
    
         a**((p+1)/4) mod p == sqrt(a)
    
    For 2^450-2^225-1 and 2^10860-2^5430-1, which are 3 mod 4:
    
    BenchmarkModSqrt225_TonelliTri      1000     1135375 ns/op
    BenchmarkModSqrt225_3Mod4          10000      156009 ns/op
    BenchmarkModSqrt5430_Tonelli           1  3448851386 ns/op
    BenchmarkModSqrt5430_3Mod4             2   914616710 ns/op
    
    ~2.6x to 7x faster.
    
    Fixes #11437 (which is a prime choice of issues to fix)
    
    Change-Id: I813fb29454160483ec29825469e0370d517850c2
    Reviewed-on: https://go-review.googlesource.com/11522Reviewed-by: 's avatarAdam Langley <agl@golang.org>
    ea0491b7
Name
Last commit
Last update
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...