I believe in 64-bit JVM long[] is much more efficient than int[], and it can significantly speed up RSA operations.
Carry is a problem in long[], but we can use some native methods to force long as unsigned, eg long z = u64add(x, y, cr)
, here cr
is a boolean[]
, can replace long z = x + y
.
BigInteger
supports multiply()
, not just add()
. Since multiply()
is the more expensive operation, its speed is also what matters most for algorithms.
Multiplying two 64-bit integers gives a 128-bit result. There is no 128-bit integer type in Java, so getting the correct result isn't just "do the operation and shift some bits." You would have to split the two numbers into 4 32-bit pieces, multiply those, and then compose the result. Or add a JVM intrinsic so that a native 128-bit operation could be used. It's not that it can't be done, it's more of a cost-benefit thing.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.