Fix comparison while creating signatures #11
Merged
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.
Issue
When performing the string based comparison for two hexadecimal values (in this case while forming the signature for a requested sequence with data committee member private key), the logic does not consider the fact that the
Bytes2Hex
function returns output in lowercase char. for the hexadecimal string.While performing comparison with
7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0
using the lower case string it gives wrong results for most of the cases. This is because the ASCII values of upper case and lower case char. are different, which is what is considered while performing the string based comparison.Example
LHS (hash):
7a9d59c0b984259000bfbb7787965552e85f6b84f8a85461fc8fc050cc47ab41
RHS:
7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0
This leads to creating unacceptable signatures (creating wrong
s
component withinv,r,s
signature) which doesn't get verified by the "data committee" smart contract (when invoked bysupernets2
smart contract).Following is the error thrown by
supernets2-sequence-sender
service, right after collecting signatures from data committee service, while estimating the gas before performing tx. on L1Solution
There are two possible solutions
Bytes2Hex
before comparing the string.We have applied the first solution while was the one going for.