# Determine rotation indices when deserializing keys?

**URL:** <https://openfhe.discourse.group/t/determine-rotation-indices-when-deserializing-keys/1243>\
**Category:** Library Questions\
**Created:** [April 30, 2024, 9:19pm UTC](https://openfhe.discourse.group/t/determine-rotation-indices-when-deserializing-keys/1243 "2024-04-30T21:19:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jkav77](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@jkav77](https://openfhe.discourse.group/u/jkav77)\
**Post date:** [April 30, 2024, 9:19pm UTC](https://openfhe.discourse.group/t/determine-rotation-indices-when-deserializing-keys/1243/1 "2024-04-30T21:19:28Z")

</div>

When deserializing rotation keys, is there a way to determine which rotation indices are supported by the keys without knowing in advance? I’ve looked at `GetExistingEvalAutomorphismKeyIndices(const std::string &keyTag)`, but it returns the automorphism indices and not the rotation indices. I can find the automorphism index for a given rotation index using ` FindAutomorphismIndex(const usint idx) const`, but I didn’t see a straightforward way to determine the rotation indices from the automorphism indices.

---

<div class="post-metadata">

**Author:** ![Caesar](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/caesar/32/63_2.png) [@Caesar](https://openfhe.discourse.group/u/Caesar)\
**Post date:** [May 2, 2024, 1:00pm UTC](https://openfhe.discourse.group/t/determine-rotation-indices-when-deserializing-keys/1243/2 "2024-05-02T13:00:21Z")

</div>

`FindAutomorphismIndex` converts the rotation index into an automorphism index by raising a certain generator (5) to the rotation index modulo the cyclotomic ring index m=2N, where N is the ring dimension. To reverse that, all you need to do is solving the discrete log problem for a small modulus m, and this should be easy to do.  
Alternatively, you can keep a lookup table for rotation and automorphism indices.

Note that the generator OpenFHE uses depends on the FHE scheme used, and the sign of the rotation index, but for your purpose, I think generator 5 should serve your purpose.
