narger-ef / LowMemoryFHEResNet20

Source code for the paper "Encrypted Image Classification with Low Memory Footprint using Fully Homomorphic Encryption"
https://eprint.iacr.org/2024/460
MIT License
34 stars 10 forks source link

Is it feasible to generate a RotateKeyGen without specifying EvalBootstrapSetup({4, 4}, {0, 0}, 16384)? #16

Closed yellow123Nike closed 4 months ago

yellow123Nike commented 4 months ago

image Is it feasible to generate a RotateKeyGen without specifying EvalBootstrapSetup({4, 4}, {0, 0}, 16384)?

narger-ef commented 4 months ago

Yes, you can generate rotation keys without bootstrapping. Notice that, in this case, you will not be able to perform bootstrap anymore.

yellow123Nike commented 4 months ago

image image image However, the following error occurred at res = m_cc->EvalAdd(res, m_cc->EvalRotate(sum, 1024));.

narger-ef commented 4 months ago

This happens because $1024 \neq -1024$. I think that the actual rotation for $-1024$ is $16384-1024=15360$

yellow123Nike commented 4 months ago

However, after adding context->EvalBootstrapSetup({4, 4}, {0, 0}, 16384);, this issue did not occur. Apologies, I am a beginner in FHE.

narger-ef commented 4 months ago

No worries, I am still learning, too :-P.

The bootstrapping its self uses a lot of rotation keys, perhaps that setup generates the key also for $15360$.

To confirm, check the memory when you

If they are the same, then the rotation key for $15360$ is already included in the ones used by the bootstrapping

yellow123Nike commented 4 months ago

Thank you very much!

narger-ef commented 4 months ago

Feel free to re-open if you have issues :)

yellow123Nike commented 4 months ago

image image Why is the error from layer 3 to FC so large?