A DESCRIPTION OF THE REQUEST :

Add intrinsic for the BigInteger.mod() method to get a faster execution time.

JUSTIFICATION :

From Java7 to Java 8 the multiply operation is clearly faster, but a modular multiplication (multiply(_).mod(p)) is not.

In Java 9, BigInteger will get some "Montgomery multiply intrinsic" to accelerate modular exponentiation which is useful for cryptographic scheme like RSA or DSA.

But the modular reduction is not accelerated and it impairs performance in the following cases:

- when an alternative modular exponentiation implementation is needed (to be resistant to side channel attacks for example, but other uses case exists);

- for alternative cryptography like Elliptic Curve Cryptography (ECC), where modular arithmetic is used to implement the arithmetic on elliptic curves; ECC implementation like the one provided by the BouncyCastle library should greatly benefit from this.

Note that acceleration on other BigInteger operations may also be welcome.

EXPECTED VERSUS ACTUAL BEHAVIOR :

EXPECTED -

No change the API, but a cost of the modular reduction divided by at least a factor 2.

Add intrinsic for the BigInteger.mod() method to get a faster execution time.

JUSTIFICATION :

From Java7 to Java 8 the multiply operation is clearly faster, but a modular multiplication (multiply(_).mod(p)) is not.

In Java 9, BigInteger will get some "Montgomery multiply intrinsic" to accelerate modular exponentiation which is useful for cryptographic scheme like RSA or DSA.

But the modular reduction is not accelerated and it impairs performance in the following cases:

- when an alternative modular exponentiation implementation is needed (to be resistant to side channel attacks for example, but other uses case exists);

- for alternative cryptography like Elliptic Curve Cryptography (ECC), where modular arithmetic is used to implement the arithmetic on elliptic curves; ECC implementation like the one provided by the BouncyCastle library should greatly benefit from this.

Note that acceleration on other BigInteger operations may also be welcome.

EXPECTED VERSUS ACTUAL BEHAVIOR :

EXPECTED -

No change the API, but a cost of the modular reduction divided by at least a factor 2.