witnet / elliptic-curve-solidity Goto Github PK
View Code? Open in Web Editor NEWElliptic Curve arithmetic operations written in Solidity
License: MIT License
Elliptic Curve arithmetic operations written in Solidity
License: MIT License
• Elliptic-curve-solidity\contracts\FastEcMul.sol:457-459 - Review indentation and
tabs.
• Elliptic-curve-solidity\contracts\FastEcMul.sol:39-41 - ab[1] = int256(- t[0]);
instead of ab[1] = int256(0 - t[0]); ab[3] = - t[1]; instead of ab[3] = 0 - t[1];
• Elliptic-curve-solidity\examples\Secp256k1.sol:0-31 - Despite being a pure function,
if a contract called it, the caller's privateKey could be published. A warning should be
displayed in the comment that reflects it to avoid problems for a user who implements it /
inherits it wrong.
Hi, I'm writing an EIP of non-transferable contracts. I'm wondering could you add an example of receiving an address from a private key. I would include references to the organization and the repository in my EIP.
Hi,
Thanks for your work. This is very helpful. Currently solidity version goes up to 0.8.x. Could we update the solidity version requirement?
Finding discovered during Red4Sec security audit.
A bad implementation of the algorithm ecAdd was found. In this implementation, all cases and exceptions are not covered. This will produce undesired results, which can result in unhandled errors and/or denial of services in some circumstances.
During the audit, it has been observed that when making sums between two points in the ElipticCurve.sol library, the value of Y is not checked. Therefore, when the value of X1 and X2 is the same, the value of Y should be also verified, otherwise it could lead to an infinite point.
As we can see in the following examples taken from other known implementations (BouncyCastle, ANSSI-FR), the value of the Y is always checked in order to return an infinity point or not.
This issue aims to analyze (with the proper auditing tools) the potential vunerabilities that the library might have.
Tool used: SmartCheck
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 |
·-----------------------------------------------·---------------·
File: contracts/FastEcMul.sol
Lines: 428-428
Severity: 1
Pattern id: 17f23a
File: contracts/FastEcMul.sol
Lines: 30-34
Severity: 2
Pattern id: 38f6c7
File: contracts/FastEcMul.sol
Lines: 447-447
Severity: 1
Pattern id: 17f23a
File: examples/Secp256k1.sol
Lines: 1-1
Severity: 1
Pattern id: 23fc32
File: test/TestEllipticCurve.sol
Lines: 1-1
Severity: 1
Pattern id: 23fc32
File: benchmark/Secp256k1GasHelper.sol
Lines: 1-1
Severity: 1
Pattern id: 23fc32
File: benchmark/EcGasHelper.sol
Lines: 1-1
Severity: 1
Pattern id: 23fc32
File: contracts/FastEcMul.sol
Lines: 1-1
Severity: 1
Pattern id: 23fc32
File: contracts/Migrations.sol
Lines: 1-1
Severity: 1
Pattern id: 23fc32
File: contracts/Migrations.sol
Lines: 1-1
Severity: 1
Pattern id: 23fc32
File: contracts/EllipticCurve.sol
Lines: 1-1
Severity: 1
Pattern id: 23fc32
All will be fixed in the code.
File: contracts/EllipticCurve.sol
Lines: 44-45
Severity: 1
Pattern id: c56b12
File: contracts/EllipticCurve.sol
Lines: 16-18
Severity: 1
Pattern id: c56b12
File: contracts/EllipticCurve.sol
Lines: 302-306
Severity: 1
Pattern id: c56b12
File: contracts/FastEcMul.sol
Lines: 251-379
Severity: 1
Pattern id: 11314f
File: contracts/FastEcMul.sol
Lines: 218-242
Severity: 1
Pattern id: 11314f
File: contracts/EllipticCurve.sol
Lines: 39-60
Severity: 1
Pattern id: 11314f
File: examples/Secp256k1.sol
Lines: 22-30
Severity: 1
Pattern id: 73ufc1
File: benchmark/Secp256k1GasHelper.sol
Lines: 19-27
Severity: 1
Pattern id: 73ufc1
File: benchmark/EcGasHelper.sol
Lines: 131-145
Severity: 1
Pattern id: 73ufc1
File: benchmark/EcGasHelper.sol
Lines: 75-91
Severity: 1
Pattern id: 73ufc1
File: benchmark/EcGasHelper.sol
Lines: 30-32
Severity: 1
Pattern id: 73ufc1
File: benchmark/EcGasHelper.sol
Lines: 34-48
Severity: 1
Pattern id: 73ufc1
File: benchmark/EcGasHelper.sol
Lines: 127-129
Severity: 1
Pattern id: 73ufc1
File: benchmark/EcGasHelper.sol
Lines: 66-73
Severity: 1
Pattern id: 73ufc1
File: benchmark/EcGasHelper.sol
Lines: 50-64
Severity: 1
Pattern id: 73ufc1
File: benchmark/EcGasHelper.sol
Lines: 93-109
Severity: 1
Pattern id: 73ufc1
File: benchmark/EcGasHelper.sol
Lines: 111-125
Severity: 1
Pattern id: 73ufc1
File: benchmark/EcGasHelper.sol
Lines: 16-28
Severity: 1
Pattern id: 73ufc1
File: contracts/Migrations.sol
Lines: 20-23
Severity: 1
Pattern id: 73ufc1
File: contracts/Migrations.sol
Lines: 16-18
Severity: 1
Pattern id: 73ufc1
File: contracts/FastEcMul.sol
Lines: 354-356
Severity: 1
Pattern id: 109cd5
File: contracts/FastEcMul.sol
Lines: 283-285
Severity: 1
Pattern id: 109cd5
File: contracts/FastEcMul.sol
Lines: 224-239
Severity: 1
Pattern id: 109cd5
File: contracts/FastEcMul.sol
Lines: 330-332
Severity: 1
Pattern id: 109cd5
File: contracts/FastEcMul.sol
Lines: 306-308
Severity: 1
Pattern id: 109cd5
File: contracts/EllipticCurve.sol
Lines: 49-57
Severity: 1
Pattern id: 109cd5
File: examples/Secp256k1.sol
Lines: 14-14
Severity: 1
Pattern id: b51ce0
File: examples/Secp256k1.sol
Lines: 17-17
Severity: 1
Pattern id: b51ce0
File: examples/Secp256k1.sol
Lines: 16-16
Severity: 1
Pattern id: b51ce0
File: examples/Secp256k1.sol
Lines: 15-15
Severity: 1
Pattern id: b51ce0
File: examples/Secp256k1.sol
Lines: 13-13
Severity: 1
Pattern id: b51ce0
File: benchmark/Secp256k1GasHelper.sol
Lines: 16-16
Severity: 1
Pattern id: b51ce0
File: benchmark/Secp256k1GasHelper.sol
Lines: 14-14
Severity: 1
Pattern id: b51ce0
File: benchmark/Secp256k1GasHelper.sol
Lines: 17-17
Severity: 1
Pattern id: b51ce0
File: benchmark/Secp256k1GasHelper.sol
Lines: 15-15
Severity: 1
Pattern id: b51ce0
File: benchmark/Secp256k1GasHelper.sol
Lines: 13-13
Severity: 1
Pattern id: b51ce0
The goal is to perform simultaneous scalar multiplication in solidity in a generic manner, providing the needed constants through arguments
@mariocao commented on Mon Aug 12 2019
Integrate scalar decomposition support into the EllipticCurve
contract:
Hi!
Nice library to use, I really enjoy it, but could you update npm package with contracts, because there is still contract with >=0.5.3 <0.7.0
solidity version. It will be nice to use the most up to date lib
Thanks for your time!
The goal is to replicate the algorithm assessed and implemented in witnet/research#55 in solidity.
Red4Sec issue 16
Elliptic-curve-solidity\contracts\EllipticCurve.sol:299-301 - The logic specified in the comment does not match the implementation of the code.
Elliptic-curve-solidity\contracts\FastEcMul.sol:251-252 - variable _length not described in comments.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.