一、简介
APSI——Asymmetric PSI:
私用集交集(PSI)是指这样一种功能,即双方都持有一组私用项,可以在不向对方透露任何其他信息的情况下检查他们有哪些共同项。集合大小的上限被假定为公共信息,不受保护。
APSI(不对称PSI)库基于eprint.iacr.org/2021/1116中描述的协议为不对称集合大小提供PSI功能。例如,在许多情况下,一方可能持有数百万条记录的大型数据集,而另一方希望了解数据集中是出现了单个特定记录还是出现了少量记录。我们称之为未标记模式下的APSI。
然而,在许多情况下,查询器还希望为每个匹配的记录检索一些信息。这可以被视为具有隐私保护批量查询功能的键值存储。我们使用术语项和标签来指代这样一个键值存储中的键和值,并在标记模式下调用此APSI。
注意:除非实际需要标记模式,否则使用未标记模式会更有效率(在通信和计算方面)。
二、安装教程
若是简单测试可以尝试使用vcpkg安装:
./vcpkg install apsi
开发者模式安装,确定安装需要的依赖:
Dependency | vcpkg name |
---|---|
Microsoft SEAL | seal[no-throw-tran] |
Microsoft Kuku | kuku |
Log4cplus | log4cplus |
cppzmq | cppzmq (needed only for ZeroMQ networking support) |
FlatBuffers | flatbuffers |
jsoncpp | jsoncpp |
Google Test | gtest (needed only for building tests) |
TCLAP | tclap (needed only for building CLI) |
接下来我们要逐个安装依赖,里面会出现需要手动调时的东西,加油!
1.seal 4.1 :
git clone https://github.com/microsoft/SEAL.git
git checkout https://github.com/microsoft/SEAL.git
cd SEAL
git checkout origin/4.1.0
cmake -S . -B build -DSEAL_THROW_ON_TRANSPARENT_CIPHERTEXT=OFF
cmake --build build
sudo cmake --install build
可以指定安装路径--prefix /Users/admin/git/SEAL-4.1.0/seal_4.1
2.kuku
git clone https://github.com/microsoft/Kuku.git
cd Kuku
cmake -S . -B build
cmake --build build
sudo cmake --install build
3.Log4cplus
git clone --recurse-submodules https://github.com/log4cplus/log4cplus
cd log4cplus
cmake -S . -B build
cmake --build build
sudo cmake --install build
4.cppzmq
git clone https://github.com/zeromq/cppzmq.git
cd cppzmq
pip install Zeromq
cmake -S . -B build
cmake --build build
sudo cmake --install build
5.FlatBuffers
git clone https://github.com/google/flatbuffers.git
cd flatbuffers
cmake -S . -B build
cmake --build build
sudo cmake --install build
6.jsoncpp
git clone https://github.com/open-source-parsers/jsoncpp.git
cd jsoncpp
cmake -S . -B build
cmake --build build
sudo cmake --install build
7.Google Test
git clone https://github.com/google/googletest.git
cd googletest
cmake -S . -B build -DCMAKE_CXX_COMPILER="c++" -DCMAKE_CXX_FLAGS="-std=c++14 -stdlib=libc++"
cmake --build build
sudo cmake --install build
8.TCLAP
下载:https://sourceforge.net/projects/tclap/
解压
cd tclap
cmake -S . -B build -DCMAKE_CXX_COMPILER="c++" -DCMAKE_CXX_FLAGS="-std=c++14 -stdlib=libc++"
cmake --build build
sudo cmake --install build
如果你可以走到这一步距离大功告成仅差最后一步啦~
上述过程中会出现很多bug,欢迎将问题和解决方案留在评论区
cmake适配
1.使用clion打开APSI:
git clone https://github.com/microsoft/APSI.git
2.打开CMakeList.txt
197行:option(APSI_BUILD_TESTS ${APSI_BUILD_TESTS_OPTION_STR} OFF) 改成
option(APSI_BUILD_TESTS ${APSI_BUILD_TESTS_OPTION_STR} ON)
若出现下面这个错误:
Linking CXX executable bin/unit_tests
Undefined symbols for architecture arm64:
"log4cplus::Logger::getInstance(std::__1::basic_string, std::__1::allocator> const&)", referenced from:
apsi::Log::Configure() in libapsi-0.11.a(log.cpp.o)
apsi::Log::SetLogLevel(apsi::Log::Level) in libapsi-0.11.a(log.cpp.o)
apsi::Log::DoLog(std::__1::basic_string, std::__1::allocator>, apsi::Log::Level) in libapsi-0.11.a(log.cpp.o)
"log4cplus::Logger::log(int, std::__1::basic_string, std::__1::allocator> const&, char const*, int, char const*) const", referenced from:
apsi::Log::DoLog(std::__1::basic_string, std::__1::allocator>, apsi::Log::Level) in libapsi-0.11.a(log.cpp.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
#在其中增加依赖位置:
include_directories(/usr/local/include)
link_directories(/usr/local/lib)
这时打开test/unit/src/unit_tests_runner.cpp 仍会出现编译失败的问题,
gtest-port.h:281:2: error: C++ versions less than C++14 are not supported.
#error C++ versions less than C++14 are not supported.
确定自己使用的是C++14 以上版本,删除cmake-build-debug,重新编译。