Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 point unicity in validity check #54

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ECDSA256r1.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/// @param y The y-coordinate of the point
/// @return bool True if the point is on the curve, false otherwise
function isPointValid(uint256 x, uint256 y) internal pure returns (bool) {
if (((0 == x) && (0 == y)) || x == p || y == p) {
if ((0 == x % p) && (0 == y % p)) {
return false;
}

Expand All @@ -42,14 +42,14 @@
/// @param scalar_u Multiplier for basepoint G
/// @param scalar_v Multiplier for input point Q
/// @return X Resulting x-coordinate of the computed point
function mulmuladd(uint256 Q0, uint256 Q1, uint256 scalar_u, uint256 scalar_v) internal returns (uint256 X) {

Check warning on line 45 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase

Check warning on line 45 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase

Check warning on line 45 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase

Check warning on line 45 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase

Check warning on line 45 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase

Check warning on line 45 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase

Check warning on line 45 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase

Check warning on line 45 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase

Check warning on line 45 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase

Check warning on line 45 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase
uint256 zz;
uint256 zzz;
uint256 Y;

Check warning on line 48 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase

Check warning on line 48 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase
uint256 index = 255;
uint256[6] memory T;

Check warning on line 50 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase

Check warning on line 50 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase
uint256 H0;

Check warning on line 51 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase

Check warning on line 51 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase
uint256 H1;

Check warning on line 52 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase

Check warning on line 52 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Variable name must be in mixedCase

unchecked {
if (scalar_u == 0 && scalar_v == 0) return 0;
Expand All @@ -57,7 +57,7 @@
// will not work if Q=P, obvious forbidden private key
(H0, H1) = ECDSA.affAdd(gx, gy, Q0, Q1);

assembly {

Check warning on line 60 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Avoid to use inline assembly. It is acceptable only in rare cases

Check warning on line 60 in src/ECDSA256r1.sol

View workflow job for this annotation

GitHub Actions / lint

Avoid to use inline assembly. It is acceptable only in rare cases
for { let T4 := add(shl(1, and(shr(index, scalar_v), 1)), and(shr(index, scalar_u), 1)) } eq(T4, 0) {
index := sub(index, 1)
T4 := add(shl(1, and(shr(index, scalar_v), 1)), and(shr(index, scalar_u), 1))
Expand Down
Loading