-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.
Milestone
Description
For an exponent of 1, big.Int.Exp returns the correct value only for a 0 recipient, and an off-by-one result for all pre-allocated recipients.
package main
import (
"fmt"
"math/big"
)
func main() {
base := new(big.Int)
base.SetString("84555555300000000000", 10)
mod := new(big.Int)
mod.SetString("66666670001111111111", 10)
fmt.Printf("%v\n", big.NewInt(0).Exp(base, big.NewInt(1), mod))
fmt.Printf("%v\n", big.NewInt(1).Exp(base, big.NewInt(1), mod))
}The result in both cases above should be the same, however, they are 17888885298888888889
vs. 17888885298888888888. Playground: https://play.golang.org/p/uSBvGkeGkN
Issue originally found by @guidovranken, no security implication according to @rsc.
yanpozka, dmitshur, strazzere, dongweigogo and tevjef
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.