Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
hoang-gia.nguyen
dap-pattern-search-standalone
Commits
1369d029
Commit
1369d029
authored
May 05, 2023
by
Hoang Gia NGUYEN
Browse files
testing
parent
d4e94487
Changes
1000
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
2118 additions
and
349 deletions
+2118
-349
docker/Dockerfile
docker/Dockerfile
+14
-7
docker/bigpiseal3.5.1/.gitignore
docker/bigpiseal3.5.1/.gitignore
+0
-342
docker/bigpiseal3.5.1/.vscode/settings.json
docker/bigpiseal3.5.1/.vscode/settings.json
+5
-0
docker/bigpiseal3.5.1/bin/ANN/v1/.~lock.w1.csv#
docker/bigpiseal3.5.1/bin/ANN/v1/.~lock.w1.csv#
+1
-0
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_decrypt_result_v1
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_decrypt_result_v1
+0
-0
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_decrypt_result_v1.cpp
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_decrypt_result_v1.cpp
+139
-0
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_decrypt_v1
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_decrypt_v1
+0
-0
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_decrypt_v1.cpp
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_decrypt_v1.cpp
+78
-0
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_encrypt_v1
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_encrypt_v1
+0
-0
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_encrypt_v1.cpp
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_encrypt_v1.cpp
+53
-0
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_evaluate_v1
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_evaluate_v1
+0
-0
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_evaluate_v1 copy.cpp
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_evaluate_v1 copy.cpp
+515
-0
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_evaluate_v1.cpp
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_evaluate_v1.cpp
+549
-0
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_genkey_v1
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_genkey_v1
+0
-0
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_genkey_v1.cpp
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_genkey_v1.cpp
+34
-0
docker/bigpiseal3.5.1/bin/ANN/v1/CMakeLists.txt
docker/bigpiseal3.5.1/bin/ANN/v1/CMakeLists.txt
+171
-0
docker/bigpiseal3.5.1/bin/ANN/v1/csv_api.cpp
docker/bigpiseal3.5.1/bin/ANN/v1/csv_api.cpp
+497
-0
docker/bigpiseal3.5.1/bin/ANN/v1/csv_api.h
docker/bigpiseal3.5.1/bin/ANN/v1/csv_api.h
+38
-0
docker/bigpiseal3.5.1/bin/ANN/v1/decrypt.sh
docker/bigpiseal3.5.1/bin/ANN/v1/decrypt.sh
+12
-0
docker/bigpiseal3.5.1/bin/ANN/v1/decrypt_result.sh
docker/bigpiseal3.5.1/bin/ANN/v1/decrypt_result.sh
+12
-0
No files found.
Too many changes to show.
To preserve performance only
1000 of 1000+
files are displayed.
Plain diff
Email patch
docker/Dockerfile
View file @
1369d029
FROM
ubuntu:20.04
#COPY ../bigpiseal3.5.1 opt/bigpiseal3.5.1
COPY
docker
/bigpiseal3.5.1 opt/bigpiseal3.5.1
COPY
..
/bigpiseal3.5.1 opt/bigpiseal3.5.1
#datalake for testing
#COPY ../datalake opt/datalake
COPY
docker
/datalake opt/datalake
COPY
..
/datalake opt/datalake
#COPY bigpiseal3.5.1/bin/patternSearch/v2/keys keys
...
...
@@ -54,18 +54,25 @@ RUN set -eux; \
#WORKDIR /usr/src/
WORKDIR
/opt/datalake
#
WORKDIR /opt/datalake
RUN
mkdir
-p
/home/spring
EXPOSE
19191
#ARG JAR_FILE=../target/*.jar
#COPY ${JAR_FILE} /home/spring/app.jar
#COPY ${JAR_FILE} ../
ARG
JAR_FILE=./target/*.jar
COPY
${JAR_FILE} /home/spring/app.jar
#RUN cd ../
COPY
../target/*.jar home/spring/app.jar
RUN
chown
-R
bigpi:bigpi /home/spring
USER
bigpi:bigpi
ENTRYPOINT
["java","-Xms100m", "-Xmx100m", "-Dspring.profiles.active=prod", "-DPORT=${APP_PORT}," "-DCONFIG=false", "-DEUREKA=false", "-jar","/home/app.jar"]
WORKDIR
/opt/datalake
EXPOSE
19191
ENTRYPOINT
["java","-Xms100m", "-Xmx100m", "-Dspring.profiles.active=prod", "-DPORT=${APP_PORT}," "-DCONFIG=false", "-DEUREKA=false", "-jar","/home/spring/app.jar"]
docker/bigpiseal3.5.1/.gitignore
deleted
100644 → 0
View file @
d4e94487
# Other stuff
cmake/SEALConfig.cmake
cmake/SEALConfigVersion.cmake
cmake/SEALTargets.cmake
native/src/seal/util/config.h
native/src/gsl
**/CMakeCache.txt
**/CMakeFiles
**/Makefile
**/.config
**/autom4te.cache/*
**/cmake_install.cmake
**/install_manifest.txt
.ycm_extra_conf.py
.vimrc
.lvimrc
.local_vimrc
**/*.code-workspace
**/.vscode
**/build
**/*.build
**/compile_commands.json
**/.DS_Store
**/GSL
**/*.args.json
thirdparty/zlib/*
!thirdparty/zlib/CMakeLists.txt
thirdparty/msgsl/*
!thirdparty/msgsl/CMakeLists.txt
thirdparty/googletest/*
!thirdparty/googletest/CMakeLists.txt
dotnet/nuget/nuget.exe
dotnet/nuget/SEALNet.nuspec
dotnet/nuget/SEALNet-multi.nuspec
dotnet/nuget/SEALNet.targets
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ib/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Typescript v1 declaration files
typings/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
docker/bigpiseal3.5.1/.vscode/settings.json
0 → 100644
View file @
1369d029
{
"files.associations"
:
{
"shared_mutex"
:
"cpp"
}
}
\ No newline at end of file
docker/bigpiseal3.5.1/bin/ANN/v1/.~lock.w1.csv#
0 → 100644
View file @
1369d029
,hgnguyen,is233218,24.11.2022 15:12,file:///home/hgnguyen/.config/libreoffice/4;
\ No newline at end of file
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_decrypt_result_v1
0 → 100755
View file @
1369d029
File added
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_decrypt_result_v1.cpp
0 → 100644
View file @
1369d029
#include <iomanip>
#include "seal_api.h"
#include "util.h"
using
namespace
seal
;
using
namespace
std
;
string
ciphertext_name
;
string
key_dir
;
// bool decrypt(size_t poly_d, size_t p_modulus, int &sample_size, string &ciphertext_dir);
bool
decrypt
(
int
&
sample_size
,
string
&
ciphertext_dir
);
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
4
)
{
// cout << "[ERROR] please enter /full/path/to/file/to/decrypt full/path/key " << endl;
// cout << "[ERROR] please enter prefix_file_to_decrypt full/path/key /full/path/to/storage" << endl;
// cout << "[ERROR] please enter a ciphertext file path, sample size and secret key path" << endl;
return
-
1
;
}
else
{
string
dir
=
argv
[
1
];
int
sample_size
=
atol
(
argv
[
2
]);
key_dir
=
argv
[
3
];
bool
result_str
=
decrypt
(
sample_size
,
dir
);
cout
<<
result_str
<<
endl
;
return
0
;
}
}
bool
decrypt
(
int
&
sample_size
,
string
&
ciphertext_dir
)
{
struct
decryptor_t
decr
;
init_operator_batching
(
decr
,
key_dir
);
bool
isContain
=
false
;
if
(
sample_size
<=
decr
.
bcode
->
slot_count
()
/
2
)
{
Ciphertext
cipher_matrix
;
vector
<
int64_t
>
pod_matrix
;
load_ciphertext
(
decr
,
cipher_matrix
,
ciphertext_dir
);
pod_matrix
=
decrypt_ciphermatrix
(
decr
,
cipher_matrix
);
// cout << pod_matrix.size() << endl;
int
no_dual_vectors
=
(
decr
.
bcode
->
slot_count
()
/
2
)
/
(
sample_size
);
vector
<
int64_t
>
v1
,
v2
;
for
(
size_t
i
=
0
;
i
<
no_dual_vectors
*
sample_size
;
i
++
)
{
v1
.
push_back
(
pod_matrix
[
i
]);
v2
.
push_back
(
pod_matrix
[(
pod_matrix
.
size
()
/
2
)
+
i
]);
}
int64_t
sum
=
0
;
if
(
isContain
==
false
)
{
// cout << "1 : ";
for
(
size_t
i
=
0
;
i
<
v1
.
size
();
i
++
)
{
// cout << v1[i];
if
((
i
+
1
)
%
sample_size
==
0
)
{
// cout << endl;
if
(
i
<
v1
.
size
()
-
1
)
{
// cout << ((i + 1) / 40) + 1 << " : ";
}
}
else
{
// cout << ", ";
}
if
(
v1
[
i
]
==
0
)
{
sum
=
sum
+
1
;
}
else
{
sum
=
0
;
}
if
(
sum
==
sample_size
)
{
isContain
=
true
;
}
}
}
// cout << endl;
if
(
isContain
==
false
)
{
sum
=
0
;
// cout << (v2.size() + 1) / 40 + 1 << " : ";
for
(
size_t
i
=
0
;
i
<
v2
.
size
();
i
++
)
{
// cout << v2[i];
if
((
i
+
1
)
%
sample_size
==
0
)
{
// cout << endl;
if
(
i
<
v2
.
size
()
-
1
)
{
// cout << ((v2.size() + i + 1) / 40) + 1 << " : ";
}
}
else
{
// cout << ", ";
}
if
(
v2
[
i
]
==
0
)
{
sum
=
sum
+
1
;
}
else
{
sum
=
0
;
}
if
(
sum
==
sample_size
)
{
isContain
=
true
;
}
}
}
}
else
{
// cout << endl << "Sample size is too large" << endl;
}
delete_operator_batching
(
decr
);
return
isContain
;
}
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_decrypt_v1
0 → 100755
View file @
1369d029
File added
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_decrypt_v1.cpp
0 → 100644
View file @
1369d029
#include <iomanip>
#include "seal_api.h"
#include "util.h"
using
namespace
seal
;
using
namespace
std
;
string
ciphertext_name
;
string
key_dir
;
// vector<int64_t> decrypt(size_t poly_d, size_t p_modulus, int &sample_size, string &ciphertext_dir);
vector
<
double
>
decrypt
(
int
&
sample_size
,
string
&
ciphertext_dir
);
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
4
)
{
// cout << "[ERROR] please enter /full/path/to/file/to/decrypt full/path/key " << endl;
// cout << "[ERROR] please enter prefix_file_to_decrypt full/path/key /full/path/to/storage" << endl;
cout
<<
"[ERROR] please enter a ciphertext file path, sample size and secret key path"
<<
endl
;
return
-
1
;
}
else
{
string
dir
=
argv
[
1
];
int
sample_size
=
atol
(
argv
[
2
]);
key_dir
=
argv
[
3
];
vector
<
double
>
result
=
decrypt
(
sample_size
,
dir
);
for
(
int
i
=
0
;
i
<
result
.
size
();
++
i
)
{
std
::
cout
<<
result
[
i
]
<<
' '
;
}
std
::
cout
<<
endl
;
return
0
;
}
}
vector
<
double
>
decrypt
(
int
&
sample_size
,
string
&
ciphertext_dir
)
{
struct
cdecryptor_t
decr
;
// init_operator_batching(decr, key_dir);
init_operator_ckks
(
decr
,
key_dir
);
// init_operator_batching(2048, 4294967296, decr, key_dir);
// init_operator_batching(4096, 4294967296, decr, key_dir);
// init_operator_batching(8192, 4294967296, decr, key_dir);
// init_operator_batching(16384, 4294967296, decr, key_dir);
// init_operator_batching(32768, 4294967296, decr, key_dir);
vector
<
double
>
v
;
if
(
sample_size
<=
decr
.
ccode
->
slot_count
()
/
2
)
{
Ciphertext
cipher_matrix
;
vector
<
double
>
pod_matrix
;
load_ciphertext_ckks
(
decr
,
cipher_matrix
,
ciphertext_dir
);
// pod_matrix = decrypt_ciphermatrix(decr, cipher_matrix);
// pod_matrix = decrypt_ciphermatrix_ckks(decr, cipher_matrix);
decrypt_ciphertext_ckks
(
decr
,
cipher_matrix
,
pod_matrix
);
// void decrypt_ciphertext_ckks(struct cdecryptor_t& op_st, seal::Ciphertext& ct, std::vector<double>& pt_val);
for
(
size_t
i
=
0
;
i
<
sample_size
;
i
++
)
{
v
.
push_back
(
pod_matrix
[
i
]);
}
}
else
{
// cout << endl << "Sample size is too large" << endl;
}
// delete_operator_batching(decr);
delete_operator_ckks
(
decr
);
return
v
;
}
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_encrypt_v1
0 → 100755
View file @
1369d029
File added
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_encrypt_v1.cpp
0 → 100644
View file @
1369d029
#include "seal_api.h"
using
namespace
seal
;
using
namespace
std
;
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
6
)
{
// cout << "[ERROR] please enter 1 plaintext values, prefix pathstorage(exists) " << endl;
cout
<<
"[ERROR] please enter plaintext vector value (eg. 75 67 8 23 076 2 23), output ciphertext file name or "
"prefix, ciphertext output file directory, sample size and public key path"
<<
endl
;
return
-
1
;
}
else
{
string
plaintext
=
argv
[
1
];
string
ciphertext_name
=
argv
[
2
];
string
ciphertext_dir
=
argv
[
3
];
int
sample_size
=
atol
(
argv
[
4
]);
string
key_dir
=
argv
[
5
];
struct
cencryptor_t
encr
;
init_operator_ckks
(
encr
,
key_dir
);
stringstream
ss
;
ss
<<
plaintext
;
vector
<
double
>
pod_matrix
;
double
x
=
0
;
while
(
ss
>>
x
)
{
pod_matrix
.
push_back
(
x
);
}
if
(
pod_matrix
.
size
()
<=
encr
.
ccode
->
slot_count
()
&&
pod_matrix
.
size
()
>=
sample_size
)
{
Ciphertext
encrypted_matrix
;
init_ciphertext_ckks
(
encr
,
pod_matrix
,
encrypted_matrix
);
save_ciphertext
(
encrypted_matrix
,
ciphertext_dir
+
"/"
+
ciphertext_name
+
".ct"
);
delete_operator_ckks
(
encr
);
return
0
;
}
else
{
delete_operator_ckks
(
encr
);
return
-
1
;
}
delete_operator_ckks
(
encr
);
return
0
;
}
}
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_evaluate_v1
0 → 100755
View file @
1369d029
File added
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_evaluate_v1 copy.cpp
0 → 100644
View file @
1369d029
#include <iostream>
#include "seal_api.h"
#include "util.h"
// #include <algorithm>
// #include <iterator>
// #include <vector>
// #include <filesystem>
using
namespace
seal
;
using
namespace
std
;
void
sub_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
,
Ciphertext
&
ct_out
);
void
add_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
,
Ciphertext
&
ct_out
);
void
multiply_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
,
Ciphertext
&
ct_out
);
bool
is_number
(
const
string
&
s
);
void
printStrVector
(
const
vector
<
string
>
&
v
);
vector
<
vector
<
string
>>
split_ends
(
const
vector
<
string
>
&
data
,
const
vector
<
int
>
&
ends
);
void
multiply_ciphertexts
(
struct
evaluator_t
&
op_st
,
vector
<
Ciphertext
>
&
cts
,
Ciphertext
&
ct_out
);
void
relinearize_inplace
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
);
void
rescale_to_next_inplace
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
);
void
multiply_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
);
void
relinearize
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
,
Ciphertext
&
ct_out
);
void
sub_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
);
void
negate_inplace__ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
);
void
add_plain_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
struct
Ciphertext
&
ct
,
const
Plaintext
&
plain
);
void
multiply_plain_inplace
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
,
const
Plaintext
&
plain
);
void
add_many_ciphertext
(
struct
evaluator_t
&
op_st
,
vector
<
Ciphertext
>
&
cts
,
Ciphertext
&
ct_out
);
void
exponentiate_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
,
uint64_t
&
exponent
);
void
sub_plain_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
,
const
Plaintext
&
plain
);
void
mod_switch_to_next_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
);
int
simpleCheck
(
string
&
source
,
vector
<
string
>
&
data
,
string
&
result_name
,
string
&
result_dir
,
int
&
sample_size
,
string
&
key_dir
);
int
checkSq
(
string
&
source
,
vector
<
string
>
&
data
,
string
&
result_name
,
string
&
result_dir
,
int
&
sample_size
,
string
&
key_dir
);
Ciphertext
check
(
string
&
source
,
vector
<
string
>
&
data
,
string
&
result_name
,
string
&
result_dir
,
int
&
sample_size
,
string
&
key_dir
,
struct
encryptor_t
&
encr
,
struct
evaluator_t
&
eval
);
// string relink_key_path;
// string galois_key_path;
// string public_key_path;
string
key_dir
=
""
;
int
main
(
int
argc
,
char
**
argv
)
{
// input processing - begin
// string result_name = argv[argc - 6];
// string result_dir = argv[argc - 5];
// int sample_size = atoi(argv[argc - 4]);
// relink_key_path = argv[argc - 3];
// galois_key_path = argv[argc - 2];
// public_key_path = argv[argc - 1];
string
source
=
argv
[
1
];
string
result_name
=
argv
[
argc
-
4
];
string
result_dir
=
argv
[
argc
-
3
];
int
sample_size
=
atoi
(
argv
[
argc
-
2
]);
key_dir
=
argv
[
argc
-
1
];
vector
<
string
>
data
;
for
(
int
i
=
2
;
i
<
argc
-
4
;
i
++
)
{
data
.
push_back
(
argv
[
i
]);
}
// if (source == "" || data.size() == 0 || result_name == "" || result_dir == "" || sample_size == 0 ||
// relink_key_path == "" || galois_key_path == "" || public_key_path == "")
if
(
source
==
""
||
data
.
size
()
==
0
||
result_name
==
""
||
result_dir
==
""
||
sample_size
==
0
||
key_dir
==
""
)
{
// error handling
cout
<<
"[ERROR] please enter a source path, data paths, output ciphertext file name or prefix, output "
"ciphertext directory, sample size, linking key path, galois key path and public key path"
<<
endl
;
return
-
1
;
}
// input processing - end
// simple algo
// int result = simpleCheck(source, data, result_name, result_dir, sample_size, key_dir);
// sequence algo
int
result
=
checkSq
(
source
,
data
,
result_name
,
result_dir
,
sample_size
,
key_dir
);
// error handling
if
(
result
==
-
1
)
{
fprintf
(
stderr
,
"error!
\n
"
);
}
else
{
cout
<<
"done"
;
}
// checkSq(source, data, result_name, result_dir, sample_size, relink_key_path, galois_key_path, public_key_path);
return
result
;
}
int
simpleCheck
(
string
&
source
,
vector
<
string
>
&
data
,
string
&
result_name
,
string
&
result_dir
,
int
&
sample_size
,
string
&
key_dir
)
{
struct
evaluator_t
eval
;
init_operator_batching
(
eval
,
key_dir
);
struct
encryptor_t
encr
;
init_operator_batching
(
encr
,
key_dir
);
// cout << sample_size*data.size() << endl;
// cout << encr.bcode->slot_count() << endl;
if
(
sample_size
*
data
.
size
()
>
encr
.
bcode
->
slot_count
()
||
sample_size
>
encr
.
bcode
->
slot_count
()
/
2
)
{
// error handling
delete_operator_batching
(
encr
);
delete_operator_batching
(
eval
);
return
-
1
;
}
else
{
Ciphertext
encrypted_result_matrix
;
vector
<
int64_t
>
result_matrix
;
init_ciphermatrix
(
encr
,
result_matrix
,
encrypted_result_matrix
);
vector
<
int64_t
>
dummy_matrix
;
for
(
size_t
i
=
0
;
i
<
sample_size
;
i
++
)
{
dummy_matrix
.
push_back
(
1
);
}
Ciphertext
encrypted_dummy_matrix
;
init_ciphermatrix
(
encr
,
dummy_matrix
,
encrypted_dummy_matrix
);
// normalize input data if its size is odd
int
normalized_data_size
;
if
(
data
.
size
()
%
2
==
0
)
{
normalized_data_size
=
data
.
size
();
}
else
{
normalized_data_size
=
data
.
size
()
+
1
;
}
int
required_range
=
normalized_data_size
*
sample_size
;
int
required_no_row_elements
=
required_range
/
2
;
int
required_range_row
=
required_range
/
2
;
// create padding matrix
int
padding_slots
=
(
encr
.
bcode
->
slot_count
()
/
2
)
-
required_range_row
;
vector
<
int64_t
>
padding_matrix
(
encr
.
bcode
->
slot_count
(),
0ULL
);
for
(
size_t
i
=
0
;
i
<
padding_slots
;
i
++
)
{
padding_matrix
[
required_no_row_elements
+
i
]
=
1
;
padding_matrix
[
encr
.
bcode
->
slot_count
()
-
i
]
=
1
;
}
Ciphertext
encrypted_padding_matrix
;
init_ciphermatrix
(
encr
,
padding_matrix
,
encrypted_padding_matrix
);
if
(
required_range_row
<=
encr
.
bcode
->
slot_count
()
&&
required_range_row
>
0
)
{
for
(
int
index
=
0
;
index
<
normalized_data_size
/
2
;
index
++
)
{
Ciphertext
ct1
,
ct2
,
ct3
;
Ciphertext
temp1
,
temp2
;
// cout << "[INFO] loading ciphertext 1" << endl;
load_ciphertext
(
eval
,
ct1
,
source
);
// cout << "[INFO] loading ciphertext 2" << endl;
load_ciphertext
(
eval
,
ct2
,
data
.
at
(
index
));
sub_ciphertext
(
eval
,
ct1
,
ct2
,
temp1
);
if
((
normalized_data_size
/
2
)
+
index
<
data
.
size
())
{
// cout << "[INFO] loading ciphertext 3" << endl;
load_ciphertext
(
eval
,
ct3
,
data
.
at
((
normalized_data_size
/
2
)
+
index
));
sub_ciphertext
(
eval
,
ct1
,
ct3
,
temp2
);
}
else
{
// add dummy vector for oddy data
temp2
=
encrypted_dummy_matrix
;
}
eval
.
eval
->
rotate_columns_inplace
(
temp2
,
eval
.
gk
);
add_ciphertext
(
eval
,
temp1
,
temp2
,
temp1
);
add_ciphertext
(
eval
,
temp1
,
encrypted_result_matrix
,
encrypted_result_matrix
);
// avoid the last shift
if
(
index
+
1
!=
(
normalized_data_size
/
2
))
{
eval
.
eval
->
rotate_rows_inplace
(
encrypted_result_matrix
,
-
sample_size
,
eval
.
gk
);
}
}
// add renmaining padding slots
add_ciphertext
(
eval
,
encrypted_result_matrix
,
encrypted_padding_matrix
,
encrypted_result_matrix
);
}
save_ciphertext
(
encrypted_result_matrix
,
result_dir
+
"/"
+
result_name
+
".ct"
);
delete_operator_batching
(
encr
);
delete_operator_batching
(
eval
);
return
0
;
}
}
// int checkSq(
// string &source, vector<string> &data, string &result_name, string &result_dir, int &sample_size,
// string &relink_key_path, string &galois_key_path, string &public_key_path)
int
checkSq
(
string
&
source
,
vector
<
string
>
&
data
,
string
&
result_name
,
string
&
result_dir
,
int
&
sample_size
,
string
&
key_dir
)
{
struct
evaluator_t
eval
;
// init_operator_batching(2048, 4294967296, eval, relink_key_path, galois_key_path);
// init_operator_batching(4096, 4294967296, eval, relink_key_path, galois_key_path);
// init_operator_batching(8192, 4294967296, eval, relink_key_path, galois_key_path);
// init_operator_batching(16384, 4294967296, eval, relink_key_path, galois_key_path);
// init_operator_batching(32768, 4294967296, eval, relink_key_path, galois_key_path);
init_operator_batching
(
eval
,
key_dir
);
struct
encryptor_t
encr
;
// init_operator_batching(4096, 4294967296, encr, public_key_path);
// init_operator_batching(8192, 4294967296, encr, public_key_path);
// init_operator_batching(16384, 4294967296, encr, public_key_path);
// init_operator_batching(32768, 4294967296, encr, public_key_path);
init_operator_batching
(
encr
,
key_dir
);
// if (sample_size*data.size() > encr.bcode->slot_count() || sample_size > encr.bcode->slot_count()/2)
if
(
sample_size
>
encr
.
bcode
->
slot_count
()
/
2
)
{
// error handling
delete_operator_batching
(
encr
);
delete_operator_batching
(
eval
);
return
-
1
;
}
else
{
// struct evaluator_t eval;
// // init_operator_batching(2048, 4294967296, eval, relink_key_path, galois_key_path);
// // init_operator_batching(4096, 4294967296, eval, relink_key_path, galois_key_path);
// init_operator_batching(8192, 4294967296, eval, relink_key_path, galois_key_path);
// // init_operator_batching(16384, 4294967296, eval, relink_key_path, galois_key_path);
// // init_operator_batching(32768, 4294967296, eval, relink_key_path, galois_key_path);
// struct encryptor_t encr;
// // init_operator_batching(4096, 4294967296, encr, public_key_path);
// init_operator_batching(8192, 4294967296, encr, public_key_path);
// // init_operator_batching(16384, 4294967296, encr, public_key_path);
// // init_operator_batching(32768, 4294967296, encr, public_key_path);
int
capacity
=
(
encr
.
bcode
->
slot_count
())
/
sample_size
;
// cout << capacity << endl;
// vector<string> v_temp;
// vector<string> v_v_temp;
// Ciphertext result;
vector
<
Ciphertext
>
v_result
;
int
nSq
=
data
.
size
()
/
capacity
;
for
(
size_t
i
=
0
;
i
<
nSq
;
i
++
)
{
Ciphertext
result
;
// cout << "sq : " << i << endl;
vector
<
string
>
v_temp
;
for
(
size_t
j
=
0
;
j
<
capacity
;
j
++
)
{
string
str
=
data
.
back
();
v_temp
.
push_back
(
str
);
data
.
pop_back
();
}
if
(
i
==
0
)
{
// cout << "sq : init" << endl;
// result = check(
// source, v_temp, result_name, result_dir, sample_size, relink_key_path, galois_key_path,
// public_key_path, encr, eval);
result
=
check
(
source
,
v_temp
,
result_name
,
result_dir
,
sample_size
,
key_dir
,
encr
,
eval
);
v_result
.
push_back
(
result
);
}
else
{
// cout << "sq : other" << endl;
// Ciphertext result2 = check(
// source, v_temp, result_name, result_dir, sample_size, relink_key_path, galois_key_path,
// public_key_path, encr, eval);
// multiply_ciphertext(eval, result2, result, result);
// relinearize_inplace(eval, result);
// result = check(
// source, v_temp, result_name, result_dir, sample_size, relink_key_path, galois_key_path,
// public_key_path, encr, eval);
result
=
check
(
source
,
v_temp
,
result_name
,
result_dir
,
sample_size
,
key_dir
,
encr
,
eval
);
v_result
.
push_back
(
result
);
}
}
if
(
data
.
size
()
%
capacity
!=
0
)
{
// cout << "oddy!!! " << endl;
// Ciphertext result = check(
// source, data, result_name, result_dir, sample_size, relink_key_path, galois_key_path,
// public_key_path, encr, eval);
Ciphertext
result
=
check
(
source
,
data
,
result_name
,
result_dir
,
sample_size
,
key_dir
,
encr
,
eval
);
// multiply_ciphertext(eval, result2, result, result);
// relinearize_inplace(eval, result);
v_result
.
push_back
(
result
);
}
Ciphertext
result
;
multiply_ciphertexts
(
eval
,
v_result
,
result
);
relinearize_inplace
(
eval
,
result
);
save_ciphertext
(
result
,
result_dir
+
"/"
+
result_name
+
".ct"
);
delete_operator_batching
(
encr
);
delete_operator_batching
(
eval
);
return
0
;
}
}
// Ciphertext check(
// string &source, vector<string> &data, string &result_name, string &result_dir, int &sample_size,
// string &relink_key_path, string &galois_key_path, string &public_key_path, struct encryptor_t &encr,
// struct evaluator_t &eval)
Ciphertext
check
(
string
&
source
,
vector
<
string
>
&
data
,
string
&
result_name
,
string
&
result_dir
,
int
&
sample_size
,
string
&
key_dir
,
struct
encryptor_t
&
encr
,
struct
evaluator_t
&
eval
)
{
// if (source == "" || data.size() == 0 || result_name == "" || result_dir == "" || sample_size == 0)
// {
// // error handling
// // return -1;
// }
// else
// {
Ciphertext
encrypted_result_matrix
;
vector
<
int64_t
>
result_matrix
;
init_ciphermatrix
(
encr
,
result_matrix
,
encrypted_result_matrix
);
vector
<
int64_t
>
dummy_matrix
;
for
(
size_t
i
=
0
;
i
<
sample_size
;
i
++
)
{
dummy_matrix
.
push_back
(
1
);
}
Ciphertext
encrypted_dummy_matrix
;
init_ciphermatrix
(
encr
,
dummy_matrix
,
encrypted_dummy_matrix
);
// normalize input data if its size is odd
int
normalized_data_size
;
if
(
data
.
size
()
%
2
==
0
)
{
normalized_data_size
=
data
.
size
();
}
else
{
normalized_data_size
=
data
.
size
()
+
1
;
}
int
required_range
=
normalized_data_size
*
sample_size
;
int
required_no_row_elements
=
required_range
/
2
;
int
required_range_row
=
required_range
/
2
;
// create padding matrix
int
padding_slots
=
(
encr
.
bcode
->
slot_count
()
/
2
)
-
required_range_row
;
vector
<
int64_t
>
padding_matrix
(
encr
.
bcode
->
slot_count
(),
0ULL
);
for
(
size_t
i
=
0
;
i
<
padding_slots
;
i
++
)
{
padding_matrix
[
required_no_row_elements
+
i
]
=
1
;
padding_matrix
[(
encr
.
bcode
->
slot_count
()
-
1
)
-
i
]
=
1
;
}
Ciphertext
encrypted_padding_matrix
;
init_ciphermatrix
(
encr
,
padding_matrix
,
encrypted_padding_matrix
);
if
(
required_range_row
<=
encr
.
bcode
->
slot_count
()
&&
required_range_row
>
0
)
{
for
(
int
index
=
0
;
index
<
normalized_data_size
/
2
;
index
++
)
{
Ciphertext
ct1
,
ct2
,
ct3
;
Ciphertext
temp1
,
temp2
;
// cout << "[INFO] loading ciphertext 1" << endl;
load_ciphertext
(
eval
,
ct1
,
source
);
// cout << "[INFO] loading ciphertext 2" << endl;
load_ciphertext
(
eval
,
ct2
,
data
.
at
(
index
));
sub_ciphertext
(
eval
,
ct1
,
ct2
,
temp1
);
if
((
normalized_data_size
/
2
)
+
index
<
data
.
size
())
{
// cout << "[INFO] loading ciphertext 3" << endl;
load_ciphertext
(
eval
,
ct3
,
data
.
at
((
normalized_data_size
/
2
)
+
index
));
sub_ciphertext
(
eval
,
ct1
,
ct3
,
temp2
);
}
else
{
// add dummy vector for oddy data
temp2
=
encrypted_dummy_matrix
;
}
eval
.
eval
->
rotate_columns_inplace
(
temp2
,
eval
.
gk
);
add_ciphertext
(
eval
,
temp1
,
temp2
,
temp1
);
add_ciphertext
(
eval
,
temp1
,
encrypted_result_matrix
,
encrypted_result_matrix
);
// avoid the last shift
if
(
index
+
1
!=
(
normalized_data_size
/
2
))
{
eval
.
eval
->
rotate_rows_inplace
(
encrypted_result_matrix
,
-
sample_size
,
eval
.
gk
);
}
}
// add renmaining padding slots
add_ciphertext
(
eval
,
encrypted_result_matrix
,
encrypted_padding_matrix
,
encrypted_result_matrix
);
}
// // save_ciphertext(encrypted_result_matrix, result_dir + "/" + result_name + ".ct");
// delete_operator_batching(eval);
return
encrypted_result_matrix
;
// }
}
void
sub_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
,
Ciphertext
&
ct_out
)
{
op_st
.
eval
->
sub
(
ct1
,
ct2
,
ct_out
);
}
void
sub_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
)
{
op_st
.
eval
->
sub_inplace
(
ct1
,
ct2
);
}
void
sub_plain_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
,
const
Plaintext
&
plain
)
{
op_st
.
eval
->
sub_plain_inplace
(
ct
,
plain
);
}
void
negate_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
)
{
op_st
.
eval
->
negate_inplace
(
ct
);
}
void
add_plain_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
struct
Ciphertext
&
ct
,
const
Plaintext
&
plain
)
{
op_st
.
eval
->
add_plain_inplace
(
ct
,
plain
);
}
void
add_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
,
Ciphertext
&
ct_out
)
{
op_st
.
eval
->
add
(
ct1
,
ct2
,
ct_out
);
}
void
add_many_ciphertext
(
struct
evaluator_t
&
op_st
,
vector
<
Ciphertext
>
&
cts
,
Ciphertext
&
ct_out
)
{
op_st
.
eval
->
add_many
(
cts
,
ct_out
);
}
void
multiply_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
,
Ciphertext
&
ct_out
)
{
op_st
.
eval
->
multiply
(
ct1
,
ct2
,
ct_out
);
}
void
multiply_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
)
{
op_st
.
eval
->
multiply_inplace
(
ct1
,
ct2
);
}
void
multiply_ciphertexts
(
struct
evaluator_t
&
op_st
,
vector
<
Ciphertext
>
&
cts
,
Ciphertext
&
ct_out
)
{
op_st
.
eval
->
multiply_many
(
cts
,
op_st
.
lk
,
ct_out
);
}
void
multiply_plain_inplace
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
,
const
Plaintext
&
plain
)
{
op_st
.
eval
->
multiply_plain_inplace
(
ct
,
plain
);
}
void
relinearize_inplace
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
)
{
op_st
.
eval
->
relinearize_inplace
(
ct
,
op_st
.
lk
);
}
void
relinearize
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
,
Ciphertext
&
ct_out
)
{
op_st
.
eval
->
relinearize
(
ct
,
op_st
.
lk
,
ct_out
);
}
void
rescale_to_next_inplace
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
)
{
op_st
.
eval
->
rescale_to_next_inplace
(
ct
);
}
void
exponentiate_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
,
uint64_t
&
exponent
)
{
op_st
.
eval
->
exponentiate_inplace
(
ct
,
exponent
,
op_st
.
lk
);
}
void
mod_switch_to_next_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
)
{
op_st
.
eval
->
mod_switch_to_next_inplace
(
ct
);
}
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_evaluate_v1.cpp
0 → 100644
View file @
1369d029
#include <iostream>
#include "csv_api.h"
#include "print_api.h"
#include "seal_api.h"
#include "util.h"
// #include <algorithm>
// #include <iterator>
// #include <vector>
// #include <filesystem>
using
namespace
seal
;
using
namespace
std
;
void
sub_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
,
Ciphertext
&
ct_out
);
void
add_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
,
Ciphertext
&
ct_out
);
void
multiply_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
,
Ciphertext
&
ct_out
);
void
multiply_ciphertext_ckks
(
struct
cevaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
,
Ciphertext
&
ct_out
);
bool
is_number
(
const
string
&
s
);
void
printStrVector
(
const
vector
<
string
>
&
v
);
vector
<
vector
<
string
>>
split_ends
(
const
vector
<
string
>
&
data
,
const
vector
<
int
>
&
ends
);
void
multiply_ciphertexts
(
struct
evaluator_t
&
op_st
,
vector
<
Ciphertext
>
&
cts
,
Ciphertext
&
ct_out
);
void
multiply_ciphertexts_ckks
(
struct
cevaluator_t
&
op_st
,
vector
<
Ciphertext
>
&
cts
,
Ciphertext
&
ct_out
);
void
relinearize_inplace
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
);
void
rescale_to_next_inplace
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
);
void
rescale_to_next_inplace_ckks
(
struct
cevaluator_t
&
op_st
,
Ciphertext
&
ct
);
void
multiply_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
);
void
relinearize
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
,
Ciphertext
&
ct_out
);
void
sub_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
);
void
negate_inplace__ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
);
void
add_plain_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
struct
Ciphertext
&
ct
,
const
Plaintext
&
plain
);
void
add_plain_inplace_ciphertext_ckks
(
struct
cevaluator_t
&
op_st
,
struct
Ciphertext
&
ct
,
const
Plaintext
&
plain
);
void
multiply_plain_inplace_ckks
(
struct
cevaluator_t
&
op_st
,
Ciphertext
&
ct
,
const
Plaintext
&
plain
);
void
add_many_ciphertext
(
struct
evaluator_t
&
op_st
,
vector
<
Ciphertext
>
&
cts
,
Ciphertext
&
ct_out
);
void
exponentiate_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
,
uint64_t
&
exponent
);
void
sub_plain_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
,
const
Plaintext
&
plain
);
void
mod_switch_to_next_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
);
int
ANNProcess
(
string
&
wFilePath
,
string
&
xCT
,
string
&
bFilePath
,
string
&
result_name
,
string
&
result_dir
,
int
&
sample_size
,
string
&
key_dir
);
// string relink_key_path;
// string galois_key_path;
// string public_key_path;
string
key_dir
=
""
;
int
main
(
int
argc
,
char
**
argv
)
{
// input processing - begin
// string result_name = argv[argc - 6];
// string result_dir = argv[argc - 5];
// int sample_size = atoi(argv[argc - 4]);
// relink_key_path = argv[argc - 3];
// galois_key_path = argv[argc - 2];
// public_key_path = argv[argc - 1];
string
wFilePath
=
argv
[
1
];
string
xCT
=
argv
[
2
];
string
bFilePath
=
argv
[
3
];
string
result_name
=
argv
[
argc
-
4
];
string
result_dir
=
argv
[
argc
-
3
];
int
sample_size
=
atoi
(
argv
[
argc
-
2
]);
key_dir
=
argv
[
argc
-
1
];
if
(
xCT
==
""
||
result_name
==
""
||
result_dir
==
""
||
sample_size
==
0
||
key_dir
==
""
)
{
// error handling
cout
<<
"[ERROR] please enter a source path, data paths, output ciphertext file name or prefix, output "
"ciphertext directory, sample size, linking key path, galois key path and public key path"
<<
endl
;
return
-
1
;
}
// cout << "[ANN Engine] printing matrix w ..... " << endl;
// print_matrix(temp);
int
result
=
0
;
result
=
ANNProcess
(
wFilePath
,
xCT
,
bFilePath
,
result_name
,
result_dir
,
sample_size
,
key_dir
);
// error handling
if
(
result
==
-
1
)
{
fprintf
(
stderr
,
"error!
\n
"
);
}
else
{
cout
<<
"done"
;
}
// checkSq(source, data, result_name, result_dir, sample_size, relink_key_path, galois_key_path, public_key_path);
return
result
;
}
void
rotate_2d_matrix_clockwise_impl
(
vector
<
vector
<
double
>>
const
&
matrix
,
vector
<
vector
<
double
>>
&
rotated_matrix
,
int
const
M
,
int
const
N
)
{
for
(
int
x
=
0
;
x
<
N
;
++
x
)
{
for
(
int
y
=
0
;
y
<
M
;
++
y
)
{
// cout << "[ANN Engine] ..... " << matrix[x][y] << endl;
// Source : https://stackoverflow.com/questions/4780119/2d-euclidean-vector-rotations
rotated_matrix
[
y
][
-
x
-
1
+
N
]
=
matrix
[
x
][
y
];
}
}
}
auto
rotate_2d_matrix_clockwise
(
vector
<
vector
<
double
>>
const
&
original_matrix
)
->
vector
<
vector
<
double
>>
{
int
const
M
=
original_matrix
[
0
].
size
();
int
const
N
=
original_matrix
.
size
();
vector
<
vector
<
double
>>
rotated_matrix
;
rotated_matrix
.
resize
(
M
);
for
(
auto
x
=
0
;
x
<
M
;
++
x
)
{
rotated_matrix
[
x
].
resize
(
N
);
}
rotate_2d_matrix_clockwise_impl
(
original_matrix
,
rotated_matrix
,
M
,
N
);
return
rotated_matrix
;
}
int
ANNProcess
(
string
&
wFilePath
,
string
&
xCT
,
string
&
bFilePath
,
string
&
result_name
,
string
&
result_dir
,
int
&
sample_size
,
string
&
key_dir
)
{
cout
<<
"[ANN Engine] loading matrix w ..... "
<<
endl
;
vector
<
vector
<
double
>>
w
;
load_csv_file
(
wFilePath
,
w
,
1
);
cout
<<
"[ANN Engine] loading matrix w .....end
\n
"
<<
endl
;
cout
<<
"[ANN Engine] rotating counter-clockwise matrix w ..... "
<<
endl
;
vector
<
vector
<
double
>>
cw
;
cw
=
rotate_2d_matrix_clockwise
(
rotate_2d_matrix_clockwise
(
rotate_2d_matrix_clockwise
(
w
)));
cout
<<
"[ANN Engine] rotating counter-clockwise matrix w .....end
\n
"
<<
endl
;
cout
<<
"[ANN Engine] printing rotated matrix w ..... "
<<
endl
;
print_matrix
(
cw
);
cout
<<
"[ANN Engine] printing rotated matrix w .....end
\n
"
<<
endl
;
struct
cevaluator_t
eval
;
init_operator_ckks
(
eval
,
key_dir
);
cout
<<
"[ANN Engine] loading vector x ..... "
<<
endl
;
Ciphertext
x
;
load_ciphertext_ckks
(
eval
,
x
,
xCT
);
// /*
// Decrypt, decode, and print the result.
// */
// struct cdecryptor_t decr;
// init_operator_ckks(decr, key_dir);
// decrypt_ciphertext_ckks(decr, cipher_matrix, pod_matrix);
// decr.decrypt(encrypted_result, plain_result);
// vector<double> result;
// encoder.decode(plain_result, result);
// cout << " + Computed result ...... Correct." << endl;
// print_vector(result, 3, 7);
cout
<<
"[ANN Engine] loading vector x .....end
\n
"
<<
endl
;
cout
<<
"[ANN Engine] loading vector b ..... "
<<
endl
;
vector
<
vector
<
double
>>
b
;
load_csv_file
(
bFilePath
,
b
,
1
);
cout
<<
"[ANN Engine] loading vector b .....end
\n
"
<<
endl
;
// struct cdecryptor_t decr;
// init_operator_ckks(decr, key_dir);
struct
cencryptor_t
encr
;
init_operator_ckks
(
encr
,
key_dir
);
// Transform into vector<Plaintext>
cout
<<
"[ANN Engine] Transform into vector<Plaintext> b_pt ..... "
<<
endl
;
vector
<
Plaintext
>
cw_pt
;
for
(
int
i
=
0
;
i
<
cw
.
size
();
i
++
)
{
// code block to be executed
Plaintext
pt
;
// init_plaintext_ckks(decr, cw[i], pt);
init_plaintext_ckks
(
encr
,
cw
[
i
],
pt
);
cw_pt
.
push_back
(
pt
);
}
cout
<<
"[ANN Engine] Transform into vector<Plaintext> b_pt .....end
\n
"
<<
endl
;
// size_t slot_count = encr.encoder.slot_count();
cout
<<
encr
.
ccode
->
slot_count
()
<<
endl
;
cout
<<
"[ANN Engine] Transform into vector<Plaintext> b_pt ..... "
<<
endl
;
vector
<
Ciphertext
>
bx_ct
;
cout
<<
"[ANN Engine] awdasfsdfsd ..... "
<<
w
.
size
()
<<
endl
;
// vector<double> null_vector(w.size(), 0ULL);
vector
<
double
>
null_vector
;
null_vector
.
push_back
(
2.2
);
null_vector
.
push_back
(
2.2
);
// for (int i = 0; i < cw_pt.size(); i++)
// for (int i = 0; i < 1; i++)
{
// code block to be executed
Plaintext
pt
;
init_plaintext_ckks
(
encr
,
null_vector
,
pt
);
// pt.scale() = pow(2.0, 40);
Ciphertext
ct1
,
ct2
,
ct3
;
init_ciphertext_ckks
(
encr
,
null_vector
,
ct1
);
init_ciphertext_ckks
(
encr
,
null_vector
,
ct2
);
// ct1.scale() = pow(2.0, 40);
// ct2.scale() = pow(2.0, 40);
multiply_plain_inplace_ckks
(
eval
,
x
,
pt
);
// multiply_ciphertext_ckks(eval, ct1, ct2, ct3);
// add_plain_inplace_ciphertext_ckks(eval, ct1, pt);
// multiply_plain_inplace_ckks(eval, pt, ct);
// rescale_to_next_inplace_ckks(eval, ct);
// bx_ct.push_back(ct);
}
// multiply_plain_inplace_ckks(eval, x, pt);
// init_ciphermatrix
// struct encryptor_t encr;
// init_operator_batching(encr, key_dir);
// // cout << sample_size*data.size() << endl;
// // cout << encr.bcode->slot_count() << endl;
// if (sample_size * data.size() > encr.bcode->slot_count() || sample_size > encr.bcode->slot_count() / 2)
// {
// // error handling
// delete_operator_batching(encr);
// delete_operator_batching(eval);
// return -1;
// }
// else
// {
// Ciphertext encrypted_result_matrix;
// vector<int64_t> result_matrix;
// init_ciphermatrix(encr, result_matrix, encrypted_result_matrix);
// vector<int64_t> dummy_matrix;
// for (size_t i = 0; i < sample_size; i++)
// {
// dummy_matrix.push_back(1);
// }
// Ciphertext encrypted_dummy_matrix;
// init_ciphermatrix(encr, dummy_matrix, encrypted_dummy_matrix);
// // normalize input data if its size is odd
// int normalized_data_size;
// if (data.size() % 2 == 0)
// {
// normalized_data_size = data.size();
// }
// else
// {
// normalized_data_size = data.size() + 1;
// }
// int required_range = normalized_data_size * sample_size;
// int required_no_row_elements = required_range / 2;
// int required_range_row = required_range / 2;
// // create padding matrix
// int padding_slots = (encr.bcode->slot_count() / 2) - required_range_row;
// vector<int64_t> padding_matrix(encr.bcode->slot_count(), 0ULL);
// for (size_t i = 0; i < padding_slots; i++)
// {
// padding_matrix[required_no_row_elements + i] = 1;
// padding_matrix[encr.bcode->slot_count() - i] = 1;
// }
// Ciphertext encrypted_padding_matrix;
// init_ciphermatrix(encr, padding_matrix, encrypted_padding_matrix);
// if (required_range_row <= encr.bcode->slot_count() && required_range_row > 0)
// {
// for (int index = 0; index < normalized_data_size / 2; index++)
// {
// Ciphertext ct1, ct2, ct3;
// Ciphertext temp1, temp2;
// // cout << "[INFO] loading ciphertext 1" << endl;
// load_ciphertext(eval, ct1, source);
// // cout << "[INFO] loading ciphertext 2" << endl;
// load_ciphertext(eval, ct2, data.at(index));
// sub_ciphertext(eval, ct1, ct2, temp1);
// if ((normalized_data_size / 2) + index < data.size())
// {
// // cout << "[INFO] loading ciphertext 3" << endl;
// load_ciphertext(eval, ct3, data.at((normalized_data_size / 2) + index));
// sub_ciphertext(eval, ct1, ct3, temp2);
// }
// else
// {
// // add dummy vector for oddy data
// temp2 = encrypted_dummy_matrix;
// }
// eval.eval->rotate_columns_inplace(temp2, eval.gk);
// add_ciphertext(eval, temp1, temp2, temp1);
// add_ciphertext(eval, temp1, encrypted_result_matrix, encrypted_result_matrix);
// // avoid the last shift
// if (index + 1 != (normalized_data_size / 2))
// {
// eval.eval->rotate_rows_inplace(encrypted_result_matrix, -sample_size, eval.gk);
// }
// }
// // add renmaining padding slots
// add_ciphertext(eval, encrypted_result_matrix, encrypted_padding_matrix, encrypted_result_matrix);
// }
// save_ciphertext(encrypted_result_matrix, result_dir + "/" + result_name + ".ct");
// delete_operator_batching(encr);
// delete_operator_batching(eval);
return
0
;
// }
}
// int ANNProcess(
// string &wFilePath, string &xCT, string &bFilePath, string &result_name, string &result_dir, int &sample_size,
// string &key_dir)
// {
// struct evaluator_t eval;
// init_operator_batching(eval, key_dir);
// struct encryptor_t encr;
// init_operator_batching(encr, key_dir);
// // cout << sample_size*data.size() << endl;
// // cout << encr.bcode->slot_count() << endl;
// if (sample_size * data.size() > encr.bcode->slot_count() || sample_size > encr.bcode->slot_count() / 2)
// {
// // error handling
// delete_operator_batching(encr);
// delete_operator_batching(eval);
// return -1;
// }
// else
// {
// Ciphertext encrypted_result_matrix;
// vector<int64_t> result_matrix;
// init_ciphermatrix(encr, result_matrix, encrypted_result_matrix);
// vector<int64_t> dummy_matrix;
// for (size_t i = 0; i < sample_size; i++)
// {
// dummy_matrix.push_back(1);
// }
// Ciphertext encrypted_dummy_matrix;
// init_ciphermatrix(encr, dummy_matrix, encrypted_dummy_matrix);
// // normalize input data if its size is odd
// int normalized_data_size;
// if (data.size() % 2 == 0)
// {
// normalized_data_size = data.size();
// }
// else
// {
// normalized_data_size = data.size() + 1;
// }
// int required_range = normalized_data_size * sample_size;
// int required_no_row_elements = required_range / 2;
// int required_range_row = required_range / 2;
// // create padding matrix
// int padding_slots = (encr.bcode->slot_count() / 2) - required_range_row;
// vector<int64_t> padding_matrix(encr.bcode->slot_count(), 0ULL);
// for (size_t i = 0; i < padding_slots; i++)
// {
// padding_matrix[required_no_row_elements + i] = 1;
// padding_matrix[encr.bcode->slot_count() - i] = 1;
// }
// Ciphertext encrypted_padding_matrix;
// init_ciphermatrix(encr, padding_matrix, encrypted_padding_matrix);
// if (required_range_row <= encr.bcode->slot_count() && required_range_row > 0)
// {
// for (int index = 0; index < normalized_data_size / 2; index++)
// {
// Ciphertext ct1, ct2, ct3;
// Ciphertext temp1, temp2;
// // cout << "[INFO] loading ciphertext 1" << endl;
// load_ciphertext(eval, ct1, source);
// // cout << "[INFO] loading ciphertext 2" << endl;
// load_ciphertext(eval, ct2, data.at(index));
// sub_ciphertext(eval, ct1, ct2, temp1);
// if ((normalized_data_size / 2) + index < data.size())
// {
// // cout << "[INFO] loading ciphertext 3" << endl;
// load_ciphertext(eval, ct3, data.at((normalized_data_size / 2) + index));
// sub_ciphertext(eval, ct1, ct3, temp2);
// }
// else
// {
// // add dummy vector for oddy data
// temp2 = encrypted_dummy_matrix;
// }
// eval.eval->rotate_columns_inplace(temp2, eval.gk);
// add_ciphertext(eval, temp1, temp2, temp1);
// add_ciphertext(eval, temp1, encrypted_result_matrix, encrypted_result_matrix);
// // avoid the last shift
// if (index + 1 != (normalized_data_size / 2))
// {
// eval.eval->rotate_rows_inplace(encrypted_result_matrix, -sample_size, eval.gk);
// }
// }
// // add renmaining padding slots
// add_ciphertext(eval, encrypted_result_matrix, encrypted_padding_matrix, encrypted_result_matrix);
// }
// save_ciphertext(encrypted_result_matrix, result_dir + "/" + result_name + ".ct");
// delete_operator_batching(encr);
// delete_operator_batching(eval);
// return 0;
// }
// }
void
sub_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
,
Ciphertext
&
ct_out
)
{
op_st
.
eval
->
sub
(
ct1
,
ct2
,
ct_out
);
}
void
sub_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
)
{
op_st
.
eval
->
sub_inplace
(
ct1
,
ct2
);
}
void
sub_plain_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
,
const
Plaintext
&
plain
)
{
op_st
.
eval
->
sub_plain_inplace
(
ct
,
plain
);
}
void
negate_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
)
{
op_st
.
eval
->
negate_inplace
(
ct
);
}
void
add_plain_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
struct
Ciphertext
&
ct
,
const
Plaintext
&
plain
)
{
op_st
.
eval
->
add_plain_inplace
(
ct
,
plain
);
}
void
add_plain_inplace_ciphertext_ckks
(
struct
cevaluator_t
&
op_st
,
struct
Ciphertext
&
ct
,
const
Plaintext
&
plain
)
{
op_st
.
eval
->
add_plain_inplace
(
ct
,
plain
);
}
void
add_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
,
Ciphertext
&
ct_out
)
{
op_st
.
eval
->
add
(
ct1
,
ct2
,
ct_out
);
}
void
add_many_ciphertext
(
struct
evaluator_t
&
op_st
,
vector
<
Ciphertext
>
&
cts
,
Ciphertext
&
ct_out
)
{
op_st
.
eval
->
add_many
(
cts
,
ct_out
);
}
void
multiply_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
,
Ciphertext
&
ct_out
)
{
op_st
.
eval
->
multiply
(
ct1
,
ct2
,
ct_out
);
}
void
multiply_ciphertext_ckks
(
struct
cevaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
,
Ciphertext
&
ct_out
)
{
op_st
.
eval
->
multiply
(
ct1
,
ct2
,
ct_out
);
}
void
multiply_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
)
{
op_st
.
eval
->
multiply_inplace
(
ct1
,
ct2
);
}
void
multiply_ciphertexts
(
struct
evaluator_t
&
op_st
,
vector
<
Ciphertext
>
&
cts
,
Ciphertext
&
ct_out
)
{
op_st
.
eval
->
multiply_many
(
cts
,
op_st
.
lk
,
ct_out
);
}
void
multiply_ciphertexts_ckks
(
struct
cevaluator_t
&
op_st
,
vector
<
Ciphertext
>
&
cts
,
Ciphertext
&
ct_out
)
{
op_st
.
eval
->
multiply_many
(
cts
,
op_st
.
lk
,
ct_out
);
}
void
multiply_plain_inplace_ckks
(
struct
cevaluator_t
&
op_st
,
Ciphertext
&
ct
,
const
Plaintext
&
plain
)
{
op_st
.
eval
->
multiply_plain_inplace
(
ct
,
plain
);
}
// void multiply_plain_inplace_ckks(struct evaluator_t &op_st, Ciphertext &ct, const Plaintext &plain)
// {
// op_st.eval->multiply_plain_inplace(ct, plain);
// }
void
relinearize_inplace
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
)
{
op_st
.
eval
->
relinearize_inplace
(
ct
,
op_st
.
lk
);
}
void
relinearize
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
,
Ciphertext
&
ct_out
)
{
op_st
.
eval
->
relinearize
(
ct
,
op_st
.
lk
,
ct_out
);
}
void
rescale_to_next_inplace
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
)
{
op_st
.
eval
->
rescale_to_next_inplace
(
ct
);
}
void
rescale_to_next_inplace_ckks
(
struct
cevaluator_t
&
op_st
,
Ciphertext
&
ct
)
{
op_st
.
eval
->
rescale_to_next_inplace
(
ct
);
}
void
exponentiate_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
,
uint64_t
&
exponent
)
{
op_st
.
eval
->
exponentiate_inplace
(
ct
,
exponent
,
op_st
.
lk
);
}
void
mod_switch_to_next_inplace_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
)
{
op_st
.
eval
->
mod_switch_to_next_inplace
(
ct
);
}
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_genkey_v1
0 → 100755
View file @
1369d029
File added
docker/bigpiseal3.5.1/bin/ANN/v1/ANN_genkey_v1.cpp
0 → 100644
View file @
1369d029
#include "seal_api.h"
using
namespace
std
;
using
namespace
seal
;
int
main
(
int
argc
,
char
**
argv
)
{
string
key_dir
=
argv
[
1
];
size_t
poly_d
=
4096
;
// size_t poly_d = 16384;
// size_t poly_d = 8192;
// Params option 1
// int bit_size = 20;
int
bit_size
=
0
;
// Params option 2
// uint64_t plain_modulus = 1032193;
// vector<int> bit_sizes = { 36, 36, 37 };
// timeval t0, t1;
// unsigned long dt = 0;
// gettimeofday(&t0, NULL);
generate_keys_ckks
(
poly_d
,
bit_size
,
key_dir
,
true
);
// batching_generate_keys(poly_d, bit_sizes, plain_modulus, key_dir, true);
// gettimeofday(&t1, NULL);
// dt = 1000000 * (t1.tv_sec - t0.tv_sec) + (t1.tv_usec - t0.tv_usec);
// cout << "[INFO] keys generation time in seconds: " << ((float)dt)/1000000 << endl;
return
0
;
}
docker/bigpiseal3.5.1/bin/ANN/v1/CMakeLists.txt
0 → 100644
View file @
1369d029
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.
cmake_minimum_required
(
VERSION 3.10
)
set
(
TEST_NAME ANN
)
#set(GENKEY_BIN ${TEST_NAME}_genkey)
#set(ENCR_BIN ${TEST_NAME}_encrypt)
#set(DECR_BIN ${TEST_NAME}_decrypt)
#set(EVAL_BIN ${TEST_NAME}_evaluate)
#set(SCR_TEST test.sh)
set
(
GENKEY_BIN_2
${
TEST_NAME
}
_genkey_v1
)
set
(
ENCR_BIN_2
${
TEST_NAME
}
_encrypt_v1
)
set
(
DECR_BIN_2
${
TEST_NAME
}
_decrypt_v1
)
set
(
DECR_RESULT_BIN_2
${
TEST_NAME
}
_decrypt_result_v1
)
set
(
EVAL_BIN_2
${
TEST_NAME
}
_evaluate_v1
)
set
(
SCR_ENC encrypt.sh
)
set
(
SCR_DEC decrypt.sh
)
set
(
SCR_DEC_RESULT decrypt_result.sh
)
set
(
SCR_EVAL eval.sh
)
set
(
SCR_GEN genkey.sh
)
set
(
SCR_TEST_v1 test_v1.sh
)
set
(
GENKEY_SRCS
${
CMAKE_CURRENT_LIST_DIR
}
/seal_api.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/
${
TEST_NAME
}
_genkey.cpp
)
set
(
ENCR_SRCS
${
CMAKE_CURRENT_LIST_DIR
}
/seal_api.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/
${
TEST_NAME
}
_encrypt.cpp
)
set
(
DECR_SRCS
${
CMAKE_CURRENT_LIST_DIR
}
/util.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/seal_api.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/
${
TEST_NAME
}
_decrypt.cpp
)
set
(
EVAL_SRCS
${
CMAKE_CURRENT_LIST_DIR
}
/seal_api.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/util.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/
${
TEST_NAME
}
_evaluate.cpp
)
set
(
GENKEY_SRCS_2
${
CMAKE_CURRENT_LIST_DIR
}
/seal_api.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/
${
TEST_NAME
}
_genkey_v1.cpp
)
set
(
ENCR_SRCS_2
${
CMAKE_CURRENT_LIST_DIR
}
/seal_api.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/
${
TEST_NAME
}
_encrypt_v1.cpp
)
set
(
DECR_SRCS_2
${
CMAKE_CURRENT_LIST_DIR
}
/util.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/seal_api.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/
${
TEST_NAME
}
_decrypt_v1.cpp
)
set
(
DECR_RESULT_SRCS_2
${
CMAKE_CURRENT_LIST_DIR
}
/util.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/seal_api.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/
${
TEST_NAME
}
_decrypt_result_v1.cpp
)
set
(
EVAL_SRCS_2
${
CMAKE_CURRENT_LIST_DIR
}
/seal_api.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/util.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/csv_api.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/print_api.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/
${
TEST_NAME
}
_evaluate_v1.cpp
)
set
(
HEADER_FILES
${
CMAKE_CURRENT_LIST_DIR
}
/seal_api.h
${
CMAKE_CURRENT_LIST_DIR
}
/util.h
${
CMAKE_CURRENT_LIST_DIR
}
/csv_api.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/print_api.cpp
)
#add_executable(${GENKEY_BIN} ${GENKEY_SRCS} ${HEADER_FILES})
#add_executable(${ENCR_BIN} ${ENCR_SRCS} ${HEADER_FILES})
#add_executable(${DECR_BIN} ${DECR_SRCS} ${HEADER_FILES})
#add_executable(${EVAL_BIN} ${EVAL_SRCS} ${HEADER_FILES})
#target_include_directories(${TEST_NAME} PRIVATE ${HEADER_DIR})
add_executable
(
${
GENKEY_BIN_2
}
${
GENKEY_SRCS_2
}
${
HEADER_FILES
}
)
add_executable
(
${
ENCR_BIN_2
}
${
ENCR_SRCS_2
}
${
HEADER_FILES
}
)
add_executable
(
${
DECR_BIN_2
}
${
DECR_SRCS_2
}
${
HEADER_FILES
}
)
add_executable
(
${
DECR_RESULT_BIN_2
}
${
DECR_RESULT_SRCS_2
}
${
HEADER_FILES
}
)
add_executable
(
${
EVAL_BIN_2
}
${
EVAL_SRCS_2
}
${
HEADER_FILES
}
)
#target_include_directories(${TEST_NAME} PRIVATE ${HEADER_DIR})
# Import Microsoft SEAL
find_package
(
SEAL 3.5 REQUIRED
)
# Link Microsoft SEAL
#target_link_libraries(${GENKEY_BIN} SEAL::seal)
#target_link_libraries(${ENCR_BIN} SEAL::seal)
#target_link_libraries(${DECR_BIN} SEAL::seal)
#target_link_libraries(${EVAL_BIN} SEAL::seal)
target_link_libraries
(
${
GENKEY_BIN_2
}
SEAL::seal
)
target_link_libraries
(
${
ENCR_BIN_2
}
SEAL::seal
)
target_link_libraries
(
${
DECR_BIN_2
}
SEAL::seal
)
target_link_libraries
(
${
DECR_RESULT_BIN_2
}
SEAL::seal
)
target_link_libraries
(
${
EVAL_BIN_2
}
SEAL::seal
)
set
(
CMAKE_RUNTIME_OUTPUT_DIRECTORY
${
CMAKE_SOURCE_DIR
}
/bin
)
#set_target_properties(${GENKEY_BIN}
# PROPERTIES
# RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TEST_NAME}"
# )
#set_target_properties(${ENCR_BIN}
# PROPERTIES
# RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TEST_NAME}"
# )
#set_target_properties(${DECR_BIN}
# PROPERTIES
# RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TEST_NAME}"
# )
#set_target_properties(${EVAL_BIN}
# PROPERTIES
# RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TEST_NAME}"
# )
set_target_properties
(
${
GENKEY_BIN_2
}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY
"
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/
${
TEST_NAME
}
/v1"
)
set_target_properties
(
${
ENCR_BIN_2
}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY
"
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/
${
TEST_NAME
}
/v1"
)
set_target_properties
(
${
DECR_BIN_2
}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY
"
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/
${
TEST_NAME
}
/v1"
)
set_target_properties
(
${
DECR_RESULT_BIN_2
}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY
"
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/
${
TEST_NAME
}
/v1"
)
set_target_properties
(
${
EVAL_BIN_2
}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY
"
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/
${
TEST_NAME
}
/v1"
)
file
(
COPY
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SCR_TEST
}
DESTINATION
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/
${
TEST_NAME
}
/v1
)
file
(
COPY
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SCR_ENC
}
DESTINATION
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/
${
TEST_NAME
}
/v1
)
file
(
COPY
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SCR_DEC
}
DESTINATION
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/
${
TEST_NAME
}
/v1
)
file
(
COPY
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SCR_DEC_RESULT
}
DESTINATION
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/
${
TEST_NAME
}
/v1
)
file
(
COPY
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SCR_EVAL
}
DESTINATION
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/
${
TEST_NAME
}
/v1
)
file
(
COPY
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SCR_GEN
}
DESTINATION
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/
${
TEST_NAME
}
/v1
)
file
(
COPY
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SCR_TEST_v1
}
DESTINATION
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/
${
TEST_NAME
}
/v1
)
\ No newline at end of file
docker/bigpiseal3.5.1/bin/ANN/v1/csv_api.cpp
0 → 100644
View file @
1369d029
/*
*/
#include "csv_api.h"
/* namespaces */
using
namespace
std
;
int
load_csv_line
(
const
string
&
filename
,
vector
<
int64_t
>
&
in
,
bool
print_info
)
{
int
ret
=
1
;
if
(
in
.
size
()
>
0
)
in
.
clear
();
fstream
fd
;
fd
.
open
(
filename
,
std
::
fstream
::
in
);
if
(
!
fd
.
is_open
())
{
cerr
<<
"[csv-error] opening csv file failure"
<<
endl
;
ret
=
0
;
}
else
{
string
l
;
getline
(
fd
,
l
);
if
(
l
.
empty
())
{
cerr
<<
"[csv-error] empty csv file, please provide a valid csv file"
<<
endl
;
ret
=
0
;
}
else
{
string
w
;
stringstream
s
(
l
);
while
(
getline
(
s
,
w
,
','
))
{
int64_t
val
=
boost
::
lexical_cast
<
int64_t
>
(
w
);
in
.
push_back
(
val
);
}
fd
.
close
();
/* print the obtained vector of numbers from a csv line */
if
(
print_info
)
{
cout
<<
"[csv-info] loading vector from a csv input (line): "
<<
endl
;
for
(
int
i
=
0
;
i
<
(
int
)(
in
.
size
());
++
i
)
cout
<<
in
[
i
]
<<
" "
;
cout
<<
endl
;
}
}
}
return
ret
;
}
int
load_csv_line
(
const
string
&
filename
,
vector
<
double
>
&
in
,
bool
print_info
)
{
int
ret
=
1
;
if
(
in
.
size
()
>
0
)
in
.
clear
();
fstream
fd
;
fd
.
open
(
filename
,
std
::
fstream
::
in
);
if
(
!
fd
.
is_open
())
{
cerr
<<
"[csv-error] opening csv file failure"
<<
endl
;
ret
=
0
;
}
else
{
string
l
;
getline
(
fd
,
l
);
if
(
l
.
empty
())
{
cerr
<<
"[csv-error] empty csv file, please provide a valid csv file"
<<
endl
;
ret
=
0
;
}
else
{
string
w
;
stringstream
s
(
l
);
while
(
getline
(
s
,
w
,
','
))
{
double
val
=
boost
::
lexical_cast
<
double
>
(
w
);
in
.
push_back
(
val
);
}
fd
.
close
();
/* print the obtained vector of numbers from a csv line */
if
(
print_info
)
{
cout
<<
"[csv-info] loading vector from a csv input (line): "
<<
endl
;
for
(
int
i
=
0
;
i
<
(
int
)(
in
.
size
());
++
i
)
cout
<<
in
[
i
]
<<
" "
;
cout
<<
endl
;
}
}
}
return
ret
;
}
int
load_windows_csv_line
(
const
string
&
filename
,
vector
<
int64_t
>
&
in
,
bool
print_info
)
{
int
ret
=
1
;
if
(
in
.
size
()
>
0
)
in
.
clear
();
fstream
fd
;
fd
.
open
(
filename
,
std
::
fstream
::
in
);
if
(
!
fd
.
is_open
())
{
cerr
<<
"[csv-error] opening csv file failure"
<<
endl
;
ret
=
0
;
}
else
{
string
l
;
getline
(
fd
,
l
);
if
(
l
.
empty
())
{
cerr
<<
"[csv-error] empty csv file, please provide a valid csv file"
<<
endl
;
ret
=
0
;
}
else
{
if
(
l
[
l
.
size
()
-
1
]
==
'\r'
)
l
.
erase
(
l
.
size
()
-
1
);
string
w
;
stringstream
s
(
l
);
while
(
getline
(
s
,
w
,
','
))
{
int64_t
val
=
boost
::
lexical_cast
<
int64_t
>
(
w
);
in
.
push_back
(
val
);
}
fd
.
close
();
/* print the obtained vector of numbers from a csv line */
if
(
print_info
)
{
cout
<<
"[csv-info] loading vector from a csv input (line): "
<<
endl
;
for
(
int
i
=
0
;
i
<
(
int
)(
in
.
size
());
++
i
)
cout
<<
in
[
i
]
<<
" "
;
cout
<<
endl
;
}
}
}
return
ret
;
}
int
load_windows_csv_line
(
const
string
&
filename
,
vector
<
double
>
&
in
,
bool
print_info
)
{
int
ret
=
1
;
if
(
in
.
size
()
>
0
)
in
.
clear
();
fstream
fd
;
fd
.
open
(
filename
,
std
::
fstream
::
in
);
if
(
!
fd
.
is_open
())
{
cerr
<<
"[csv-error] opening csv file failure"
<<
endl
;
ret
=
0
;
}
else
{
string
l
;
getline
(
fd
,
l
);
if
(
l
.
empty
())
{
cerr
<<
"[csv-error] empty csv file, please provide a valid csv file"
<<
endl
;
ret
=
0
;
}
else
{
if
(
l
[
l
.
size
()
-
1
]
==
'\r'
)
l
.
erase
(
l
.
size
()
-
1
);
string
w
;
stringstream
s
(
l
);
while
(
getline
(
s
,
w
,
','
))
{
double
val
=
boost
::
lexical_cast
<
double
>
(
w
);
in
.
push_back
(
val
);
}
fd
.
close
();
/* print the obtained vector of numbers from a csv line */
if
(
print_info
)
{
cout
<<
"[csv-info] loading vector from a csv input (line): "
<<
endl
;
for
(
int
i
=
0
;
i
<
(
int
)(
in
.
size
());
++
i
)
cout
<<
in
[
i
]
<<
" "
;
cout
<<
endl
;
}
}
}
return
ret
;
}
void
string_to_number_vector
(
string
&
s
,
vector
<
int64_t
>
&
in
,
bool
print_info
)
{
if
(
in
.
size
()
>
0
)
in
.
clear
();
string
w
;
stringstream
c
(
s
);
while
(
getline
(
c
,
w
,
','
))
{
int64_t
val
=
boost
::
lexical_cast
<
int64_t
>
(
w
);
in
.
push_back
(
val
);
}
/* print the obtained vectors of numbers from a csv file */
if
(
print_info
)
{
cout
<<
"[csv-info] converting a csv line to a vector of numbers"
<<
endl
;
cout
<<
"[csv-info] input line: "
<<
s
<<
endl
;
cout
<<
"[csv-info] output vector: "
;
for
(
int
i
=
0
;
i
<
(
int
)(
in
.
size
());
++
i
)
cout
<<
in
[
i
]
<<
" "
;
cout
<<
endl
;
}
}
void
string_to_number_vector
(
string
&
s
,
vector
<
double
>
&
in
,
bool
print_info
)
{
if
(
in
.
size
()
>
0
)
in
.
clear
();
string
w
;
stringstream
c
(
s
);
while
(
getline
(
c
,
w
,
','
))
{
double
val
=
boost
::
lexical_cast
<
double
>
(
w
);
in
.
push_back
(
val
);
}
/* print the obtained vectors of numbers from a csv file */
if
(
print_info
)
{
cout
<<
"[csv-info] converting a csv line to a vector of numbers"
<<
endl
;
cout
<<
"[csv-info] input line: "
<<
s
<<
endl
;
cout
<<
"[csv-info] output vector: "
;
for
(
int
i
=
0
;
i
<
(
int
)(
in
.
size
());
++
i
)
cout
<<
in
[
i
]
<<
" "
;
cout
<<
endl
;
}
}
int
load_csv_file
(
const
string
&
filename
,
vector
<
vector
<
int64_t
>>
&
in
,
bool
print_info
)
{
int
ret
=
1
;
if
(
in
.
size
()
>
0
)
in
.
clear
();
fstream
fd
;
fd
.
open
(
filename
,
std
::
fstream
::
in
);
if
(
!
fd
.
is_open
())
{
cerr
<<
"[csv-error] opening csv file failure"
<<
endl
;
ret
=
0
;
}
else
{
while
(
!
fd
.
eof
())
{
string
l
;
getline
(
fd
,
l
);
vector
<
int64_t
>
tmp
;
string_to_number_vector
(
l
,
tmp
);
in
.
push_back
(
tmp
);
}
fd
.
close
();
/* print the different csv lines */
if
(
print_info
)
{
cout
<<
"[csv-info] loaded vectors from the lines of a csv file: "
<<
endl
;
print_matrix
(
in
);
}
}
return
ret
;
}
void
remove_carriage_return
(
std
::
string
&
line
)
{
if
(
*
line
.
rbegin
()
==
'\r'
)
{
line
.
erase
(
line
.
length
()
-
1
);
}
}
int
load_csv_file
(
const
string
&
filename
,
vector
<
vector
<
double
>>
&
in
,
bool
print_info
)
{
int
ret
=
1
;
if
(
in
.
size
()
>
0
)
in
.
clear
();
fstream
fd
;
fd
.
open
(
filename
,
std
::
fstream
::
in
);
if
(
!
fd
.
is_open
())
{
cerr
<<
"[csv-error] opening csv file failure"
<<
endl
;
ret
=
0
;
}
else
{
int
i
=
0
;
while
(
!
fd
.
eof
())
{
string
l
;
getline
(
fd
,
l
);
remove_carriage_return
(
l
);
vector
<
double
>
tmp
;
string_to_number_vector
(
l
,
tmp
);
in
.
push_back
(
tmp
);
i
++
;
}
fd
.
close
();
/* print the different csv lines */
if
(
print_info
)
{
cout
<<
"[csv-info] loaded vectors from the lines of a csv file: "
<<
endl
;
print_matrix
(
in
);
}
}
return
ret
;
}
int
read_csv_file
(
const
string
&
filename
,
vector
<
string
>
&
in
,
bool
print_info
)
{
int
ret
=
1
;
if
(
in
.
size
()
>
0
)
in
.
clear
();
fstream
fd
;
fd
.
open
(
filename
,
std
::
fstream
::
in
);
if
(
!
fd
.
is_open
())
{
cerr
<<
"[csv-error] opening csv file failure"
<<
endl
;
ret
=
0
;
}
else
{
while
(
!
fd
.
eof
())
{
string
l
;
getline
(
fd
,
l
);
in
.
push_back
(
l
);
}
fd
.
close
();
/* print the different csv lines */
if
(
print_info
)
{
cout
<<
"[csv-info] reading csv lines: "
<<
endl
;
for
(
int
i
=
0
;
i
<
(
int
)(
in
.
size
());
++
i
)
cout
<<
in
[
i
]
<<
endl
;
}
}
return
ret
;
}
int
write_to_csv_file
(
const
string
&
filename
,
vector
<
int64_t
>
&
in
)
{
int
ret
=
1
;
ofstream
fd
(
filename
);
if
(
!
fd
.
is_open
())
{
cerr
<<
"[csv-error] could not open the csv output file"
<<
endl
;
ret
=
0
;
}
else
{
for
(
int
i
=
0
;
i
<
(
int
)(
in
.
size
()
-
1
);
++
i
)
{
fd
<<
in
[
i
]
<<
","
;
}
fd
<<
in
[
in
.
size
()
-
1
]
<<
endl
;
fd
.
close
();
}
return
ret
;
}
int
write_to_csv_file
(
const
string
&
filename
,
vector
<
double
>
&
in
)
{
int
ret
=
1
;
ofstream
fd
(
filename
);
if
(
!
fd
.
is_open
())
{
cerr
<<
"[csv-error] could not open the csv output file"
<<
endl
;
ret
=
0
;
}
else
{
for
(
int
i
=
0
;
i
<
(
int
)(
in
.
size
()
-
1
);
++
i
)
{
fd
<<
in
[
i
]
<<
","
;
}
fd
<<
in
[
in
.
size
()
-
1
]
<<
endl
;
fd
.
close
();
}
return
ret
;
}
int
convert_crlf_to_lf
(
char
*
in
,
char
*
out
)
{
int
ret
=
1
;
int
c
;
FILE
*
ifp
,
*
ofp
;
if
((
ifp
=
fopen
(
in
,
"rb"
))
==
NULL
)
{
cout
<<
"[csv-error] could not open input file"
<<
endl
;
ret
=
0
;
}
else
{
if
((
ofp
=
fopen
(
out
,
"wb"
))
==
NULL
)
{
cout
<<
"[csv-error] could not open output file"
<<
endl
;
fclose
(
ifp
);
ret
=
0
;
}
else
{
while
((
c
=
getc
(
ifp
))
!=
EOF
)
{
if
(
c
==
'\r'
)
{
putc
(
'\n'
,
ofp
);
c
=
getc
(
ifp
);
if
(
c
==
EOF
)
break
;
if
(
c
==
'\n'
)
continue
;
}
putc
(
c
,
ofp
);
}
fclose
(
ifp
);
fclose
(
ofp
);
}
}
return
ret
;
}
int
convert_lf_to_crlf
(
char
*
in
,
char
*
out
)
{
int
ret
=
1
;
int
c
;
FILE
*
ifp
,
*
ofp
;
if
((
ifp
=
fopen
(
in
,
"rb"
))
==
NULL
)
{
cout
<<
"[csv-error] could not open input file
\n
"
<<
endl
;
ret
=
0
;
}
else
{
if
((
ofp
=
fopen
(
out
,
"wb"
))
==
NULL
)
{
cout
<<
"[csv-error] could not open output file
\n
"
<<
endl
;
fclose
(
ifp
);
ret
=
0
;
}
else
{
while
((
c
=
getc
(
ifp
))
!=
EOF
)
{
if
(
c
==
'\n'
)
{
putc
(
'\r'
,
ofp
);
putc
(
'\n'
,
ofp
);
c
=
getc
(
ifp
);
if
(
c
==
EOF
)
break
;
if
(
c
==
'\n'
)
continue
;
}
putc
(
c
,
ofp
);
}
fclose
(
ifp
);
fclose
(
ofp
);
}
}
return
ret
;
}
docker/bigpiseal3.5.1/bin/ANN/v1/csv_api.h
0 → 100644
View file @
1369d029
/*
(C) Copyright 2022 CEA LIST. All Rights Reserved.
*/
#ifndef _CSV_API_H_
#define _CSV_API_H_
/* includes */
#include <iostream>
#include <fstream>
#include <string>
#include <cstdio>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include "print_api.h"
/* prototypes */
int
load_csv_line
(
const
std
::
string
&
filename
,
std
::
vector
<
int64_t
>&
in
,
bool
print_info
=
0
);
int
load_csv_line
(
const
std
::
string
&
filename
,
std
::
vector
<
double
>&
in
,
bool
print_info
=
0
);
int
load_windows_csv_line
(
const
std
::
string
&
filename
,
std
::
vector
<
int64_t
>&
in
,
bool
print_info
=
0
);
int
load_windows_csv_line
(
const
std
::
string
&
filename
,
std
::
vector
<
double
>&
in
,
bool
print_info
=
0
);
void
string_to_number_vector
(
std
::
string
&
s
,
std
::
vector
<
int64_t
>&
in
,
bool
print_info
=
0
);
void
string_to_number_vector
(
std
::
string
&
s
,
std
::
vector
<
double
>&
in
,
bool
print_info
=
0
);
int
load_csv_file
(
const
std
::
string
&
filename
,
std
::
vector
<
std
::
vector
<
int64_t
>>&
in
,
bool
print_info
=
0
);
int
load_csv_file
(
const
std
::
string
&
filename
,
std
::
vector
<
std
::
vector
<
double
>>&
in
,
bool
print_info
=
0
);
int
read_csv_file
(
const
std
::
string
&
filename
,
std
::
vector
<
std
::
string
>&
in
,
bool
print_info
=
0
);
int
write_to_csv_file
(
const
std
::
string
&
filename
,
std
::
vector
<
int64_t
>
&
in
);
int
write_to_csv_file
(
const
std
::
string
&
filename
,
std
::
vector
<
double
>
&
in
);
int
convert_crlf_to_lf
(
char
*
in
,
char
*
out
);
int
convert_lf_to_crlf
(
char
*
in
,
char
*
out
);
#endif
docker/bigpiseal3.5.1/bin/ANN/v1/decrypt.sh
0 → 100644
View file @
1369d029
#decrypt
resultPath
=
$1
# ex: result/l.ct
sample
=
$2
# ex: 40
keyDir
=
$3
# ex: keys/
CURR_DIR
=
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
&&
pwd
)
# time ./ANN_decrypt_v1 "$resultPath" "$sample" "$keyDir"
time
${
CURR_DIR
}
/ANN_decrypt_v1
"
$resultPath
"
"
$sample
"
"
$keyDir
"
\ No newline at end of file
docker/bigpiseal3.5.1/bin/ANN/v1/decrypt_result.sh
0 → 100644
View file @
1369d029
#decrypt result
resultPath
=
$1
# ex: result/l.ct
sample
=
$2
# ex: 40
keyDir
=
$3
# ex: keys/
CURR_DIR
=
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
&&
pwd
)
# time ./ANN_decrypt_result_v1 "$resultPath" "$sample" "$keyDir"
time
${
CURR_DIR
}
/ANN_decrypt_result_v1
"
$resultPath
"
"
$sample
"
"
$keyDir
"
\ No newline at end of file
Prev
1
2
3
4
5
…
50
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment