witnet / elliptic-curve-solidity

Elliptic Curve arithmetic operations written in Solidity
MIT License
166 stars 40 forks source link

Fix errors from code review #15

Closed mariocao closed 4 years ago

mariocao commented 4 years ago

Code Review Result

Tool used: SmartCheck

Errors found

Summary:

·-----------------------------------------------·---------------·
|                Error Type                     |  Occurrences  |
·································································
| Costly loop                                   |           3   |
·································································
| Compiler version not fixed                    |           8   |
·································································
| Revert inside the if-operator                 |           3   |
·································································
| Pure-functions should not read/change state   |           3   |
·································································
| Prefer external to public visibility level    |          14   | 
·································································
| Use of assembly                               |           6   |
·································································
| Implicit visibility level                     |           8   |
·-----------------------------------------------·---------------·
| TOTAL                                         |          45   |
·-----------------------------------------------·---------------·

Costly loop

  1. File: contracts/FastEcMul.sol Lines: 428-428 Severity: 1 Pattern id: 17f23a

  2. File: contracts/FastEcMul.sol Lines: 30-34 Severity: 2 Pattern id: 38f6c7

  3. File: contracts/FastEcMul.sol Lines: 447-447 Severity: 1 Pattern id: 17f23a

Compiler version not fixed

  1. File: examples/Secp256k1.sol Lines: 1-1 Severity: 1

  2. Pattern id: 23fc32 File: test/TestEllipticCurve.sol Lines: 1-1 Severity: 1 Pattern id: 23fc32

  3. File: benchmark/Secp256k1GasHelper.sol Lines: 1-1 Severity: 1 Pattern id: 23fc32

  4. File: benchmark/EcGasHelper.sol Lines: 1-1 Severity: 1 Pattern id: 23fc32

  5. File: contracts/FastEcMul.sol Lines: 1-1 Severity: 1 Pattern id: 23fc32

  6. File: contracts/Migrations.sol Lines: 1-1 Severity: 1 Pattern id: 23fc32

  7. File: contracts/Migrations.sol Lines: 1-1 Severity: 1 Pattern id: 23fc32

  8. File: contracts/EllipticCurve.sol Lines: 1-1 Severity: 1 Pattern id: 23fc32

Revert inside the if-operator

All will be fixed in the code.

  1. File: contracts/EllipticCurve.sol Lines: 44-45 Severity: 1 Pattern id: c56b12

  2. File: contracts/EllipticCurve.sol Lines: 16-18 Severity: 1 Pattern id: c56b12

  3. File: contracts/EllipticCurve.sol Lines: 302-306 Severity: 1 Pattern id: c56b12

Pure-functions should not read/change state

  1. File: contracts/FastEcMul.sol Lines: 251-379 Severity: 1 Pattern id: 11314f

  2. File: contracts/FastEcMul.sol Lines: 218-242 Severity: 1 Pattern id: 11314f

  3. File: contracts/EllipticCurve.sol Lines: 39-60 Severity: 1 Pattern id: 11314f

Prefer external to public visibility level

  1. File: examples/Secp256k1.sol Lines: 22-30 Severity: 1 Pattern id: 73ufc1

  2. File: benchmark/Secp256k1GasHelper.sol Lines: 19-27 Severity: 1 Pattern id: 73ufc1

  3. File: benchmark/EcGasHelper.sol Lines: 131-145 Severity: 1 Pattern id: 73ufc1

  4. File: benchmark/EcGasHelper.sol Lines: 75-91 Severity: 1 Pattern id: 73ufc1

  5. File: benchmark/EcGasHelper.sol Lines: 30-32 Severity: 1 Pattern id: 73ufc1

  6. File: benchmark/EcGasHelper.sol Lines: 34-48 Severity: 1 Pattern id: 73ufc1

  7. File: benchmark/EcGasHelper.sol Lines: 127-129 Severity: 1 Pattern id: 73ufc1

  8. File: benchmark/EcGasHelper.sol Lines: 66-73 Severity: 1 Pattern id: 73ufc1

  9. File: benchmark/EcGasHelper.sol Lines: 50-64 Severity: 1 Pattern id: 73ufc1

  10. File: benchmark/EcGasHelper.sol Lines: 93-109 Severity: 1 Pattern id: 73ufc1

  11. File: benchmark/EcGasHelper.sol Lines: 111-125 Severity: 1 Pattern id: 73ufc1

  12. File: benchmark/EcGasHelper.sol Lines: 16-28 Severity: 1 Pattern id: 73ufc1

  13. File: contracts/Migrations.sol Lines: 20-23 Severity: 1 Pattern id: 73ufc1

  14. File: contracts/Migrations.sol Lines: 16-18 Severity: 1 Pattern id: 73ufc1

Use of assembly

  1. File: contracts/FastEcMul.sol Lines: 354-356 Severity: 1 Pattern id: 109cd5

  2. File: contracts/FastEcMul.sol Lines: 283-285 Severity: 1 Pattern id: 109cd5

  3. File: contracts/FastEcMul.sol Lines: 224-239 Severity: 1 Pattern id: 109cd5

  4. File: contracts/FastEcMul.sol Lines: 330-332 Severity: 1 Pattern id: 109cd5

  5. File: contracts/FastEcMul.sol Lines: 306-308 Severity: 1 Pattern id: 109cd5

  6. File: contracts/EllipticCurve.sol Lines: 49-57 Severity: 1 Pattern id: 109cd5

Implicit visibility level

  1. File: examples/Secp256k1.sol Lines: 14-14 Severity: 1 Pattern id: b51ce0

  2. File: examples/Secp256k1.sol Lines: 17-17 Severity: 1 Pattern id: b51ce0

  3. File: examples/Secp256k1.sol Lines: 16-16 Severity: 1 Pattern id: b51ce0

  4. File: examples/Secp256k1.sol Lines: 15-15 Severity: 1 Pattern id: b51ce0

  5. File: examples/Secp256k1.sol Lines: 13-13 Severity: 1 Pattern id: b51ce0

  6. File: benchmark/Secp256k1GasHelper.sol Lines: 16-16 Severity: 1 Pattern id: b51ce0

  7. File: benchmark/Secp256k1GasHelper.sol Lines: 14-14 Severity: 1 Pattern id: b51ce0

  8. File: benchmark/Secp256k1GasHelper.sol Lines: 17-17 Severity: 1 Pattern id: b51ce0

  9. File: benchmark/Secp256k1GasHelper.sol Lines: 15-15 Severity: 1 Pattern id: b51ce0

  10. File: benchmark/Secp256k1GasHelper.sol Lines: 13-13 Severity: 1 Pattern id: b51ce0