同态加密库 HEAAN效率测试(3)

long logq = 1200; ///< Ciphertext Modulus
long logp = 30; ///< Real message will be quantized by multiplying 2^40
long logn = 3; ///< log2(The number of slots)  8个slot
long degree=5;
—
参考:https://github.com/snucrypto/HEAAN/issues/28#event-2561020130

测试函数: POWER OF 2、POWER 、INVERSE、Logarithm、EXPONENT、SIGMOID
(仅供个人参考)

!!! START TEST POWER OF 2 !!!
------------------
Start Power of 2
Power of 2 time = 29903.3 ms
------------------
---------------------
mpow2: 0 :(0.20162,0.979464)
dpow2: 0 :(0.20162,0.979464)
epow2: 0 :(1.83199e-08,-1.12564e-09)
---------------------
---------------------
mpow2: 1 :(0.39818,-0.917307)
dpow2: 1 :(0.39818,-0.917307)
epow2: 1 :(6.64167e-09,-3.2562e-08)
---------------------
---------------------
mpow2: 2 :(-0.41879,0.908083)
dpow2: 2 :(-0.41879,0.908083)
epow2: 2 :(1.45851e-08,1.39123e-09)
---------------------
---------------------
mpow2: 3 :(0.999421,0.0340386)
dpow2: 3 :(0.99942,0.0340385)
epow2: 3 :(2.1027e-08,1.09442e-08)
---------------------
---------------------
mpow2: 4 :(-0.871525,-0.490351)
dpow2: 4 :(-0.871525,-0.490351)
epow2: 4 :(-1.30287e-08,-2.86705e-08)
---------------------
---------------------
mpow2: 5 :(-0.293521,-0.955953)
dpow2: 5 :(-0.293521,-0.955953)
epow2: 5 :(-4.8545e-08,-3.85901e-10)
---------------------
---------------------
mpow2: 6 :(0.863814,0.50381)
dpow2: 6 :(0.863814,0.50381)
epow2: 6 :(-1.61899e-08,9.14006e-09)
---------------------
---------------------
mpow2: 7 :(-0.890984,-0.454035)
dpow2: 7 :(-0.890984,-0.454035)
epow2: 7 :(3.92436e-08,-2.97827e-08)
---------------------
!!! END TEST POWER OF 2 !!!
!!! START TEST POWER !!!
------------------
Start Power
Power time = 9829.79 ms
------------------
---------------------
mpow: 0 :(-0.742102,-0.670287)
dpow: 0 :(-0.742102,-0.670287)
epow: 0 :(1.13483e-08,-1.68938e-08)
---------------------
---------------------
mpow: 1 :(0.909259,-0.416231)
dpow: 1 :(0.909259,-0.416231)
epow: 1 :(-1.77325e-08,7.48444e-10)
---------------------
---------------------
mpow: 2 :(0.506365,0.862319)
dpow: 2 :(0.506365,0.862319)
epow: 2 :(-1.8085e-09,-1.01674e-08)
---------------------
---------------------
mpow: 3 :(-0.997199,-0.0747973)
dpow: 3 :(-0.997199,-0.0747973)
epow: 3 :(-3.47097e-09,-1.49076e-08)
---------------------
---------------------
mpow: 4 :(0.763133,-0.646241)
dpow: 4 :(0.763133,-0.646241)
epow: 4 :(-2.06813e-09,2.16905e-08)
---------------------
---------------------
mpow: 5 :(0.980991,0.194051)
dpow: 5 :(0.980991,0.194051)
epow: 5 :(-6.74576e-09,2.66091e-08)
---------------------
---------------------
mpow: 6 :(0.299009,-0.95425)
dpow: 6 :(0.299009,-0.95425)
epow: 6 :(1.61131e-08,-9.98294e-09)
---------------------
---------------------
mpow: 7 :(0.969113,-0.246619)
dpow: 7 :(0.969113,-0.246619)
epow: 7 :(-1.02026e-09,-1.8247e-08)
---------------------
!!! END TEST POWER !!!
-----------
steps: 5
!!! START TEST INVERSE !!!
-------
Start Inverse
Inverse time = 59877.3 ms
------------------
---------------------
minv: 0 :(0.979241,-0.202699)
dinv: 0 :(0.979241,-0.202699)
einv: 0 :(-2.03227e-07,1.67167e-07)
---------------------
---------------------
minv: 1 :(0.965417,-0.260712)
dinv: 1 :(0.965417,-0.260712)
einv: 1 :(2.29263e-08,-2.60538e-08)
---------------------
---------------------
minv: 2 :(0.93469,-0.355465)
dinv: 2 :(0.93469,-0.355465)
einv: 2 :(-1.74903e-08,-2.08526e-08)
---------------------
---------------------
minv: 3 :(0.999832,-0.0183071)
dinv: 3 :(0.999832,-0.0183071)
einv: 3 :(4.48239e-08,-1.88877e-08)
---------------------
---------------------
minv: 4 :(0.822808,-0.568319)
dinv: 4 :(0.822808,-0.568319)
einv: 4 :(-2.61805e-08,1.6703e-08)
---------------------
---------------------
minv: 5 :(0.98849,-0.151285)
dinv: 5 :(0.98849,-0.151285)
einv: 5 :(-1.65211e-08,3.91995e-09)
---------------------
---------------------
minv: 6 :(0.961106,-0.276181)
dinv: 6 :(0.961106,-0.276181)
einv: 6 :(3.0734e-08,5.90463e-08)
---------------------
---------------------
minv: 7 :(0.997173,-0.0751337)
dinv: 7 :(0.997173,-0.0751337)
einv: 7 :(-4.78926e-09,-1.80592e-10)
---------------------
!!! END TEST INVERSE !!


