hpsc-lab / SecureArithmetic.jl

Secure arithmetic operations using fully homomorphic encryption
https://hpsc-lab.github.io/SecureArithmetic.jl
MIT License
7 stars 1 forks source link

add cleanup function to clean contexts and keys #44

Closed ArseniyKholod closed 2 months ago

ArseniyKholod commented 3 months ago

This PR adds function cleanup, that can be used for runtime cleaning of CryptoContexts and generated keys.

It should be merged after https://github.com/hpsc-lab/openfhe-julia/pull/61 and https://github.com/hpsc-lab/OpenFHE.jl/pull/64 and new releases of OpenFHE and openfhe-julia

ArseniyKholod commented 2 months ago

Thanks for figuring this out!

Besides the comments I already left, I have a more general remark:

Wouldn't a better place to hold this cleanup function be in OpenFHE.jl? Since it's only relevant for OpenFHE.jl, I feel like it should be located there, as it could also be useful for someone working with OpenFHE.jl without SA.jl.

But this is merely a question at this point, I am not sure myself what the best way to handle this would be.

Thank you for the review!

I agree with you, that this function is both useful for using OpenFHE.jl separately or within SecureArithmetic.jl, I added it here only because it seems, that we try to leave functions in OpenFHE.jl as they are in OpenFHE, which does not provide a single function to clean all the keys, so I thought it fits better in a "user-friendly interface". But it doesn't generally make a big difference for me, where to place it.

sloede commented 2 months ago

I added it here only because it seems, that we try to leave functions in OpenFHE.jl as they are in OpenFHE, which does not provide a single function to clean all the keys, so I thought it fits better in a "user-friendly interface".

Ah yes, that makes sense. OK, let's leave it here, but please also add documentation to OpenFHE.jl that describes the memory issues and how to fix them be referencing the appropriate functions and in which orse they need to be called.

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Files with missing lines Coverage Δ
examples/simple_ckks_bootstrapping.jl 100.00% <100.00%> (ø)
examples/simple_matrix_operations.jl 100.00% <100.00%> (ø)
examples/simple_real_numbers.jl 100.00% <100.00%> (ø)
src/SecureArithmetic.jl 100.00% <ø> (ø)
src/operations.jl 100.00% <100.00%> (ø)
ArseniyKholod commented 2 months ago

I added docs in README.md to explain how to deal with memory issues.