Skip to content

Commit

Permalink
Add test for encrypt_symmetric!; add encrypt_symmetric
Browse files Browse the repository at this point in the history
  • Loading branch information
sloede committed Jul 5, 2020
1 parent be7f805 commit a698b0f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions examples/6_serialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ function example_serialization()
encrypt!(encrypted2, plain2, encryptor)

sym_encryptor = Encryptor(context, sk)
sym_encrypted1 = encrypt_symmetric!(plain1, sym_encryptor)
sym_encrypted2 = encrypt_symmetric!(plain2, sym_encryptor)
sym_encrypted1 = encrypt_symmetric(plain1, sym_encryptor)
sym_encrypted2 = encrypt_symmetric(plain2, sym_encryptor)

resize!(data_stream2, save_size(sym_encrypted1))
size_sym_encrypted1 = save!(data_stream2, sym_encrypted1)
Expand Down
2 changes: 1 addition & 1 deletion src/SEAL.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ include("ciphertext.jl")
export Ciphertext, scale, scale!, parms_id, size, length, save_size, save!, load!

include("encryptor.jl")
export Encryptor, encrypt!, encrypt_symmetric!
export Encryptor, encrypt!, encrypt_symmetric, encrypt_symmetric!

include("evaluator.jl")
export Evaluator, square!, square_inplace!, relinearize!, relinearize_inplace!, rescale_to_next!,
Expand Down
2 changes: 1 addition & 1 deletion src/encryptor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function encrypt_symmetric!(destination::Ciphertext, plain::Plaintext, encryptor
@check_return_value retval
return destination
end
function encrypt_symmetric!(plain::Plaintext, encryptor::Encryptor)
function encrypt_symmetric(plain::Plaintext, encryptor::Encryptor)
destination = Ciphertext()
retval = ccall((:Encryptor_EncryptSymmetric, libsealc), Clong,
(Ptr{Cvoid}, Ptr{Cvoid}, UInt8, Ptr{Cvoid}, Ptr{Cvoid}),
Expand Down
14 changes: 8 additions & 6 deletions test/test_6_serialization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@
end
sym_encryptor = Encryptor(context, sk)

@testset "encrypt_symmetric!" begin
@test encrypt_symmetric!(plain1, sym_encryptor) isa Ciphertext
@test encrypt_symmetric!(plain2, sym_encryptor) isa Ciphertext
end
sym_encrypted1 = encrypt_symmetric!(plain1, sym_encryptor)
sym_encrypted2 = encrypt_symmetric!(plain2, sym_encryptor)
@testset "encrypt_symmetric, encrypt_symmetric!" begin
@test encrypt_symmetric(plain1, sym_encryptor) isa Ciphertext
@test encrypt_symmetric(plain2, sym_encryptor) isa Ciphertext
c = Ciphertext()
@test encrypt_symmetric!(c, plain2, sym_encryptor) == c
end
sym_encrypted1 = encrypt_symmetric(plain1, sym_encryptor)
sym_encrypted2 = encrypt_symmetric(plain2, sym_encryptor)

@testset "save! Ciphertext" begin
@test save_size(sym_encrypted1) == 131298
Expand Down

0 comments on commit a698b0f

Please sign in to comment.