Skip to content

Infinite loop in modInverse on negative number #27

Description

@aczekajski

When invoking modInverse on BigInteger object representing negative number, library seems to fall into an infinite loop.

Example code:

    new BigInteger('-3').modInverse(new BigInteger('2'));

Expected behaviour:
Return a value

Actual behaviour:
Infinite loop

Known workaround:
Invoking mod before modInverse:

    const p = new BigInteger('2');
    new BigInteger('-3').mod(p).modInverse(p);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions