From e99f57376754fcad7610b2442659b109977c13db Mon Sep 17 00:00:00 2001 From: Michael Schlottke-Lakemper Date: Fri, 19 Jan 2024 13:30:52 +0100 Subject: [PATCH] Add `!` suffix to functions that modify their arguments --- examples/simple_ckks_bootstrapping.jl | 4 ++-- examples/simple_real_numbers.jl | 4 ++-- src/SecureArithmetic.jl | 2 +- src/openfhe.jl | 6 +++--- src/unencrypted.jl | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/examples/simple_ckks_bootstrapping.jl b/examples/simple_ckks_bootstrapping.jl index beb6f94..5a316db 100644 --- a/examples/simple_ckks_bootstrapping.jl +++ b/examples/simple_ckks_bootstrapping.jl @@ -8,8 +8,8 @@ using OpenFHE function simple_ckks_bootstrapping(context) public_key, private_key = generate_keys(context) - init_multiplication(context, private_key) - init_bootstrapping(context, private_key) + init_multiplication!(context, private_key) + init_bootstrapping!(context, private_key) x = [0.25, 0.5, 0.75, 1.0, 2.0, 3.0, 4.0, 5.0] encoded_length = length(x) diff --git a/examples/simple_real_numbers.jl b/examples/simple_real_numbers.jl index b8a04c7..655ca2a 100644 --- a/examples/simple_real_numbers.jl +++ b/examples/simple_real_numbers.jl @@ -4,8 +4,8 @@ using OpenFHE function simple_real_numbers(context) public_key, private_key = generate_keys(context) - init_multiplication(context, private_key) - init_rotation(context, private_key, [1, -2]) + init_multiplication!(context, private_key) + init_rotation!(context, private_key, [1, -2]) x1 = [0.25, 0.5, 0.75, 1.0, 2.0, 3.0, 4.0, 5.0] diff --git a/src/SecureArithmetic.jl b/src/SecureArithmetic.jl index 28eaa0c..055f6f1 100644 --- a/src/SecureArithmetic.jl +++ b/src/SecureArithmetic.jl @@ -9,7 +9,7 @@ export SecureContext, SecureVector, PlainVector export Unencrypted, OpenFHEBackend # Crypto operations -export generate_keys, init_multiplication, init_rotation, init_bootstrapping +export generate_keys, init_multiplication!, init_rotation!, init_bootstrapping! export encrypt, decrypt, decrypt!, bootstrap! include("types.jl") diff --git a/src/openfhe.jl b/src/openfhe.jl index cba4ec3..172b7aa 100644 --- a/src/openfhe.jl +++ b/src/openfhe.jl @@ -21,21 +21,21 @@ function generate_keys(context::SecureContext{<:OpenFHEBackend}) public_key, private_key end -function init_multiplication(context::SecureContext{<:OpenFHEBackend}, private_key) +function init_multiplication!(context::SecureContext{<:OpenFHEBackend}, private_key) cc = get_crypto_context(context) OpenFHE.EvalMultKeyGen(cc, private_key.private_key) nothing end -function init_rotation(context::SecureContext{<:OpenFHEBackend}, private_key, shifts) +function init_rotation!(context::SecureContext{<:OpenFHEBackend}, private_key, shifts) cc = get_crypto_context(context) OpenFHE.EvalRotateKeyGen(cc, private_key.private_key, shifts) nothing end -function init_bootstrapping(context::SecureContext{<:OpenFHEBackend}, private_key) +function init_bootstrapping!(context::SecureContext{<:OpenFHEBackend}, private_key) cc = get_crypto_context(context) ring_dimension = OpenFHE.GetRingDimension(cc) num_slots = div(ring_dimension, 2) diff --git a/src/unencrypted.jl b/src/unencrypted.jl index 1ce6ebe..63092a2 100644 --- a/src/unencrypted.jl +++ b/src/unencrypted.jl @@ -6,9 +6,9 @@ function generate_keys(context::SecureContext{<:Unencrypted}) PublicKey(context, nothing), PrivateKey(context, nothing) end -init_multiplication(context::SecureContext{<:Unencrypted}, private_key) = nothing -init_rotation(context::SecureContext{<:Unencrypted}, private_key, shifts) = nothing -init_bootstrapping(context::SecureContext{<:Unencrypted}, private_key) = nothing +init_multiplication!(context::SecureContext{<:Unencrypted}, private_key) = nothing +init_rotation!(context::SecureContext{<:Unencrypted}, private_key, shifts) = nothing +init_bootstrapping!(context::SecureContext{<:Unencrypted}, private_key) = nothing function PlainVector(context::SecureContext{<:Unencrypted}, data::Vector{<:Real}) plain_vector = PlainVector(data, context)