Hi everybody,
First of all, this is an opinionated question after struggling with the library a little bit. It is related to some aspects of how the library works (non related to cryptography) which I have had to struggle with and I find them important to understand, but not intuitive without proper documentation. Maybe I did not find it.
Is the way Crypto Contexts are managed globally in OpenFHE documented somewhere? Personally, it seems to me one of the most fundamental aspects of how OpenFHE works that should be taken into account in any mature development and should be made known in any introduction to the technology.
When I first encounter the GenCryptoContext function, check the examples and read the comments in the header file, I expect it to create a new context, managed through the return value. It is not intuitive (to me) to understand that there is a global vector that keeps it in memory during program execution and that the next time you invoke GenCryptoContext with parameters with the same value it will return exactly the same shared pointer.
Similarly, I can expect that when I generate some EvalKey for some context, that EvalKey is somehow associated with the context. It is not intuitive (to me) to have methods that, from one context, return EvalKeys that only apply to other contexts. Only when I start to perceive unexpected behaviors and dig into the code, I discover that there is a global map where all the EvalKeys are managed sine die (regardless of their context) and that it is the Key Tags that actually allow you to determine the keys that apply in each case.
Maybe it is documented somewhere and I have not found it. Or it is not intuitive only for me. But my intuition leads me to think about other behavior. And it’s not that I don’t understand why this approach applies, once I figure out how it works. It’s simply that, if not understood, it can lead to wrong design decisions when moving from the single-file example to a real use case with several contexts, peers, etc.
Thank you very much and congratulations for your development.