intel / ipp-crypto

Apache License 2.0
314 stars 85 forks source link

The performance of ECC-related functions of v2021.6 is much worse than that of v2021.4 and openssl #49

Closed cyjseagull closed 2 months ago

cyjseagull commented 1 year ago

I am using ipp-crypto and openssl to implement elliptic curve related ecpoint-multiply, hashToCurve operation.

I found that the performance of ipp-crypto is worse than openssl, the results are as follows(ipp-crypto of v2021.6):

./crypto_bench ecc 10000
----------- Ed25519EccCrypto perf start -----------
TPS of Ed25519EccCrypto: generateRandomScalar: 40322.6, timecost:248 ms
TPS of Ed25519EccCrypto: hashToCurve: 43290, timecost:231 ms
TPS of Ed25519EccCrypto: ecMultiply: 9643.2, timecost:1037 ms
TPS of Ed25519EccCrypto: scalarInvert: 26455, timecost:378 ms
TPS of Ed25519EccCrypto: mulGenerator: 57142.9, timecost:175 ms
----------- Ed25519EccCrypto perf end -----------

----------- OpenSSLEccCrypto-SM2 perf start -----------
TPS of OpenSSLEccCrypto-SM2: generateRandomScalar: 370370, timecost:27 ms
TPS of OpenSSLEccCrypto-SM2: hashToCurve: 32573.3, timecost:307 ms
TPS of OpenSSLEccCrypto-SM2: ecMultiply: 14705.9, timecost:680 ms
TPS of OpenSSLEccCrypto-SM2: scalarInvert: 74074.1, timecost:135 ms
TPS of OpenSSLEccCrypto-SM2: mulGenerator: 50505.1, timecost:198 ms
----------- OpenSSLEccCrypto-SM2 perf end -----------

----------- OpenSSLEccCrypto-P256 perf start -----------
TPS of OpenSSLEccCrypto-P256: generateRandomScalar: 370370, timecost:27 ms
TPS of OpenSSLEccCrypto-P256: hashToCurve: 34246.6, timecost:292 ms
TPS of OpenSSLEccCrypto-P256: ecMultiply: 12135.9, timecost:824 ms
TPS of OpenSSLEccCrypto-P256: scalarInvert: 42918.5, timecost:233 ms
TPS of OpenSSLEccCrypto-P256: mulGenerator: 57471.3, timecost:174 ms
----------- OpenSSLEccCrypto-P256 perf end -----------

----------- OpenSSLEccCrypto-SECP256K1 perf start -----------
TPS of OpenSSLEccCrypto-SECP256K1: generateRandomScalar: 370370, timecost:27 ms
TPS of OpenSSLEccCrypto-SECP256K1: hashToCurve: 36101.1, timecost:277 ms
TPS of OpenSSLEccCrypto-SECP256K1: ecMultiply: 2355.16, timecost:4246 ms
TPS of OpenSSLEccCrypto-SECP256K1: scalarInvert: 73529.4, timecost:136 ms
TPS of OpenSSLEccCrypto-SECP256K1: mulGenerator: 2272.73, timecost:4400 ms
----------- OpenSSLEccCrypto-SECP256K1 perf end -----------

----------- IppEccCrypto-P256 perf start -----------
TPS of IppEccCrypto-P256: generateRandomScalar: 1.66667e+06, timecost:6 ms
TPS of IppEccCrypto-P256: hashToCurve: 6035, timecost:1657 ms
TPS of IppEccCrypto-P256: ecMultiply: 6666.67, timecost:1500 ms
TPS of IppEccCrypto-P256: scalarInvert: 117647, timecost:85 ms
TPS of IppEccCrypto-P256: mulGenerator: inf, timecost:0 ms
----------- IppEccCrypto-P256 perf end -----------

----------- IppEccCrypto-SM2 perf start -----------
TPS of IppEccCrypto-SM2: generateRandomScalar: 2e+06, timecost:5 ms
TPS of IppEccCrypto-SM2: hashToCurve: 3742.51, timecost:2672 ms
TPS of IppEccCrypto-SM2: ecMultiply: 6609.39, timecost:1513 ms
TPS of IppEccCrypto-SM2: scalarInvert: 129870, timecost:77 ms
TPS of IppEccCrypto-SM2: mulGenerator: inf, timecost:0 ms
----------- IppEccCrypto-SM2 perf end -----------

