二楼说的对,滑动窗口的算法原理如下:其中d表示非零窗口的最大长度(即窗口占几个bit)
The Sliding Window Method
Input: M; e; n.
Output: C = M^e (mod n).
1. Compute and store M^w (mod n) for all w = 3, 5, 7, ... , 2^d - 1.
2. Decompose e into zero and nonzero windows F(i) of length L(F(i)),for i = 0, 1, 2, ... , p - 1.
3. C := M^F(p-1) (mod n)
4. for i = p - 2 down to 0
4a. C := C^(2^L(F(i))) (mod n)
4b. if F(i)不等于0, then C := C * M^F(i) (mod n)
5. return C