From 94bb244ed5bad3910e1d6002856a91b70623761a Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Wed, 1 May 2024 14:48:53 +0300 Subject: [PATCH 1/3] add test for circshift --- test/test_unit.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test_unit.jl b/test/test_unit.jl index a44616f..7b3052c 100644 --- a/test/test_unit.jl +++ b/test/test_unit.jl @@ -96,8 +96,10 @@ for backend in ((; name = "OpenFHE", BackendT = OpenFHEBackend, context = contex @test circshift(sv_short, 1) isa SecureVector @test circshift(sv_short, 0) isa SecureVector @test_throws ArgumentError circshift(sv_short, 1; wrap_by = :wololo) - @test circshift(sv_short, 1; wrap_by = :length) isa SecureVector - @test circshift(sv_short, -2; wrap_by = :length) isa SecureVector + @test sv_short_rotated = circshift(sv_short, 1; wrap_by = :length) isa SecureVector + @test collect(decrypt(sv_short_rotated, private_key)) ≈ [3.0, 1.0, 2.0] + @test sv_short_rotated = circshift(sv_short, -2; wrap_by = :length) isa SecureVector + @test collect(decrypt(sv_short_rotated, private_key)) ≈ [3.0, 1.0, 2.0] end @testset verbose=true showtiming=true "length" begin From bafe6c62151bb9286102f6231496b5ce9dbd8712 Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Wed, 1 May 2024 14:55:38 +0300 Subject: [PATCH 2/3] Update test_unit.jl --- test/test_unit.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/test_unit.jl b/test/test_unit.jl index 7b3052c..76cf4d8 100644 --- a/test/test_unit.jl +++ b/test/test_unit.jl @@ -96,10 +96,12 @@ for backend in ((; name = "OpenFHE", BackendT = OpenFHEBackend, context = contex @test circshift(sv_short, 1) isa SecureVector @test circshift(sv_short, 0) isa SecureVector @test_throws ArgumentError circshift(sv_short, 1; wrap_by = :wololo) - @test sv_short_rotated = circshift(sv_short, 1; wrap_by = :length) isa SecureVector - @test collect(decrypt(sv_short_rotated, private_key)) ≈ [3.0, 1.0, 2.0] - @test sv_short_rotated = circshift(sv_short, -2; wrap_by = :length) isa SecureVector - @test collect(decrypt(sv_short_rotated, private_key)) ≈ [3.0, 1.0, 2.0] + @test circshift(sv_short, 1; wrap_by = :length) isa SecureVector + @test circshift(sv_short, -2; wrap_by = :length) isa SecureVector + @test collect(decrypt(circshift(sv_short, 1; wrap_by = :length), private_key)) ≈ + [3.0, 1.0, 2.0] + @test collect(decrypt(circshift(sv_short, -2; wrap_by = :length), private_key)) ≈ + [3.0, 1.0, 2.0] end @testset verbose=true showtiming=true "length" begin From 48ae1c965a55c6451a71a5ee8092792b243db23e Mon Sep 17 00:00:00 2001 From: ArseniyKholod <119304909+ArseniyKholod@users.noreply.github.com> Date: Wed, 1 May 2024 15:23:14 +0300 Subject: [PATCH 3/3] add two more --- test/test_unit.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/test_unit.jl b/test/test_unit.jl index 76cf4d8..2f87bf9 100644 --- a/test/test_unit.jl +++ b/test/test_unit.jl @@ -102,6 +102,10 @@ for backend in ((; name = "OpenFHE", BackendT = OpenFHEBackend, context = contex [3.0, 1.0, 2.0] @test collect(decrypt(circshift(sv_short, -2; wrap_by = :length), private_key)) ≈ [3.0, 1.0, 2.0] + @test collect(decrypt(circshift(sv1, 1), private_key)) ≈ + [5.0, 0.25, 0.5, 0.75, 1.0, 2.0, 3.0, 4.0] + @test collect(decrypt(circshift(sv1, -2), private_key)) ≈ + [0.75, 1.0, 2.0, 3.0, 4.0, 5.0, 0.25, 0.5] end @testset verbose=true showtiming=true "length" begin