# FHOPEexperiment **Repository Path**: haiweizone/FHOPEexperiment ## Basic Information - **Project Name**: FHOPEexperiment - **Description**: FHOPE算法的实验代码 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2016-09-26 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # FHOPEexperiment项目文档 > 该文档使用markdown编写,其中的Latex公式在某些编辑器中无法显示。请使用以下链接查看 > https://www.zybuluo.com/iWorkHere/note/578477 ## Polynomial类 这个类中完成了对FHOPE算法同态加和同态乘的性能测试,具体做法是定义两个函数`addition(double ciper[], int numOfShares, int itemsNum)`,和`multiplication(double ciper[], int numOfShares, int exponent)`。 **1. 对加法的测试:** 采用$\sum_{i=1}^Nc$,$c$是明文$v$经过算法加密后的密文,对这个密文进行累加计算,$N$从1000到10000进行分别测试。 **2. 对乘法的测试:** 采用指数函数$c^N$,对密文$c$进行$N$次乘法运算。 ## 具体函数 1. `double[] addition(double ciper[], int numOfShares, int itemsNum)` ```java * @param ciper 操作数 * @param numOfShares 密文分片的个数 * @param itemsNum 累加的次数 * @return 返回对ciperA累加itemsNum次的结果,该结果是一个密文。 ``` 2. `double[] multiplication(double ciper[], int numOfShares, int exponent)` ```java * @param ciper 操作数 * @param numOfShares 密文分片的个数 * @param exponent 指数的次,也是乘法运算的次数 * @return 返回对ciper累乘的结果。 ``` 同态乘法的计算过程: $$ 明文x的密文是c_x = (x_1,x_2,x_3, \dots, x_n),明文y的密文是c_y = (y_1,y_2,y_3, \dots, y_n) $$ $$ x \times y = Dec(c_x \times c_y) = Dec \begin{pmatrix} & Dec(x_1 \times y_1, x_1 \times y_2 , \dots, x_1 \times y_n)), & \\ & Dec(x_2 \times y_1, x_2 \times y_2 , \dots, x_2 \times y_n)), & \\ & \vdots & \\ & Dec(x_n \times y_1, x_n \times y_2 , \dots, x_n \times y_n)) & \end{pmatrix} $$ 在实现过程中,我们可以使用一个二维数组,保存一些数据: $$ \begin{pmatrix} x_1 \times y_1,x_1 \times y_2, \dots , x_1 \times y_n \\ x_2 \times y_1,x_2 \times y_2, \dots , x_2 \times y_n \\ \vdots \\ x_n \times y_1,x_n \times y_2, \dots , x_n \times y_n \end{pmatrix} $$ 将二维数组的每一行看作一个密文分片,使用解密函数处理,之后得到一个$n \times 1$ 的中间结果,再一次使用解密函数对其解密。