Skip to content

math/big: Exp does not handle negative exponents correctly #25865

@zzh1823

Description

@zzh1823

Please answer these questions before submitting your issue. Thanks!

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

Go 1.10

Does this issue reproduce with the latest release?

Yes

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

linux_amd64

What did you do?

When using package math/big, specifically big.Int.Exp(), I found that it cannot handle negative exponents correctly but simply returns 1.

What did you expect to see?

Compared to ModPow() in Java, Exp(x, y, z) should return mod inverse of (x ^ Abs(y)) mod N when y is negative.

What did you see instead?

Exp(x, y, z) simply returns 1 when y is negative.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions