This is a supporting document for the paper STR: Secure Computation on additive shares using the share-transform-reveal strategy.
STR: Secure computation on additive shares using the share-transform-reveal strategy
By Zhihua Xia, Qi Gu, Wenhao Zhou, Lizhi Xiong, Jian Weng, Neal N. Xiong
This paper is accepted by IEEE Transactions on computers now (doi: 10.1109/TC.2021.3073171). Thanks to the editors and reviewers for their time
If you have any suggestions or problems with the code or this document, please contact me by email: 634337549@qq.com
We provide the demo codes for all the protocols shown in the paper. For convenience and readability, the demo only uses the (2,2)-threshold assumption, and the interaction operations are not simulated. We try to use the same symbols like that in the paper.
Please download this md file and open it with some better md readers (e.g., typora) to support LATEX.
The codes use the library spfpm to control the decimal length. Thus, please install it before executing the codes. We have written the test code for each protocol, and you can execute them at will.
If you want to use the protocols in a specific task, please note that we here just provide the demo rather than a library. We believe you should do the following to use the codes in a specific task:
-
ensure all the nonlinear steps in the task (for instance, ReLU layer)
-
rewrite these steps based on the demo and ensure the parallelization is used (always based on the matrix)
-
deploy code (combine each step) in multiple terminals and ensure synchronization
Besides, the user should ensure four parameters before the task: 1)
We evaluate the number of computations involved in each protocol. The communication consumptions have been described in the paper; thus, we skip it. We show consumption separately according to the protocol. Note that here
Protocols | offline phase | ||
---|---|---|---|
|
|
others | |
1 |
|||
1 |
|||
1 |
|||
1 |
|||
1 |
|||
1 |
|||
|
|||
1 |
|||
2 |
|||
1 |
|||
1 |
|||
3 |
|||
2 |
|||
|
Protocols | online phase | ||||
---|---|---|---|---|---|
|
|
|
|
others | |
- | |||||
|
|||||
|
|||||
|
|||||
|
|||||
|
|||||
|
|||||
- | |||||
|
|||||
- | |||||
|
|||||
|
|
|
|||
- | |||||
|
We test the following protocols with two kinds of input secret: 1.the exponent is uniformly generated in
We test each protocol's actual loss under the different settings; all values result from a million experiments. Compared with the real value, if the experimental error is more than
SecMul:
SecMul | (48, 24) | (56, 24) | (64, 24) | (64, 64) |
---|---|---|---|---|
errorCount1 | 0 | 0 | 0 | 0 |
meanError1 | 1.29E-09 | 1.30E-09 | 1.32E-09 | 1.30E-09 |
maxError1 | 9.45E-07 | 9.52E-07 | 9.52E-07 | 9.45E-07 |
errorCount2 | 0 | 0 | 0 | 0 |
meanError2 | 3.52E-15 | 6.55E-17 | 6.47E-17 | 6.46E-17 |
maxError2 | 8.52E-14 | 5.44E-15 | 7.01E-15 | 6.59E-15 |
Here, errorCount1 means that under the setting that the exponent is uniformly generated in
SecThreeMul:
SecThreeMul | (48, 24) | (56, 24) | (64, 24) | (64, 64) |
---|---|---|---|---|
errorCount1 | 1451 | 1422 | 1462 | 1390 |
meanError1 | 1.15E-05 | 1.06E-05 | 1.06E-05 | 1.00E-05 |
maxError1 | 0.16 | 0.1336 | 0.123 | 0.122 |
errorCount2 | 0 | 0 | 0 | 0 |
meanError2 | 1.51E-10 | 5.91E-13 | 2.32E-15 | 2.32E-15 |
maxError2 | 1.21E-09 | 4.75E-12 | 2.77E-14 | 3.71E-14 |
SecMulRes:
SecMulRes | (48, 24) | (56, 24) | (64, 24) | (64, 64) |
---|---|---|---|---|
errorCount1 | 18110 | 325 | 0 | 0 |
meanError1 | 5.19E-04 | 1.97E-06 | 7.59E-09 | 7.61E-09 |
maxError1 | 0.88 | 0.003 | 1.15E-05 | 1.43E-05 |
errorCount2 | 0 | 0 | 0 | 0 |
meanError2 | 3.08E-07 | 2.68E-08 | 2.62E-08 | 4.33E-12 |
maxError2 | 7.07E-05 | 8.62E-07 | 9.89E-07 | 1.07E-09 |
SecAddRes:
SecAddRes | (48, 24) | (56, 24) | (64, 24) | (64, 64) |
---|---|---|---|---|
errorCount1 | 83931 | 70595 | 67724 | 0 |
meanError1 | 8.10E-04 | 3.05E-04 | 2.88E-04 | 7.65E-09 |
maxError1 | 0.875 | 0.027 | 0.022 | 1.28E-05 |
errorCount2 | 0 | 0 | 0 | 0 |
meanError2 | 2.12E-07 | 6.74E-08 | 6.75E-08 | 2.37E-12 |
maxError2 | 7.14E-05 | 2.26E-06 | 2.98E-06 | 1.13E-09 |
SecExp:
SecExp | (48, 24) | (56, 24) | (64, 24) | (64, 64) |
---|---|---|---|---|
errorCount1 | 18026 | 277 | 0 | 0 |
meanError1 | 5.09E-04 | 1.92E-06 | 7.46E-09 | 7.49E-09 |
maxError1 | 0.89 | 0.003 | 1.20E-05 | 1.10E-05 |
errorCount2 | 0 | 0 | 0 | 0 |
meanError2 | 3.08E-07 | 2.67E-08 | 2.61E-08 | 4.42E-12 |
maxError2 | 8.56E-05 | 9.67E-07 | 9.77E-07 | 1.04E-09 |
SecLog:
SecLog | (48, 24) | (56, 24) | (64, 24) | (64, 64) |
---|---|---|---|---|
errorCount1 | 83976 | 71079 | 68034 | 0 |
meanError1 | 8.13E-04 | 3.08E-04 | 2.86E-04 | 7.79E-09 |
maxError1 | 0.852 | 0.026 | 0.027 | 1.38E-05 |
errorCount2 | 0 | 0 | 0 | 0 |
meanError2 | 2.13E-07 | 6.73E-08 | 6.75E-08 | 2.36E-12 |
maxError2 | 5.86E-05 | 2.14E-06 | 3.93E-06 | 1.25E-09 |
A special case of SecPow (
There are two main tricks to this problem:
-
use bigger fractional bit
-
execute two protocols in parallel, after getting the result, use
$\texttt{SecCmp}$ to judge that whether the difference of them is less than delta
Since the possibility of error is too low (always less than 1/10000), it is necessary to decide whether to use the second trick according to the actual task's risk. The error in the next protocols can all be coped with the above two tricks.
SecSqrt | (48, 24) | (56, 24) | (64, 24) | (64, 64) |
---|---|---|---|---|
errorCount1 | 26 | 0 | 0 | 0 |
meanError1 | - | 7.32E-07 | 6.74E-07 | 3.76E-11 |
maxError1 | - | 2.24E-05 | 2.24E-05 | 2.09E-08 |
errorCount2 | 0 | 0 | 0 | 0 |
meanError2 | 9.66E-08 | 2.50E-08 | 2.48E-08 | 1.09E-12 |
maxError2 | 1.41E-05 | 2.37E-07 | 2.28E-07 | 2.32E-10 |
SecSin:
SecSin | (48, 24) | (56, 24) | (64, 24) | (64, 64) |
---|---|---|---|---|
errorCount1 | 1 | 1 | 8 | 2 |
meanError1 | 4.03E-07 | 1.81E-08 | 1.81E-08 | 6.05E-12 |
maxError1 | 2.78E-05 | 1.17E-07 | 8.12E-08 | 3.77E-10 |
errorCount2 | 2 | 5 | 1 | 4 |
meanError2 | 4.18E-07 | 2.85E-08 | 2.92E-08 | 6.26E-12 |
maxError2 | 2.10E-05 | 1.25E-07 | 8.17E-08 | 3.37E-10 |
SecArctan:$[arctan\theta]_i\leftarrow[\theta]_i$
SecArctan | (48, 24) | (56, 24) | (64, 24) | (64, 64) |
---|---|---|---|---|
errorCount1 | 7901 | 2838 | 40 | 47 |
meanError1 | 0.023 | 0.009 | 1.25E-04 | 1.47E-04 |
maxError1 | π | π | π | π |
errorCount2 | 123 | 3 | 0 | 0 |
meanError2 | 9.64E-06 | 1.07E-06 | 7.57E-09 | 7.60E-09 |
maxError2 | 3.007 | 0.002 | 2.72E-05 | 1.90E-05 |
We test the following protocols with only the second kind of input. The protocols on matrices always use the setting of (64, 64); we test three different kinds of matrix size:
SecDiv:
SecDiv | (48, 24) | (56, 24) | (64, 24) | (64, 64) |
---|---|---|---|---|
errorCount | 3 | 0 | 0 | 0 |
meanError | 5.76E-07 | 2.24E-09 | 8.64E-12 | 8.63E-12 |
maxError | 0.001 | 1.02E-05 | 2.78E-08 | 3.61E-08 |
SecMatMul:
SecMatMul | 4*4 | 16*16 | 64*64 |
---|---|---|---|
errorCount | 0 | 0 | 0 |
meanError | 9.27E-16 | 2.84E-15 | 4.79E-14 |
maxError | 3.64E-14 | 5.17E-14 | 1.86E-13 |
SecMatInv:
SecMatInv | 4*4 | 16*16 | 64*64 |
---|---|---|---|
errorCount | 0 | 0 | 0 |
meanError | 9.07E-12 | 2.74E-11 | 1.07E-10 |
maxError | 2.08E-07 | 1.74E-07 | 2.76E-07 |
SecMatEigen: additive
SecMatEigen | 4*4 | 16*16 | 64*64 |
---|---|---|---|
errorCount | 1301 | 19 | 586 |
meanValueErr | 1.61E-03 | 2.98E-06 | 2.28E-05 |
maxValueErr | 2.2695 | 0.001 | 0.005 |
meanVectorErr | 1.29E-03 | 1.49E-07 | 4.08E-10 |
maxVectorErr | 1.898 | 2.32E-04 | 1.19E-07 |