Fix a bug of addition law of elliptic curve groups #81
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I notice that the origin addition law has a bug.
https://github.com/binance-chain/tss-lib/blob/883f207b38f0357d7a8c7fa957301c7a6f9b0848/crypto/ecpoint.go#L50
For example:
Let N be the order of an elliptic curve group and G is a generator of the elliptic curve group. Then
if you try to use "Add" to compute 2*G+(N-2)*G, then the output is an error.
This phenomenon will cause the following implementation which has possible failure.
https://github.com/binance-chain/tss-lib/blob/883f207b38f0357d7a8c7fa957301c7a6f9b0848/ecdsa/keygen/round_3.go#L135
If you meet the case 2*G+(N-2)*G, then culprits is not empty. However, the case 2G+ (N-2)G
should be handled.
Following your nice codes, we recommend that
Denote X()=nil and Y()=nil to be identity element in the elliptic curve group (i.e. aG+(nil, nil) = aG, for any a in [0,N-1]), which also implies that this point X()=nil and Y()=nil is on the curve. You can imaginary this point intercepting the elliptic curve at infinity.
Add function should handle some special cases. After this modification, this "Add" can
sum any two elements in elliptic curve groups including the following cases:
If you don't like my coding style, then you can rewrite it.
Well, some functions maybe also need to modify. For examples:
"FlattenECPoints", UnFlattenECPoints and so on.....
Thank you for your patience.