Fastest modular exponentiation in JavaScript

后端 未结 4 1570
余生分开走
余生分开走 2021-02-01 09:38

My problem is to compute (g^x) mod p quickly in JavaScript, where ^ is exponentiation, mod is the modulo operation. All inputs are nonnega

4条回答
  •  南方客
    南方客 (楼主)
    2021-02-01 10:32

    Why not do it server side in some kind of web service using a more appropriate language like C? Times will then be time for one round trip (less than 9 seconds), plus the time for the server to calculate the result using some BigInt library in native code. This is likely to be much faster.

提交回复
热议问题