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
1698a67c
Commit
1698a67c
authored
May 05, 2023
by
Hoang Gia NGUYEN
Browse files
testing
parent
d8df7d47
Changes
268
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
0 additions
and
1570 deletions
+0
-1570
bigpiseal3.5.1/native/examples/ANN/v1/test_v1.sh
bigpiseal3.5.1/native/examples/ANN/v1/test_v1.sh
+0
-115
bigpiseal3.5.1/native/examples/ANN/v1/util.cpp
bigpiseal3.5.1/native/examples/ANN/v1/util.cpp
+0
-73
bigpiseal3.5.1/native/examples/ANN/v1/util.h
bigpiseal3.5.1/native/examples/ANN/v1/util.h
+0
-15
bigpiseal3.5.1/native/examples/CMakeLists.txt
bigpiseal3.5.1/native/examples/CMakeLists.txt
+0
-14
bigpiseal3.5.1/native/examples/SEALExamples.vcxproj
bigpiseal3.5.1/native/examples/SEALExamples.vcxproj
+0
-206
bigpiseal3.5.1/native/examples/SEALExamples.vcxproj.filters
bigpiseal3.5.1/native/examples/SEALExamples.vcxproj.filters
+0
-52
bigpiseal3.5.1/native/examples/examples.cpp
bigpiseal3.5.1/native/examples/examples.cpp
+0
-100
bigpiseal3.5.1/native/examples/examples.h
bigpiseal3.5.1/native/examples/examples.h
+0
-223
bigpiseal3.5.1/native/examples/generic/CMakeLists.txt
bigpiseal3.5.1/native/examples/generic/CMakeLists.txt
+0
-114
bigpiseal3.5.1/native/examples/generic/add.cpp
bigpiseal3.5.1/native/examples/generic/add.cpp
+0
-30
bigpiseal3.5.1/native/examples/generic/add.h
bigpiseal3.5.1/native/examples/generic/add.h
+0
-13
bigpiseal3.5.1/native/examples/generic/decrypt_gen.sh
bigpiseal3.5.1/native/examples/generic/decrypt_gen.sh
+0
-100
bigpiseal3.5.1/native/examples/generic/encrypt_gen.sh
bigpiseal3.5.1/native/examples/generic/encrypt_gen.sh
+0
-126
bigpiseal3.5.1/native/examples/generic/generic_decrypt.cpp
bigpiseal3.5.1/native/examples/generic/generic_decrypt.cpp
+0
-71
bigpiseal3.5.1/native/examples/generic/generic_encrypt.cpp
bigpiseal3.5.1/native/examples/generic/generic_encrypt.cpp
+0
-68
bigpiseal3.5.1/native/examples/generic/generic_evaluate.cpp
bigpiseal3.5.1/native/examples/generic/generic_evaluate.cpp
+0
-63
bigpiseal3.5.1/native/examples/generic/generic_evaluate_multiply.cpp
...5.1/native/examples/generic/generic_evaluate_multiply.cpp
+0
-65
bigpiseal3.5.1/native/examples/generic/generic_evaluate_sub.cpp
...eal3.5.1/native/examples/generic/generic_evaluate_sub.cpp
+0
-63
bigpiseal3.5.1/native/examples/generic/generic_genkey.cpp
bigpiseal3.5.1/native/examples/generic/generic_genkey.cpp
+0
-23
bigpiseal3.5.1/native/examples/generic/genkey_gen.sh
bigpiseal3.5.1/native/examples/generic/genkey_gen.sh
+0
-36
No files found.
Too many changes to show.
To preserve performance only
268 of 268+
files are displayed.
Plain diff
Email patch
bigpiseal3.5.1/native/examples/ANN/v1/test_v1.sh
deleted
100644 → 0
View file @
d8df7d47
mkdir
-p
keys/
mkdir
-p
lcheck/
mkdir
-p
parent/
mkdir
-p
result/
# rm ls.txt
# bash data_creating.sh 0 99 9 1000
# Number of driving licenses, eg: (0..99)
min
=
0
max
=
101
# max=1631
# max=101
# sim: (eval: 0.465s, 0.488s, 0.480s decrypt: 0.028s, 0.080s, 0.077s)
# seq: (eval: 0.xxx, 0.xxx, 0.xxx decrypt: 0.xxx, 0.xxx, 0.xxx)
# max=203
# (eval: 3.635s, 3.510s, 3.628s decrypt: 0.062s, 0.153s. 0.134s)
# seq: (eval: 0.xxx, 0.xxx, 0.xxx decrypt: 0.xxx, 0.xxx, 0.xxx)
# max=407
# (eval: 38.607s, 39.600s, 39.565s decrypt: 0.264s, 0.260s, 0.245s)
# seq: (eval: 0.xxx, 0.xxx, 0.xxx decrypt: 0.xxx, 0.xxx, 0.xxx)
# max=815
# (eval: x decrypt: x )
# Number of chars/words of a driving license, eg: 9
n_char
=
39
# Encrypted number range, eg: 10, 100, 1000 for 1 2 3 4 digits
range
=
255
# (8-bit)
# sampling size
sample
=
40
CURR_DIR
=
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
&&
pwd
)
# Note
# gen keys
# ./ANN_genkey_v1 keys/
${
CURR_DIR
}
/ANN_genkey_v1 keys/
line
=
$((
RANDOM
%
max
))
lcheck
=
""
# gen data
for
i
in
$(
seq
$min
$max
)
do
mkdir
-p
parent/l
"
$i
"
/
echo
"Created folder
$i
"
value
=
""
for
j
in
$(
seq
0
$n_char
)
do
value+
=
"
$((
RANDOM
%
$range
))
"
done
echo
$value
echo
$value
>>
ls.txt
# ./ANN_encrypt_v1 "$value" "l" parent/l"$i"/ $sample keys/
${
CURR_DIR
}
/ANN_encrypt_v1
"
$value
"
"l"
parent/l
"
$i
"
/
$sample
keys/
if
[[
"
$line
"
-eq
"
$i
"
]]
then
lcheck
=
"
$value
"
fi
done
# get random lc
# lcheck=$(sed -n "$((RANDOM %9){p;q}" ls.txt)
# line=$((RANDOM %max))
# lcheck="$(sed -n "${line}{p;q}" ls.txt)"
echo
"Pick up license to check:
$lcheck
"
# ./ANN_encrypt_v1 "$lcheck" "l" lcheck/ $sample keys/
${
CURR_DIR
}
/ANN_encrypt_v1
"
$lcheck
"
"l"
lcheck/
$sample
keys/
# ./ANN_encrypt "47 25 76 23 30 21 1 47 88 3" "a" keys/bfv.pk lcheck/
# eval
value1
=
"lcheck/l.ct "
value2
=
""
for
i
in
$(
seq
0
$max
)
do
value2+
=
"parent/l
${
i
}
/l.ct "
done
# value2="${value1} ${value2}"
value3
=
"
$value1$value2
"
echo
"
$value3
"
# time ./ANN_evaluate_v1 $value3 "l" result/ $sample keys/
# ./ANN_evaluate_v1 $value3 "l" result/ $sample keys/
time
${
CURR_DIR
}
/ANN_evaluate_v1
$value3
"l"
result/
$sample
keys/
echo
""
# time ./ANN_decrypt_result_v1 result/l.ct $sample keys/
# ./ANN_decrypt_result_v1 result/l.ct $sample keys/
${
CURR_DIR
}
/ANN_decrypt_result_v1 result/l.ct
$sample
keys/
# rm -r keys/*
# rm -r lcheck/*
# rm -r parent/*
# rm -r result/*
# rm ls.txt
bigpiseal3.5.1/native/examples/ANN/v1/util.cpp
deleted
100644 → 0
View file @
d8df7d47
#include "util.h"
// #include <filesystem>
#include "seal_api.h"
// #include <boost/filesystem.hpp>
// namespace fs = boost::filesystem;
bool
sub_str_exist
(
const
std
::
string
&
str
,
const
std
::
string
&
sub_str
)
{
return
str
.
size
()
>=
sub_str
.
size
()
&&
str
.
compare
(
str
.
size
()
-
sub_str
.
size
(),
sub_str
.
size
(),
sub_str
)
==
0
;
}
// int findNumberOfFilesInDirectory(const std::string &path)
// {
// auto dirIter = std::filesystem::directory_iterator(path);
// int fileCount = std::count_if(
// begin(dirIter),
// end(dirIter),
// [](auto &entry) { return entry.is_regular_file(); });
// return fileCount;
// }
// int findNumberOfFilesInDirectory(std::string &path, std::string &ext)
// int findNumberOfFilesInDirectory(const std::string &path)
// {
// // namespace fs = boost::filesystem;
// std::string ext = ".ct";
// fs::path Path(path);
// int Nb_ext = 0;
// fs::directory_iterator end_iter; // Default constructor for an iterator is the end iterator
// for (fs::directory_iterator iter(Path); iter != end_iter; ++iter)
// if (iter->path().extension() == ext)
// ++Nb_ext;
// return Nb_ext;
// }
// c++ 17
// std::vector<std::string> get_directories(const std::string &s)
// {
// std::vector<std::string> r;
// for(auto& p : std::filesystem::recursive_directory_iterator(s))
// if (p.is_directory())
// r.push_back(p.path().string());
// return r;
// }
// struct path_leaf_string
// {
// std::string operator()(const boost::filesystem::directory_entry &entry) const
// {
// return entry.path().leaf().string();
// }
// };
// std::vector<std::string> get_directories(const std::string &s)
// {
// std::vector<std::string> v;
// boost::filesystem::path p(s);
// boost::filesystem::directory_iterator start(p);
// boost::filesystem::directory_iterator end;
// std::transform(start, end, std::back_inserter(v), path_leaf_string());
// std::copy(v.begin(), v.end(),
// std::ostream_iterator<std::string>(std::cout, "\n"));
// return v;
// }
bigpiseal3.5.1/native/examples/ANN/v1/util.h
deleted
100644 → 0
View file @
d8df7d47
#ifndef _UTIL_H_
#define _UTIL_H_
#include <string>
#include <vector>
// int findNumberOfFilesInDirectory(const std::string &path);
bool
sub_str_exist
(
const
std
::
string
&
str
,
const
std
::
string
&
sub_str
);
// std::vector<std::string> get_directories(const std::string &s);
// std::vector<std::string> get_directories_deep(const std::string &s);
#endif
bigpiseal3.5.1/native/examples/CMakeLists.txt
deleted
100644 → 0
View file @
d8df7d47
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.
target_sources
(
sealexamples
PRIVATE
${
CMAKE_CURRENT_LIST_DIR
}
/examples.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/1_bfv_basics.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/2_encoders.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/3_levels.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/4_ckks_basics.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/5_rotation.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/6_serialization.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/7_performance.cpp
)
\ No newline at end of file
bigpiseal3.5.1/native/examples/SEALExamples.vcxproj
deleted
100644 → 0
View file @
d8df7d47
<?xml version="1.0" encoding="utf-8"?>
<Project
DefaultTargets=
"Build"
ToolsVersion=
"15.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ItemGroup
Label=
"ProjectConfigurations"
>
<ProjectConfiguration
Include=
"Debug|Win32"
>
<Configuration>
Debug
</Configuration>
<Platform>
Win32
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Debug|x64"
>
<Configuration>
Debug
</Configuration>
<Platform>
x64
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Release|Win32"
>
<Configuration>
Release
</Configuration>
<Platform>
Win32
</Platform>
</ProjectConfiguration>
<ProjectConfiguration
Include=
"Release|x64"
>
<Configuration>
Release
</Configuration>
<Platform>
x64
</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup
Label=
"Globals"
>
<ProjectGuid>
{2B57D847-26DC-45FF-B9AF-EE33910B5093}
</ProjectGuid>
<Keyword>
Win32Proj
</Keyword>
<RootNamespace>
SEALExamples
</RootNamespace>
<WindowsTargetPlatformVersion>
10.0
</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.Default.props"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
true
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
true
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
Label=
"Configuration"
>
<ConfigurationType>
Application
</ConfigurationType>
<UseDebugLibraries>
false
</UseDebugLibraries>
<PlatformToolset>
v142
</PlatformToolset>
<WholeProgramOptimization>
true
</WholeProgramOptimization>
<CharacterSet>
Unicode
</CharacterSet>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.props"
/>
<ImportGroup
Label=
"ExtensionSettings"
>
</ImportGroup>
<ImportGroup
Label=
"Shared"
>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
Label=
"PropertySheets"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Label=
"PropertySheets"
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<ImportGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
Label=
"PropertySheets"
>
<Import
Project=
"$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props"
Condition=
"exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')"
Label=
"LocalAppDataPlatform"
/>
</ImportGroup>
<PropertyGroup
Label=
"UserMacros"
/>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<LinkIncremental>
true
</LinkIncremental>
<OutDir>
$(ProjectDir)..\..\bin\$(Platform)\$(Configuration)\
</OutDir>
<IntDir>
$(ProjectDir)obj\$(Platform)\$(Configuration)\
</IntDir>
<TargetName>
sealexamples
</TargetName>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<LinkIncremental>
true
</LinkIncremental>
<OutDir>
$(ProjectDir)..\..\bin\$(Platform)\$(Configuration)\
</OutDir>
<IntDir>
$(ProjectDir)obj\$(Platform)\$(Configuration)\
</IntDir>
<TargetName>
sealexamples
</TargetName>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<LinkIncremental>
false
</LinkIncremental>
<OutDir>
$(ProjectDir)..\..\bin\$(Platform)\$(Configuration)\
</OutDir>
<IntDir>
$(ProjectDir)obj\$(Platform)\$(Configuration)\
</IntDir>
<TargetName>
sealexamples
</TargetName>
</PropertyGroup>
<PropertyGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<LinkIncremental>
false
</LinkIncremental>
<OutDir>
$(ProjectDir)..\..\bin\$(Platform)\$(Configuration)\
</OutDir>
<IntDir>
$(ProjectDir)obj\$(Platform)\$(Configuration)\
</IntDir>
<TargetName>
sealexamples
</TargetName>
</PropertyGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|x64'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<PrecompiledHeader>
NotUsing
</PrecompiledHeader>
<Optimization>
Disabled
</Optimization>
<PreprocessorDefinitions>
_ENABLE_EXTENDED_ALIGNED_STORAGE
</PreprocessorDefinitions>
<SDLCheck>
true
</SDLCheck>
<AdditionalIncludeDirectories>
$(SolutionDir)native\src
</AdditionalIncludeDirectories>
<LanguageStandard>
stdcpp17
</LanguageStandard>
<AdditionalOptions>
/Zc:__cplusplus %(AdditionalOptions)
</AdditionalOptions>
<ControlFlowGuard>
Guard
</ControlFlowGuard>
<DebugInformationFormat>
ProgramDatabase
</DebugInformationFormat>
<MultiProcessorCompilation>
true
</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<AdditionalLibraryDirectories>
$(ProjectDir)..\..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)
</AdditionalLibraryDirectories>
<AdditionalDependencies>
seal.lib;%(AdditionalDependencies)
</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Debug|Win32'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<PrecompiledHeader>
NotUsing
</PrecompiledHeader>
<Optimization>
Disabled
</Optimization>
<PreprocessorDefinitions>
_ENABLE_EXTENDED_ALIGNED_STORAGE
</PreprocessorDefinitions>
<SDLCheck>
true
</SDLCheck>
<AdditionalIncludeDirectories>
$(SolutionDir)native\src
</AdditionalIncludeDirectories>
<LanguageStandard>
stdcpp17
</LanguageStandard>
<AdditionalOptions>
/Zc:__cplusplus %(AdditionalOptions)
</AdditionalOptions>
<ControlFlowGuard>
Guard
</ControlFlowGuard>
<DebugInformationFormat>
ProgramDatabase
</DebugInformationFormat>
<MultiProcessorCompilation>
true
</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<AdditionalLibraryDirectories>
$(ProjectDir)..\..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)
</AdditionalLibraryDirectories>
<AdditionalDependencies>
seal.lib;%(AdditionalDependencies)
</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|x64'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<PrecompiledHeader>
NotUsing
</PrecompiledHeader>
<Optimization>
MaxSpeed
</Optimization>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<PreprocessorDefinitions>
_ENABLE_EXTENDED_ALIGNED_STORAGE
</PreprocessorDefinitions>
<SDLCheck>
true
</SDLCheck>
<AdditionalIncludeDirectories>
$(SolutionDir)native\src
</AdditionalIncludeDirectories>
<LanguageStandard>
stdcpp17
</LanguageStandard>
<AdditionalOptions>
/Zc:__cplusplus %(AdditionalOptions)
</AdditionalOptions>
<ControlFlowGuard>
Guard
</ControlFlowGuard>
<MultiProcessorCompilation>
true
</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<EnableCOMDATFolding>
true
</EnableCOMDATFolding>
<OptimizeReferences>
true
</OptimizeReferences>
<AdditionalLibraryDirectories>
$(ProjectDir)..\..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)
</AdditionalLibraryDirectories>
<AdditionalDependencies>
seal.lib;%(AdditionalDependencies)
</AdditionalDependencies>
<Profile>
true
</Profile>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition=
"'$(Configuration)|$(Platform)'=='Release|Win32'"
>
<ClCompile>
<WarningLevel>
Level3
</WarningLevel>
<PrecompiledHeader>
NotUsing
</PrecompiledHeader>
<Optimization>
MaxSpeed
</Optimization>
<FunctionLevelLinking>
true
</FunctionLevelLinking>
<IntrinsicFunctions>
true
</IntrinsicFunctions>
<PreprocessorDefinitions>
_ENABLE_EXTENDED_ALIGNED_STORAGE
</PreprocessorDefinitions>
<SDLCheck>
true
</SDLCheck>
<AdditionalIncludeDirectories>
$(SolutionDir)native\src
</AdditionalIncludeDirectories>
<LanguageStandard>
stdcpp17
</LanguageStandard>
<AdditionalOptions>
/Zc:__cplusplus %(AdditionalOptions)
</AdditionalOptions>
<ControlFlowGuard>
Guard
</ControlFlowGuard>
<MultiProcessorCompilation>
true
</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>
Console
</SubSystem>
<GenerateDebugInformation>
true
</GenerateDebugInformation>
<EnableCOMDATFolding>
true
</EnableCOMDATFolding>
<OptimizeReferences>
true
</OptimizeReferences>
<AdditionalLibraryDirectories>
$(ProjectDir)..\..\lib\$(Platform)\$(Configuration);%(AdditionalLibraryDirectories)
</AdditionalLibraryDirectories>
<AdditionalDependencies>
seal.lib;%(AdditionalDependencies)
</AdditionalDependencies>
<Profile>
true
</Profile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile
Include=
"1_bfv_basics.cpp"
/>
<ClCompile
Include=
"2_encoders.cpp"
/>
<ClCompile
Include=
"4_ckks_basics.cpp"
/>
<ClCompile
Include=
"5_rotation.cpp"
/>
<ClCompile
Include=
"3_levels.cpp"
/>
<ClCompile
Include=
"6_serialization.cpp"
/>
<ClCompile
Include=
"7_performance.cpp"
/>
<ClCompile
Include=
"examples.cpp"
/>
</ItemGroup>
<ItemGroup>
<Text
Include=
"CMakeLists.txt"
/>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"examples.h"
/>
</ItemGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.targets"
/>
<ImportGroup
Label=
"ExtensionTargets"
/>
</Project>
\ No newline at end of file
bigpiseal3.5.1/native/examples/SEALExamples.vcxproj.filters
deleted
100644 → 0
View file @
d8df7d47
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"4.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ItemGroup>
<Filter
Include=
"Source Files"
>
<UniqueIdentifier>
{4FC737F1-C7A5-4376-A066-2A32D752A2FF}
</UniqueIdentifier>
<Extensions>
cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
</Extensions>
</Filter>
<Filter
Include=
"Header Files"
>
<UniqueIdentifier>
{93995380-89BD-4b04-88EB-625FBE52EBFB}
</UniqueIdentifier>
<Extensions>
h;hh;hpp;hxx;hm;inl;inc;xsd
</Extensions>
</Filter>
<Filter
Include=
"Other"
>
<UniqueIdentifier>
{abd2e216-316f-4dad-a2a4-a72ffccfd92b}
</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile
Include=
"examples.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
<ClCompile
Include=
"3_levels.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
<ClCompile
Include=
"5_rotation.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
<ClCompile
Include=
"1_bfv_basics.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
<ClCompile
Include=
"2_encoders.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
<ClCompile
Include=
"4_ckks_basics.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
<ClCompile
Include=
"7_performance.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
<ClCompile
Include=
"6_serialization.cpp"
>
<Filter>
Source Files
</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Text
Include=
"CMakeLists.txt"
>
<Filter>
Other
</Filter>
</Text>
</ItemGroup>
<ItemGroup>
<ClInclude
Include=
"examples.h"
>
<Filter>
Header Files
</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
bigpiseal3.5.1/native/examples/examples.cpp
deleted
100644 → 0
View file @
d8df7d47
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
#include "examples.h"
using
namespace
std
;
using
namespace
seal
;
int
main
()
{
cout
<<
"Microsoft SEAL version: "
<<
SEAL_VERSION
<<
endl
;
while
(
true
)
{
cout
<<
"+---------------------------------------------------------+"
<<
endl
;
cout
<<
"| The following examples should be executed while reading |"
<<
endl
;
cout
<<
"| comments in associated files in native/examples/. |"
<<
endl
;
cout
<<
"+---------------------------------------------------------+"
<<
endl
;
cout
<<
"| Examples | Source Files |"
<<
endl
;
cout
<<
"+----------------------------+----------------------------+"
<<
endl
;
cout
<<
"| 1. BFV Basics | 1_bfv_basics.cpp |"
<<
endl
;
cout
<<
"| 2. Encoders | 2_encoders.cpp |"
<<
endl
;
cout
<<
"| 3. Levels | 3_levels.cpp |"
<<
endl
;
cout
<<
"| 4. CKKS Basics | 4_ckks_basics.cpp |"
<<
endl
;
cout
<<
"| 5. Rotation | 5_rotation.cpp |"
<<
endl
;
cout
<<
"| 6. Serialization | 6_serialization.cpp |"
<<
endl
;
cout
<<
"| 7. Performance Test | 7_performance.cpp |"
<<
endl
;
cout
<<
"+----------------------------+----------------------------+"
<<
endl
;
/*
Print how much memory we have allocated from the current memory pool.
By default the memory pool will be a static global pool and the
MemoryManager class can be used to change it. Most users should have
little or no reason to touch the memory allocation system.
*/
size_t
megabytes
=
MemoryManager
::
GetPool
().
alloc_byte_count
()
>>
20
;
cout
<<
"["
<<
setw
(
7
)
<<
right
<<
megabytes
<<
" MB] "
<<
"Total allocation from the memory pool"
<<
endl
;
int
selection
=
0
;
bool
invalid
=
true
;
do
{
cout
<<
endl
<<
"> Run example (1 ~ 7) or exit (0): "
;
if
(
!
(
cin
>>
selection
))
{
invalid
=
false
;
}
else
if
(
selection
<
0
||
selection
>
7
)
{
invalid
=
false
;
}
else
{
invalid
=
true
;
}
if
(
!
invalid
)
{
cout
<<
" [Beep~~] Invalid option: type 0 ~ 7"
<<
endl
;
cin
.
clear
();
cin
.
ignore
(
numeric_limits
<
streamsize
>::
max
(),
'\n'
);
}
}
while
(
!
invalid
);
switch
(
selection
)
{
case
1
:
example_bfv_basics
();
break
;
case
2
:
example_encoders
();
break
;
case
3
:
example_levels
();
break
;
case
4
:
example_ckks_basics
();
break
;
case
5
:
example_rotation
();
break
;
case
6
:
example_serialization
();
break
;
case
7
:
example_performance_test
();
break
;
case
0
:
return
0
;
}
}
return
0
;
}
bigpiseal3.5.1/native/examples/examples.h
deleted
100644 → 0
View file @
d8df7d47
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
#pragma once
#include "seal/seal.h"
#include <algorithm>
#include <chrono>
#include <cstddef>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <memory>
#include <mutex>
#include <numeric>
#include <random>
#include <sstream>
#include <string>
#include <thread>
#include <vector>
void
example_bfv_basics
();
void
example_encoders
();
void
example_levels
();
void
example_ckks_basics
();
void
example_rotation
();
void
example_serialization
();
void
example_performance_test
();
/*
Helper function: Prints the name of the example in a fancy banner.
*/
inline
void
print_example_banner
(
std
::
string
title
)
{
if
(
!
title
.
empty
())
{
std
::
size_t
title_length
=
title
.
length
();
std
::
size_t
banner_length
=
title_length
+
2
*
10
;
std
::
string
banner_top
=
"+"
+
std
::
string
(
banner_length
-
2
,
'-'
)
+
"+"
;
std
::
string
banner_middle
=
"|"
+
std
::
string
(
9
,
' '
)
+
title
+
std
::
string
(
9
,
' '
)
+
"|"
;
std
::
cout
<<
std
::
endl
<<
banner_top
<<
std
::
endl
<<
banner_middle
<<
std
::
endl
<<
banner_top
<<
std
::
endl
;
}
}
/*
Helper function: Prints the parameters in a SEALContext.
*/
inline
void
print_parameters
(
std
::
shared_ptr
<
seal
::
SEALContext
>
context
)
{
// Verify parameters
if
(
!
context
)
{
throw
std
::
invalid_argument
(
"context is not set"
);
}
auto
&
context_data
=
*
context
->
key_context_data
();
/*
Which scheme are we using?
*/
std
::
string
scheme_name
;
switch
(
context_data
.
parms
().
scheme
())
{
case
seal
::
scheme_type
::
BFV
:
scheme_name
=
"BFV"
;
break
;
case
seal
::
scheme_type
::
CKKS
:
scheme_name
=
"CKKS"
;
break
;
default:
throw
std
::
invalid_argument
(
"unsupported scheme"
);
}
std
::
cout
<<
"/"
<<
std
::
endl
;
std
::
cout
<<
"| Encryption parameters :"
<<
std
::
endl
;
std
::
cout
<<
"| scheme: "
<<
scheme_name
<<
std
::
endl
;
std
::
cout
<<
"| poly_modulus_degree: "
<<
context_data
.
parms
().
poly_modulus_degree
()
<<
std
::
endl
;
/*
Print the size of the true (product) coefficient modulus.
*/
std
::
cout
<<
"| coeff_modulus size: "
;
std
::
cout
<<
context_data
.
total_coeff_modulus_bit_count
()
<<
" ("
;
auto
coeff_modulus
=
context_data
.
parms
().
coeff_modulus
();
std
::
size_t
coeff_modulus_size
=
coeff_modulus
.
size
();
for
(
std
::
size_t
i
=
0
;
i
<
coeff_modulus_size
-
1
;
i
++
)
{
std
::
cout
<<
coeff_modulus
[
i
].
bit_count
()
<<
" + "
;
}
std
::
cout
<<
coeff_modulus
.
back
().
bit_count
();
std
::
cout
<<
") bits"
<<
std
::
endl
;
/*
For the BFV scheme print the plain_modulus parameter.
*/
if
(
context_data
.
parms
().
scheme
()
==
seal
::
scheme_type
::
BFV
)
{
std
::
cout
<<
"| plain_modulus: "
<<
context_data
.
parms
().
plain_modulus
().
value
()
<<
std
::
endl
;
}
std
::
cout
<<
"
\\
"
<<
std
::
endl
;
}
/*
Helper function: Prints the `parms_id' to std::ostream.
*/
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
stream
,
seal
::
parms_id_type
parms_id
)
{
/*
Save the formatting information for std::cout.
*/
std
::
ios
old_fmt
(
nullptr
);
old_fmt
.
copyfmt
(
std
::
cout
);
stream
<<
std
::
hex
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
16
)
<<
parms_id
[
0
]
<<
" "
<<
std
::
setw
(
16
)
<<
parms_id
[
1
]
<<
" "
<<
std
::
setw
(
16
)
<<
parms_id
[
2
]
<<
" "
<<
std
::
setw
(
16
)
<<
parms_id
[
3
]
<<
" "
;
/*
Restore the old std::cout formatting.
*/
std
::
cout
.
copyfmt
(
old_fmt
);
return
stream
;
}
/*
Helper function: Prints a vector of floating-point values.
*/
template
<
typename
T
>
inline
void
print_vector
(
std
::
vector
<
T
>
vec
,
std
::
size_t
print_size
=
4
,
int
prec
=
3
)
{
/*
Save the formatting information for std::cout.
*/
std
::
ios
old_fmt
(
nullptr
);
old_fmt
.
copyfmt
(
std
::
cout
);
std
::
size_t
slot_count
=
vec
.
size
();
std
::
cout
<<
std
::
fixed
<<
std
::
setprecision
(
prec
);
std
::
cout
<<
std
::
endl
;
if
(
slot_count
<=
2
*
print_size
)
{
std
::
cout
<<
" ["
;
for
(
std
::
size_t
i
=
0
;
i
<
slot_count
;
i
++
)
{
std
::
cout
<<
" "
<<
vec
[
i
]
<<
((
i
!=
slot_count
-
1
)
?
","
:
" ]
\n
"
);
}
}
else
{
vec
.
resize
(
std
::
max
(
vec
.
size
(),
2
*
print_size
));
std
::
cout
<<
" ["
;
for
(
std
::
size_t
i
=
0
;
i
<
print_size
;
i
++
)
{
std
::
cout
<<
" "
<<
vec
[
i
]
<<
","
;
}
if
(
vec
.
size
()
>
2
*
print_size
)
{
std
::
cout
<<
" ...,"
;
}
for
(
std
::
size_t
i
=
slot_count
-
print_size
;
i
<
slot_count
;
i
++
)
{
std
::
cout
<<
" "
<<
vec
[
i
]
<<
((
i
!=
slot_count
-
1
)
?
","
:
" ]
\n
"
);
}
}
std
::
cout
<<
std
::
endl
;
/*
Restore the old std::cout formatting.
*/
std
::
cout
.
copyfmt
(
old_fmt
);
}
/*
Helper function: Prints a matrix of values.
*/
template
<
typename
T
>
inline
void
print_matrix
(
std
::
vector
<
T
>
matrix
,
std
::
size_t
row_size
)
{
/*
We're not going to print every column of the matrix (there are 2048). Instead
print this many slots from beginning and end of the matrix.
*/
std
::
size_t
print_size
=
5
;
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
" ["
;
for
(
std
::
size_t
i
=
0
;
i
<
print_size
;
i
++
)
{
std
::
cout
<<
std
::
setw
(
3
)
<<
std
::
right
<<
matrix
[
i
]
<<
","
;
}
std
::
cout
<<
std
::
setw
(
3
)
<<
" ...,"
;
for
(
std
::
size_t
i
=
row_size
-
print_size
;
i
<
row_size
;
i
++
)
{
std
::
cout
<<
std
::
setw
(
3
)
<<
matrix
[
i
]
<<
((
i
!=
row_size
-
1
)
?
","
:
" ]
\n
"
);
}
std
::
cout
<<
" ["
;
for
(
std
::
size_t
i
=
row_size
;
i
<
row_size
+
print_size
;
i
++
)
{
std
::
cout
<<
std
::
setw
(
3
)
<<
matrix
[
i
]
<<
","
;
}
std
::
cout
<<
std
::
setw
(
3
)
<<
" ...,"
;
for
(
std
::
size_t
i
=
2
*
row_size
-
print_size
;
i
<
2
*
row_size
;
i
++
)
{
std
::
cout
<<
std
::
setw
(
3
)
<<
matrix
[
i
]
<<
((
i
!=
2
*
row_size
-
1
)
?
","
:
" ]
\n
"
);
}
std
::
cout
<<
std
::
endl
;
}
/*
Helper function: Print line number.
*/
inline
void
print_line
(
int
line_number
)
{
std
::
cout
<<
"Line "
<<
std
::
setw
(
3
)
<<
line_number
<<
" --> "
;
}
bigpiseal3.5.1/native/examples/generic/CMakeLists.txt
deleted
100644 → 0
View file @
d8df7d47
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.
cmake_minimum_required
(
VERSION 3.10
)
set
(
TEST_NAME generic
)
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
(
EVAL_BIN_MUL
${
TEST_NAME
}
_evaluate_multiply
)
set
(
EVAL_BIN_SUB
${
TEST_NAME
}
_evaluate_sub
)
set
(
SCR_ENC encrypt_gen.sh
)
set
(
SCR_DEC decrypt_gen.sh
)
set
(
SCR_GEN genkey_gen.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
}
/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
}
/add.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/
${
TEST_NAME
}
_evaluate.cpp
)
set
(
EVAL_SRCS_SUB
${
CMAKE_CURRENT_LIST_DIR
}
/seal_api.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/sub.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/
${
TEST_NAME
}
_evaluate_sub.cpp
)
set
(
EVAL_SRCS_MUL
${
CMAKE_CURRENT_LIST_DIR
}
/seal_api.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/multiply.cpp
${
CMAKE_CURRENT_LIST_DIR
}
/
${
TEST_NAME
}
_evaluate_multiply.cpp
)
set
(
HEADER_DIR
${
CMAKE_SOURCE_DIR
}
/
${
TEST_NAME
}
)
set
(
HEADER_FILES
${
CMAKE_CURRENT_LIST_DIR
}
/seal_api.h
${
CMAKE_CURRENT_LIST_DIR
}
/add.h
)
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
}
)
add_executable
(
${
EVAL_BIN_SUB
}
${
EVAL_SRCS_SUB
}
${
HEADER_FILES
}
)
add_executable
(
${
EVAL_BIN_MUL
}
${
EVAL_SRCS_MUL
}
${
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
(
${
EVAL_BIN_SUB
}
SEAL::seal
)
target_link_libraries
(
${
EVAL_BIN_MUL
}
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
(
${
EVAL_BIN_SUB
}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY
"
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/
${
TEST_NAME
}
"
)
set_target_properties
(
${
EVAL_BIN_MUL
}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY
"
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/
${
TEST_NAME
}
"
)
file
(
COPY
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SCR_ENC
}
DESTINATION
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/
${
TEST_NAME
}
)
file
(
COPY
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SCR_DEC
}
DESTINATION
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/
${
TEST_NAME
}
)
file
(
COPY
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SCR_GEN
}
DESTINATION
${
CMAKE_RUNTIME_OUTPUT_DIRECTORY
}
/
${
TEST_NAME
}
)
bigpiseal3.5.1/native/examples/generic/add.cpp
deleted
100644 → 0
View file @
d8df7d47
#include "add.h"
using
namespace
std
;
using
namespace
seal
;
void
add_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct
,
Plaintext
&
pt
,
Ciphertext
&
ct_out
)
{
timeval
t0
,
t1
;
unsigned
long
dt
=
0
;
gettimeofday
(
&
t0
,
NULL
);
op_st
.
eval
->
add_plain
(
ct
,
pt
,
ct_out
);
gettimeofday
(
&
t1
,
NULL
);
dt
=
1000000
*
(
t1
.
tv_sec
-
t0
.
tv_sec
)
+
(
t1
.
tv_usec
-
t0
.
tv_usec
);
cout
<<
"[INFO] Homomorphic addition (pt+ct) time in (us): "
<<
dt
<<
endl
;
}
void
add_ciphertext
(
struct
evaluator_t
&
op_st
,
Ciphertext
&
ct1
,
Ciphertext
&
ct2
,
Ciphertext
&
ct_out
)
{
timeval
t0
,
t1
;
unsigned
long
dt
=
0
;
gettimeofday
(
&
t0
,
NULL
);
op_st
.
eval
->
add
(
ct1
,
ct2
,
ct_out
);
gettimeofday
(
&
t1
,
NULL
);
dt
=
1000000
*
(
t1
.
tv_sec
-
t0
.
tv_sec
)
+
(
t1
.
tv_usec
-
t0
.
tv_usec
);
cout
<<
"[INFO] Homomorphic addition (ct+ct) time in (us): "
<<
dt
<<
endl
;
}
bigpiseal3.5.1/native/examples/generic/add.h
deleted
100644 → 0
View file @
d8df7d47
#ifndef _ADD_H_
#define _ADD_H_
#include <sys/time.h>
#include <iostream>
#include <string>
#include "seal/seal.h"
#include "seal_api.h"
void
add_ciphertext
(
struct
evaluator_t
&
op_st
,
seal
::
Ciphertext
&
ct
,
seal
::
Plaintext
&
pt
,
seal
::
Ciphertext
&
ct_out
);
void
add_ciphertext
(
struct
evaluator_t
&
op_st
,
seal
::
Ciphertext
&
ct1
,
seal
::
Ciphertext
&
ct2
,
seal
::
Ciphertext
&
ct_out
);
#endif
bigpiseal3.5.1/native/examples/generic/decrypt_gen.sh
deleted
100644 → 0
View file @
d8df7d47
#!/bin/bash
#
# 2020 CEA LIST.
declare
-r
ERROR_NUMBER_PARAM
=
1
declare
-r
ERROR_VALUE_PARAM
=
2
declare
-r
ERROR_KEY_NOT_FOUND
=
3
declare
-r
ERRROR_ENCRYPT_DECRYPT_NOT_PERFORMED
=
4
declare
-r
ERROR_FILE_ZIP_NOT
FOUND
=
5
CURR_DIR
=
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
&&
pwd
)
# /opt/seal/native/bin
# /opt/pki/seal/
# /opt/pki/seal/natives/examples/generic
# seal preparation executable seal_generic_decrypt
# code genéré pour 63bits signés.
# params
# 1 size_bit 1 63
# 2 signed 0 unsigned 1 signed
# 3 path_to_key .pk
# 4 path_to_storage
# 5 prefix
if
[
"$#"
-ne
5
]
;
then
echo
"You must enter exactly 5 command line arguments"
echo
"size bit <1..63>, signed <0,1> , path to sk , path to storage, prefix "
exit
1
fi
# size bit 1 63
case
$1
in
''
|
*
[!
0-9]
*
)
echo
only numeric size 1..63
;;
*
)
echo
numeric
if
[
"
$1
"
-ge
1
-a
"
$1
"
-le
63
]
;
then
echo
"size input Ok"
else
echo echo
"ERROR_SIZING VALUE "
$1
",size bit is 1..63"
exit
2
fi
;;
esac
size_bit
=
$1
# signed 0 or 1
case
$2
in
''
|
*
[!
0-1]
*
)
echo
bad only 0 or 1
for
signed value
;
exit
2
;;
*
)
echo
Signed value OK
;;
esac
signed
=
$2
# path to sk an key existence
# if not found error
path_to_key
=
$3
# si $3 contient .sk à la fin, alors c'est correct sinon
# si cest directory alors ajouter bfv.sk a la fin
# si c'est un fichier, verifier l'existence
if
[[
"
$path_to_key
"
==
*
/
]]
then
file
=
"
$path_to_key
"
bfv.sk
else
file
=
"
$path_to_key
"
/bfv.sk
fi
if
test
-f
"
$file
"
;
then
echo
"
$file
exist"
else
echo
" ERROR_KEY_NOT_FOUND "
$3
/bfv.sk
" not found"
$file
exit
3
fi
# path to result
path_to_storage
=
$4
if
[[
"
$path_to_storage
"
==
*
/
]]
then
file
=
"
$path_to_storage
"
else
file
=
"
$path_to_storage
"
/
fi
prefix
=
$5
if
[
-d
"
$path_to_storage
"
]
then
echo
1
else
echo
3
#~ extract_zip
fi
${
CURR_DIR
}
/generic_decrypt
$prefix
$path_to_key
$path_to_storage
# ./generic_decrypt ct2 /home/bigpi/ storage/
# recuperate result
if
[
"
$?
"
==
"0"
]
;
then
echo
ok
done
else
echo
DECRYPTION_NOT_PERFORMED
exit
4
fi
bigpiseal3.5.1/native/examples/generic/encrypt_gen.sh
deleted
100644 → 0
View file @
d8df7d47
#!/bin/bash
#
# 2020 CEA LIST.
declare
-r
ERROR_NUMBER_PARAM
=
1
declare
-r
ERROR_VALUE_PARAM
=
2
declare
-r
ERROR_KEY_NOT_FOUND
=
3
declare
-r
ERRROR_ENCRYPT_DECRYPT_NOT_PERFORMED
=
4
declare
-r
ERROR_FILE_ZIP_NOTFOUND
=
5
#/opt/seal/native/bin
# /opt/pki/seal/
# /opt/pki/seal/natives/examples/generic
CURR_DIR
=
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
&&
pwd
)
# params executable seal_generic_encrypt
# value
# size_bit 1 63 , limited to 63 bits Seal -ou 2-**63signed max=x value to test
# signed 0 unsigned 1 signed
# path_to_key existing key pk encrypt
# path_storage
if
[
"$#"
-ne
6
]
;
then
echo
"You must enter exactly 6 command line arguments"
# display help if empty
echo
"value , size bit <1..63>, signed <0,1> , path to sk , path to storage, prefix "
exit
$ERROR_NUMBER_PARAM
fi
[
-n
"
$1
"
]
&&
[
"
$1
"
-eq
"
$1
"
]
2>/dev/null
if
[
$?
-ne
0
]
;
then
echo
$1
is not number
exit
2
fi
[
-n
"
$2
"
]
&&
[
"
$2
"
-eq
"
$2
"
]
2>/dev/null
if
[
$?
-ne
0
]
;
then
echo
$2
is not number
exit
2
else
if
[
"
$2
"
-ge
1
-a
"
$2
"
-le
63
]
;
then
echo
"size input Ok"
else
echo
"ERROR_SIZING VALUE "
$2
",size bit is 1..63"
exit
2
fi
fi
value
=
$1
size_bit
=
$2
case
$3
in
''
|
*
[!
0-1]
*
)
echo
bad signed value
$3
, only 0 or 1
;
exit
2
;;
*
)
echo
Signed value OK
;;
esac
Signed
=
$3
path_to_key
=
$4
if
[[
"
$path_to_key
"
==
*
/
]]
then
file
=
"
$path_to_key
"
bfv.pk
else
file
=
"
$path_to_key
"
/bfv.pk
fi
if
test
-f
"
$file
"
;
then
echo
"
$file
exist"
else
echo
"ERROR_KEY_NOT_FOUND "
$4
/bfv.pk
" not found"
exit
3
fi
directory
=
$5
if
[
-d
"
$directory
"
]
then
echo
"OK"
else
echo
" Path to storage directory "
$5
" not found"
mkdir
$directory
#
echo
" path to storage created"
fi
path_storage
=
$5
prefix
=
$6
defaut_coherence_test_value_sizebit_seal
()
{
# define max value equal 2*2 ..*2 size_bit time
((
X
=(
2
**
$size_bit
)
-1
))
;
echo
"max value"
$X
((
Y
=(
2
**
63
)
-1
))
;
echo
"max value 2**63 -1"
$Y
# let "maxvalue=1"
# for i in $(seq $1 $size_bit)
# do
# let "maxvalue=maxvalue*2"
# done
if
[
"
$value
"
-gt
"
$Y
"
]
;
then
echo
" value to high or equal"
,
$value
,
" to max value"
$Y
exit
2
fi
}
defaut_coherence_test_value_sizebit_seal
# encryption
echo
"encryption"
${
CURR_DIR
}
/generic_encrypt
$value
$prefix
$path_to_key
$path_storage
# recuperate result
if
[
"
$?
"
==
"0"
]
;
then
echo
ok
done
else
echo
ENCRYPTION_NOT_PERFORMED
exit
4
fi
exit
bigpiseal3.5.1/native/examples/generic/generic_decrypt.cpp
deleted
100644 → 0
View file @
d8df7d47
#include <sys/time.h>
#include "seal_api.h"
using
namespace
std
;
using
namespace
seal
;
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
4
)
cout
<<
"[ERROR] please enter prefix_file_to_decrypt full/path/key /full/path/to/storage"
<<
endl
;
// ./_decrypt prefix_name ct3 /home/bigpi/ storage/
else
{
timeval
t0
,
t1
;
unsigned
long
dt
=
0
;
struct
decryptor_t
decr
;
string
pathK
=
argv
[
2
];
string
Ctfile
=
argv
[
1
];
string
prefix
(
""
);
if
(
suffix_exist
(
pathK
,
"/"
))
{
prefix
.
append
(
pathK
);
}
else
{
prefix
.
append
(
pathK
);
prefix
.
append
(
"/"
);
}
//cout << "[INFO] Keypathname sk: " << prefix << endl;
init_operator
(
8192
,
4294967296
,
decr
,
prefix
);
// path to storage argv[3]
string
pathStorage
=
argv
[
3
];
prefix
=
""
;
if
(
suffix_exist
(
pathStorage
,
"/"
))
{
prefix
.
append
(
pathStorage
);
}
else
{
prefix
.
append
(
pathStorage
);
prefix
.
append
(
"/"
);
}
//cout << "[INFO] Ctx de " << prefix << endl;
Ciphertext
ct
;
if
(
Ctfile
.
at
(
0
)
==
'/'
)
load_ciphertext
(
decr
,
ct
,
Ctfile
);
else
{
prefix
.
append
(
Ctfile
);
load_ciphertext
(
decr
,
ct
,
prefix
);
}
gettimeofday
(
&
t0
,
NULL
);
load_ciphertext
(
decr
,
ct
,
prefix
);
gettimeofday
(
&
t0
,
NULL
);
decrypt_ciphertext
(
decr
,
ct
);
gettimeofday
(
&
t1
,
NULL
);
dt
=
1000000
*
(
t1
.
tv_sec
-
t0
.
tv_sec
)
+
(
t1
.
tv_usec
-
t0
.
tv_usec
);
cout
<<
"[INFO] ciphertext decryption time in seconds: "
<<
((
float
)
dt
)
/
1000000
<<
endl
;
delete_operator
(
decr
);
return
0
;
}
}
bigpiseal3.5.1/native/examples/generic/generic_encrypt.cpp
deleted
100644 → 0
View file @
d8df7d47
#include <cstdint>
#include <sys/time.h>
#include <boost/lexical_cast.hpp>
#include "seal_api.h"
using
namespace
std
;
using
namespace
seal
;
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
5
)
cerr
<<
"[ERROR] please enter 1 plaintext values, prefix , pathstorage(exists) "
<<
endl
;
// ./generic_encrypt 21 ct1 /home/bigpi/ storage/
else
{
timeval
t0
,
t1
;
unsigned
long
dt
=
0
;
struct
encryptor_t
encr
;
string
pathK
=
argv
[
3
];
string
Prefix
=
argv
[
2
];
string
pathStorage
=
argv
[
4
];
//cout << "[INFO] Prefix . : " << Prefix << endl;
string
prefix
(
""
);
//string postfix1(".ct");
prefix
=
""
;
if
(
suffix_exist
(
pathK
,
"/"
))
{
prefix
.
append
(
pathK
);
}
else
{
prefix
.
append
(
pathK
);
prefix
.
append
(
"/"
);
}
init_operator
(
8192
,
4294967296
,
encr
,
prefix
);
Ciphertext
ct
;
int64_t
plain
=
boost
::
lexical_cast
<
int64_t
>
(
argv
[
1
]);
gettimeofday
(
&
t0
,
NULL
);
init_ciphertext
(
encr
,
plain
,
ct
);
gettimeofday
(
&
t1
,
NULL
);
dt
=
1000000
*
(
t1
.
tv_sec
-
t0
.
tv_sec
)
+
(
t1
.
tv_usec
-
t0
.
tv_usec
);
cout
<<
"[INFO] plaintext encryption time in seconds: "
<<
((
float
)
dt
)
/
1000000
<<
endl
;
prefix
=
""
;
if
(
suffix_exist
(
pathStorage
,
"/"
))
{
prefix
.
append
(
pathStorage
);
}
else
{
prefix
.
append
(
pathStorage
);
prefix
.
append
(
"/"
);
}
prefix
.
append
(
Prefix
);
prefix
.
append
(
".ct"
);
//cout << "[INFO] suffix .ct : " << prefix << endl;
save_ciphertext
(
ct
,
prefix
);
//~ plain = boost::lexical_cast<int64_t>(argv[2]);
//~ init_ciphertext(encr, plain, ct);
//~ save_ciphertext(ct, "ct2.ct");
delete_operator
(
encr
);
return
0
;
}
}
bigpiseal3.5.1/native/examples/generic/generic_evaluate.cpp
deleted
100644 → 0
View file @
d8df7d47
#include <sys/stat.h>
#include "add.h"
using
namespace
std
;
using
namespace
seal
;
inline
bool
exists_file
(
const
std
::
string
&
name
)
{
struct
stat
buffer
;
return
(
stat
(
name
.
c_str
(),
&
buffer
)
==
0
);
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
5
)
{
cout
<<
"[ERROR] please enter 3 ciphertext /path/to/ct1.ct /path/to/ct2.ct /path/to/result.ct full/path/to/publickey"
<<
endl
;
// ../generic_evaluate /path/to/ct1.ct /path/to/ct2.ct /path/to/result.ct /home/bigpi/path/to/pubKey
return
EXIT_FAILURE
;
}
else
{
struct
evaluator_t
eval
;
string
Ct1
=
argv
[
1
];
string
Ct2
=
argv
[
2
];
string
Ct3
=
argv
[
3
];
string
pathK1
=
argv
[
4
];
string
pathK
=
""
;
if
(
exists_file
(
Ct1
)
==
false
||
exists_file
(
Ct2
)
==
false
)
{
cout
<<
"[ERROR] please enter 2 first ciphertext input /path/to/ct1.ct /path/to/ct2.ct"
<<
endl
;
return
EXIT_FAILURE
;
}
/* if (suffix_exist(Ct3, "/") == false) {
cout << "[ERROR] please enter 3rd parameter /path/to/result/name.ct/you/wish" << endl;
return EXIT_FAILURE;
} */
if
(
suffix_exist
(
pathK1
,
"/"
))
{
pathK
=
pathK1
;
}
else
{
pathK
.
append
(
pathK1
);
pathK
.
append
(
"/"
);
}
init_operator
(
2048
,
256
,
eval
,
pathK
);
Ciphertext
ct1
,
ct2
,
ct3
;
string
prefix
(
""
);
load_ciphertext
(
eval
,
ct1
,
Ct1
);
load_ciphertext
(
eval
,
ct2
,
Ct2
);
add_ciphertext
(
eval
,
ct1
,
ct2
,
ct3
);
save_ciphertext
(
ct3
,
Ct3
);
delete_operator
(
eval
);
return
0
;
}
}
bigpiseal3.5.1/native/examples/generic/generic_evaluate_multiply.cpp
deleted
100644 → 0
View file @
d8df7d47
#include <sys/stat.h>
#include "multiply.h"
using
namespace
std
;
using
namespace
seal
;
inline
bool
exists_file
(
const
std
::
string
&
name
)
{
struct
stat
buffer
;
return
(
stat
(
name
.
c_str
(),
&
buffer
)
==
0
);
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
5
)
{
cout
<<
"ct1.ct x ct2.ct = ct3.ct"
<<
endl
;
cout
<<
"[ERROR] please enter 3 ciphertext /path/to/ct1.ct /path/to/ct2.ct /path/to/result.ct full/path/to/publickey"
<<
endl
;
// ../generic_evaluate /path/to/ct1.ct /path/to/ct2.ct /path/to/result.ct /home/bigpi/path/to/pubKey
return
EXIT_FAILURE
;
}
struct
evaluator_t
eval
;
string
Ct1
=
argv
[
1
];
string
Ct2
=
argv
[
2
];
string
Ct3
=
argv
[
3
];
string
pathK1
=
argv
[
4
];
string
pathK
=
""
;
if
(
exists_file
(
Ct1
)
==
false
||
exists_file
(
Ct2
)
==
false
)
{
cout
<<
"[ERROR] please enter 2 first ciphertext input /path/to/ct1.ct /path/to/ct2.ct"
<<
endl
;
return
EXIT_FAILURE
;
}
/* if (suffix_exist(Ct3, "/") == false) {
cout << "[ERROR] please enter 3rd parameter /path/to/result/name.ct/you/wish" << endl;
return EXIT_FAILURE;
} */
if
(
suffix_exist
(
pathK1
,
"/"
))
{
pathK
=
pathK1
;
}
else
{
pathK
.
append
(
pathK1
);
pathK
.
append
(
"/"
);
}
init_operator
(
2048
,
256
,
eval
,
pathK
);
Ciphertext
ct1
,
ct2
,
ct3
;
string
prefix
(
""
);
load_ciphertext
(
eval
,
ct1
,
Ct1
);
load_ciphertext
(
eval
,
ct2
,
Ct2
);
multiply_ciphertext
(
eval
,
ct1
,
ct2
,
ct3
);
save_ciphertext
(
ct3
,
Ct3
);
delete_operator
(
eval
);
return
0
;
}
bigpiseal3.5.1/native/examples/generic/generic_evaluate_sub.cpp
deleted
100644 → 0
View file @
d8df7d47
#include <sys/stat.h>
#include "sub.h"
using
namespace
std
;
using
namespace
seal
;
inline
bool
exists_file
(
const
std
::
string
&
name
)
{
struct
stat
buffer
;
return
(
stat
(
name
.
c_str
(),
&
buffer
)
==
0
);
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
!=
5
)
{
cout
<<
"ct1.ct - ct2.ct = ct3.ct"
<<
endl
;
cout
<<
"[ERROR] please enter 3 ciphertext /path/to/ct1.ct /path/to/ct2.ct /path/to/result.ct full/path/to/publickey"
<<
endl
;
// ../generic_evaluate /path/to/ct1.ct /path/to/ct2.ct /path/to/result.ct /home/bigpi/path/to/pubKey
return
EXIT_FAILURE
;
}
struct
evaluator_t
eval
;
string
Ct1
=
argv
[
1
];
string
Ct2
=
argv
[
2
];
string
Ct3
=
argv
[
3
];
string
pathK1
=
argv
[
4
];
string
pathK
=
""
;
if
(
exists_file
(
Ct1
)
==
false
||
exists_file
(
Ct2
)
==
false
)
{
cout
<<
"[ERROR] please enter 2 first ciphertext input /path/to/ct1.ct /path/to/ct2.ct"
<<
endl
;
return
EXIT_FAILURE
;
}
/* if (suffix_exist(Ct3, "/") == false) {
cout << "[ERROR] please enter 3rd parameter /path/to/result/name.ct/you/wish" << endl;
return EXIT_FAILURE;
} */
if
(
suffix_exist
(
pathK1
,
"/"
))
{
pathK
=
pathK1
;
}
else
{
pathK
.
append
(
pathK1
);
pathK
.
append
(
"/"
);
}
init_operator
(
2048
,
256
,
eval
,
pathK
);
Ciphertext
ct1
,
ct2
,
ct3
;
string
prefix
(
""
);
load_ciphertext
(
eval
,
ct1
,
Ct1
);
load_ciphertext
(
eval
,
ct2
,
Ct2
);
sub_ciphertext
(
eval
,
ct1
,
ct2
,
ct3
);
save_ciphertext
(
ct3
,
Ct3
);
delete_operator
(
eval
);
return
0
;
}
bigpiseal3.5.1/native/examples/generic/generic_genkey.cpp
deleted
100644 → 0
View file @
d8df7d47
#include <sys/time.h>
#include "seal_api.h"
using
namespace
std
;
using
namespace
seal
;
int
main
(
int
argc
,
char
**
argv
)
{
timeval
t0
,
t1
;
unsigned
long
dt
=
0
;
// gen keys § path to sk
string
pathSk
=
argv
[
1
];
gettimeofday
(
&
t0
,
NULL
);
generate_keys
(
8192
,
4294967296
,
pathSk
,
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
;
}
bigpiseal3.5.1/native/examples/generic/genkey_gen.sh
deleted
100644 → 0
View file @
d8df7d47
#!/bin/bash
#
# 2020 CEA LIST.
declare
-r
ERROR_NUMBER_PARAM
=
1
declare
-r
ERROR_KEY_NOT_FOUND
=
3
declare
-r
KEYGEN_NOT_PERFORMED
=
4
#/opt/seal/native/bin
# /opt/pki/seal/
# /opt/pki/seal/natives/examples/generic
CURR_DIR
=
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
&&
pwd
)
# params executable seal_generic_encrypt
# value
# path_to_key existing key pk encrypt
if
[
"$#"
-ne
1
]
;
then
echo
"You must enter exactly 1 command line arguments"
# display help if empty
echo
" path to sk , "
exit
$ERROR_NUMBER_PARAM
fi
path_to_key
=
$1
# encryption
echo
"key generation"
${
CURR_DIR
}
/generic_genkey
$path_to_key
# recuperate result
if
[
"
$?
"
==
"0"
]
;
then
echo
ok
done
else
echo
KEYGEN_NOT_PERFORMED
exit
4
fi
exit
Prev
1
…
4
5
6
7
8
9
10
11
12
…
14
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