--------------
Start Logarithm
Logarithm time = 56631.1 ms
------------------
---------------------
mLogarithm: 0 :(0.0574996,0.0270101)
dLogarithm: 0 :(0.0574996,0.0270101)
eLogarithm: 0 :(1.86378e-08,2.3162e-09)
---------------------
---------------------
mLogarithm: 1 :(0.0139661,0.0649194)
dLogarithm: 1 :(0.0139661,0.0649194)
eLogarithm: 1 :(-8.48464e-09,-2.73877e-09)
---------------------
---------------------
mLogarithm: 2 :(0.0445223,0.00197206)
dLogarithm: 2 :(0.0445223,0.00197207)
eLogarithm: 2 :(-1.45658e-08,-1.21525e-08)
---------------------
---------------------
mLogarithm: 3 :(0.0269726,0.00418482)
dLogarithm: 3 :(0.0269726,0.00418485)
eLogarithm: 3 :(-1.64351e-08,-3.38108e-08)
---------------------
---------------------
mLogarithm: 4 :(0.0154415,0.0700624)
dLogarithm: 4 :(0.0154415,0.0700624)
eLogarithm: 4 :(-8.1622e-09,-1.11971e-09)
---------------------
---------------------
mLogarithm: 5 :(0.0756601,0.0111169)
dLogarithm: 5 :(0.07566,0.0111169)
eLogarithm: 5 :(2.13796e-08,7.00175e-09)
---------------------
---------------------
mLogarithm: 6 :(0.0492212,0.00884784)
dLogarithm: 6 :(0.0492212,0.00884783)
eLogarithm: 6 :(-7.51988e-09,8.43134e-09)
---------------------
---------------------
mLogarithm: 7 :(0.0497222,0.0341698)
dLogarithm: 7 :(0.0497222,0.0341698)
eLogarithm: 7 :(-4.35382e-09,-5.37321e-09)
---------------------
!!! END TEST LOGARITHM !!!

degree: 5
!!! START TEST EXPONENT !!!
------------------
Start Exponent
Exponent time = 31820.2 ms
------------------
---------------------
mExponent: 0 :(1.10915,1.66516)
dExponent: 0 :(1.10488,1.66693)
eExponent: 0 :(0.00427812,-0.00177505)
---------------------
---------------------
mExponent: 1 :(1.2955,1.74085)
dExponent: 1 :(1.29238,1.74461)
eExponent: 1 :(0.00311955,-0.00375929)
---------------------
---------------------
mExponent: 2 :(1.33503,0.0841747)
dExponent: 2 :(1.33503,0.0841737)
eExponent: 2 :(2.71781e-07,9.75161e-07)
---------------------
---------------------
mExponent: 3 :(1.45898,1.15379)
dExponent: 3 :(1.4587,1.15462)
eExponent: 3 :(0.000282005,-0.000829586)
---------------------
---------------------
mExponent: 4 :(1.03296,0.16245)
dExponent: 4 :(1.03296,0.16245)
eExponent: 4 :(5.06283e-10,8.46601e-09)
---------------------
---------------------
mExponent: 5 :(2.07407,0.272453)
dExponent: 5 :(2.07394,0.272212)
eExponent: 5 :(0.000131662,0.000241176)
---------------------
---------------------
mExponent: 6 :(1.68599,0.443237)
dExponent: 6 :(1.68606,0.443199)
eExponent: 6 :(-6.96002e-05,3.83132e-05)
---------------------
---------------------
mExponent: 7 :(1.17611,0.630072)
dExponent: 7 :(1.17606,0.630071)
eExponent: 7 :(4.96109e-05,1.57744e-06)
---------------------
!!! END TEST EXPONENT !!!

degree: 5
!!! START TEST SIGMOID !!!
n=8
------------------
Start Sigmoid
Sigmoid time = 36913.8 ms
------------------
---------------------
mSigmoid: 0 :(0.586526,0.21296)
dSigmoid: 0 :(0.58647,0.213027)
eSigmoid: 0 :(5.59257e-05,-6.76474e-05)
---------------------
---------------------
mSigmoid: 1 :(0.665076,0.230672)
dSigmoid: 1 :(0.665324,0.23098)
eSigmoid: 1 :(-0.000248032,-0.000308678)
---------------------
---------------------
mSigmoid: 2 :(0.705241,0.162487)
dSigmoid: 2 :(0.705392,0.162217)
eSigmoid: 2 :(-0.000150396,0.000270162)
---------------------
---------------------
mSigmoid: 3 :(0.68655,0.157503)
dSigmoid: 3 :(0.686662,0.157357)
eSigmoid: 3 :(-0.00011263,0.000145701)
---------------------
---------------------
mSigmoid: 4 :(0.586437,0.153491)
dSigmoid: 4 :(0.586441,0.153506)
eSigmoid: 4 :(-4.02639e-06,-1.54641e-05)
---------------------
---------------------
mSigmoid: 5 :(0.563851,0.0989948)
dSigmoid: 5 :(0.563852,0.0989955)
eSigmoid: 5 :(-7.25777e-07,-7.46817e-07)
---------------------
---------------------
mSigmoid: 6 :(0.595737,0.0265702)
dSigmoid: 6 :(0.595737,0.0265705)
eSigmoid: 6 :(1.28603e-07,-3.38946e-07)
---------------------
---------------------
mSigmoid: 7 :(0.722734,0.22352)
dSigmoid: 7 :(0.723683,0.223486)
eSigmoid: 7 :(-0.000949022,3.33461e-05)
---------------------
!!! END TEST SIGMOID !!!

你可能感兴趣的:(同态加密)