第一次尝试使用茫然传输,在github上找到了相关代码,代码详见OTExtension,本文环境配置借鉴博客&雨后&的01 ABY框架的Ubuntu依赖包安装 感谢精彩的记录过程,让我少走不少弯路呀2333333333.
1、查看Ubuntu系统的版本号 2、更新系统的apt包列表 3、安装Git 3、安装gcc 4、安装g++ 5、安装cmake (version >= 3.12) 6、安装make 7、安装libgmp-dev 8、安装libssl-dev 9、安装libboost-all-dev
操作系统:Ubuntu 18.04
所需包:
g++(version>= 8)makelibgmp-devlibssl-devlibboost-all-dev (version >= 1.66)1、查看Ubuntu系统的版本号
查看系统的版本号可以帮助你在出现问题的时候,找到更加合适的解决方案:
$ cat /proc/version运行结果参考:
2、更新系统的apt包列表
通过运行以下命令确保您的系统和apt包列表完全更新:
sudo apt-get update第一个坑
Reading package lists... Done E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/cache/app-info -a -e /usr/bin/appstreamcli; then appstreamcli refresh > /dev/null; fi' E: Sub-process returned an error code在运行sudo apt-get update时出现如上信息,解决方法如下:
step1:
sudo pkill -KILL appstreamclistep2:
wget -P /tmp https://launchpad.net/ubuntu/+archive/primary/+files/appstream_0.9.4-1ubuntu1_amd64.deb https://launchpad.net/ubuntu/+archive/primary/+files/libappstream3_0.9.4-1ubuntu1_amd64.debstep3:
sudo dpkg -i /tmp/appstream_0.9.4-1ubuntu1_amd64.deb /tmp/libappstream3_0.9.4-1ubuntu1_amd64.deb执行完上述命令之后再次运行sudo apt-get update就不会再出现上面的错误。
3、安装Git
(1)安装
sudo apt-get install git(2)查看自己安装的git版本:
$ git --version4、安装gcc
(1)安装gcc:
sudo apt-get update
sudo apt-get install gcc
(2)查看安装gcc版本:
gcc --version 5、安装g++ (1)安装g++:
sudo apt-get update
sudo apt-get install g++
(2)查看安装g++版本:
g++ --version
【注:这里的版本是后来升级过的版本,Ubuntu18.04 apt包中对应的版本应该是7.3.0】
遇到的第2个坑: 问题1 :g++的版本与要求不符 【注:这里借用ABY环境下执行cmake的场景,该坑与OTExtension的坑相同】 解决方案1:安装g++ -8
(1)直接使用命令安装
sudo apt-get install gcc-8 sudo apt-get install g++-8(3)检查g++版本
g++ --version 问题2:g++版本升级后还是没有解决问题 解决方案2:删除原来的g++版本的软链接(卸载原来版本)
(1)进入/usr/bin目录下
ls /usr/bin/g++*(2)删除所有软链接,然后创建新的软链接指向g++ -8.
sudo rm g++ sudo ln -s /usr/bin/g++-8 g++此时使用命令g++ --version,显示版本如下 6、安装cmake
(1)确认是否安装好g++,gcc
(2)文件下载解压:
wget https://cmake.org/files/v3.12/cmake-3.12.2-Linux-x86_64.tar.gz或者直接从网站https://cmake.org/下载 (3)解压:
tar zxvf cmake-3.12.2-Linux-x86_64.tar.gz第3个坑: 如何为cmake添加环境变量 文件是提前编译好的,解压后有 bin、doc、man、share四个文件,没有bootstrap,目录结构如下:
cmake-3.21.2-Linux-x86_64 ├── bin │ ├── ccmake │ ├── cmake │ ├── cmake-gui │ ├── cpack │ └── ctest ├── doc │ └── cmake ├── man │ ├── man1 │ └── man7 └── share ├── aclocal ├── applications ├── cmake-3.9 ├── icons └── mime 12 directories, 5 files
(4)创建软链接
注: 文件路径是可以指定的, 一般选择在/opt或/usr 路径下, 这里选择/opt
mv cmake-3.12.2-Linux-x86_64 /opt/cmake-3.12.2 ln -sf /opt/cmake-3.12.2/bin/* /usr/bin/(5)查看版本
cmake --versionOK。现在cmake最新版本安装成功。 【这里之所以不用sudo apt install cmake安装cmake是因为该默认版本较低无法满足程序编译的需求】
7、安装make
sudo apt update sudo apt-get install ubuntu-make make --version8、安装libgmp-dev
sudo apt update sudo apt-get install libgmp-dev9、安装libssl-dev
sudo apt update sudo apt-get install libgmp-dev10、安装libboost-all-dev
第4个坑:安装boost的版本与要求不符 解决方案:
到boost官网安装一个boost库的压缩包 解压tar -xzvf boost_1_70_0.tar.gz 解压出来以后,进入解压出来的文件夹 执行命令sudo ./bootstrap.sh 再执行下面的命令sudo ./b2 install 这样头文件就被默认安装在/usr/local/include头文件下,库文件就被默认安装在/usr/local/lib下 成功解决!所有环境配置完成后,进入实例运行
COMPILING
Clone a copy of the OTExtension git repository: git clone https://github.com/encryptogroup/OTExtension.gitEnter the Framework directory: cd OTExtension/
Create and enter a build directory: mkdir build && cd build
Use CMake to create build files. Use
cmake .. The following options are available:
-DCMAKE_INSTALL_PREFIX=/path/to/installation -DOTEXTENSION_BUILD_EXE=Onto build executables (they are written tomains/in the build directory) In case ENCRYPTO_utilscannot be found on your system, it will automatically be compiled. If it is installed in a non-standard location, the path can be provided via -DCMAKE_PREFIX_PATH=/some/path.
Call make in the build directory to compile.To start OT extension, open two terminals on the same PC and call otmain -r 0 in one terminal to start OT extension as sender and call otmain -r 1 in the second terminal to start OT extension as receiver. This will invoke the passive secure IKNP 1-out-of-2 OT extension protocol for 1 million OTs on 8-bit strings. The result of the OT will be checked for correctness and the times (in ms) for the base-OTs, for the OT extensions, the number of bytes sent and the number of bytes received will be printed on the terminals. A list of all available options can be obtained via otmain -h. NOTES An example implementation of OT extension can be found in mains/otmain.cpp.
OT related source code is found in ot/.
Some compilation flags can be set in ot/OTconstants.h.