And the v2021.4 has higher performance than v2021.6, here is the result of v2021.4:

----------- Ed25519EccCrypto perf start -----------
TPS of Ed25519EccCrypto: generateRandomScalar: 39370.1, timecost:254 ms
TPS of Ed25519EccCrypto: hashToCurve: 42016.8, timecost:238 ms
TPS of Ed25519EccCrypto: ecMultiply: 9487.67, timecost:1054 ms
TPS of Ed25519EccCrypto: scalarInvert: 17793.6, timecost:562 ms
TPS of Ed25519EccCrypto: mulGenerator: 48309.2, timecost:207 ms
----------- Ed25519EccCrypto perf end -----------

----------- OpenSSLEccCrypto-SM2 perf start -----------
TPS of OpenSSLEccCrypto-SM2: generateRandomScalar: 277778, timecost:36 ms
TPS of OpenSSLEccCrypto-SM2: hashToCurve: 21367.5, timecost:468 ms
TPS of OpenSSLEccCrypto-SM2: ecMultiply: 11261.3, timecost:888 ms
TPS of OpenSSLEccCrypto-SM2: scalarInvert: 57803.5, timecost:173 ms
TPS of OpenSSLEccCrypto-SM2: mulGenerator: 40000, timecost:250 ms
----------- OpenSSLEccCrypto-SM2 perf end -----------

----------- OpenSSLEccCrypto-P256 perf start -----------
TPS of OpenSSLEccCrypto-P256: generateRandomScalar: 212766, timecost:47 ms
TPS of OpenSSLEccCrypto-P256: hashToCurve: 21008.4, timecost:476 ms
TPS of OpenSSLEccCrypto-P256: ecMultiply: 8635.58, timecost:1158 ms
TPS of OpenSSLEccCrypto-P256: scalarInvert: 54054.1, timecost:185 ms
TPS of OpenSSLEccCrypto-P256: mulGenerator: 53763.4, timecost:186 ms
----------- OpenSSLEccCrypto-P256 perf end -----------

----------- OpenSSLEccCrypto-SECP256K1 perf start -----------
TPS of OpenSSLEccCrypto-SECP256K1: generateRandomScalar: 357143, timecost:28 ms
TPS of OpenSSLEccCrypto-SECP256K1: hashToCurve: 28011.2, timecost:357 ms
TPS of OpenSSLEccCrypto-SECP256K1: ecMultiply: 2036.25, timecost:4911 ms
TPS of OpenSSLEccCrypto-SECP256K1: scalarInvert: 75188, timecost:133 ms
TPS of OpenSSLEccCrypto-SECP256K1: mulGenerator: 2209.94, timecost:4525 ms
----------- OpenSSLEccCrypto-SECP256K1 perf end -----------

----------- IppEccCrypto-P256 perf start -----------
TPS of IppEccCrypto-P256: generateRandomScalar: 2e+06, timecost:5 ms
TPS of IppEccCrypto-P256: hashToCurve: 8568.98, timecost:1167 ms
TPS of IppEccCrypto-P256: ecMultiply: 9950.25, timecost:1005 ms
TPS of IppEccCrypto-P256: scalarInvert: 133333, timecost:75 ms
TPS of IppEccCrypto-P256: mulGenerator: inf, timecost:0 ms
----------- IppEccCrypto-P256 perf end -----------

----------- IppEccCrypto-SM2 perf start -----------
TPS of IppEccCrypto-SM2: generateRandomScalar: 2e+06, timecost:5 ms
TPS of IppEccCrypto-SM2: hashToCurve: 3984.06, timecost:2510 ms
TPS of IppEccCrypto-SM2: ecMultiply: 9671.18, timecost:1034 ms
TPS of IppEccCrypto-SM2: scalarInvert: 123457, timecost:81 ms
TPS of IppEccCrypto-SM2: mulGenerator: inf, timecost:0 ms
----------- IppEccCrypto-SM2 perf end -----------
opervush commented 11 months ago

Hi @cyjseagull, thank you for using IPP Crypto and sorry for the delayed response! Is this issue still actual for you? Do you still face this regression with the latest IPPCP release? If yes, could you please tell us what CPU you are measuring on?

paveldyakov commented 10 months ago

Hi @cyjseagull, could you please provide the information that @opervush asked? It will help us a lot! Without this info we cannot start investigation.

paveldyakov commented 2 months ago

Closing the issue because of no response Please feel free to re-open it