About rotation key

I have a place where I need to rotate, but each rotation index is different. Do I need to generate all the required indexes at once when generating the rotation key? However, this will cause the rotation key to be too large, or will I generate the rotation key again based on the different indexes

The rotation key for each specific rotation index should be generated before invoking the rotation by that index.

You can compose multiple rotations to reduce the number of rotation keys, but this may come at the cost of performance.

Rotate(x,2)=Rotate(Rotate(x,1),1)

If I need to use an index from 0 to 1000, how should I compose it?

You can do something like this:

  1. binary-decompose 1000 into: 2^3 + 2^5 + 2^6 + 2^7 + 2^8 + 2^9
  2. generate rotations keys for: 2^3, 2^5, 2^6, 2^7, 2^8, 2^9
  3. compose your rotations as the following:
    Rotate(x,1000) = Rotate( Rotate( Rotate(Rotate(Rotate(Rotate(x, 2^3), 2^5), 2^6), 2^7), 2^8), 2^9);

So you can do it with 6 Rotations and using 6 different keys. You can consider other base decompositions which might require less number of keys. For instance, in base 3 (1000=1 + 3^3 + 3^5 + 3^6), you would need 4 rotation indices, and in base 5 (1000=3\cdot5^3 + 1\cdot5^4), you would need only 2 rotation indices.