ECDSA256r1
A library to verify ECDSA signatures made on the secp256r1 curve
This is the easiest library to deal with but also the most expensive in terms of gas cost. Indeed, this library must calculate multiple points on the curve in order to verify the signature. Use it kmowingly.
Functions
isPointValid
Verifies that a point is on the secp256r1 curve
function isPointValid(uint256 x, uint256 y) internal pure returns (bool);
Parameters
Name | Type | Description |
---|---|---|
x | uint256 | The x-coordinate of the point |
y | uint256 | The y-coordinate of the point |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool True if the point is on the curve, false otherwise |
mulmuladd
and Q is the public key.
function mulmuladd(uint256 Q0, uint256 Q1, uint256 scalar_u, uint256 scalar_v) internal returns (uint256 X);
Parameters
Name | Type | Description |
---|---|---|
Q0 | uint256 | x-coordinate of the input point Q |
Q1 | uint256 | y-coordinate of the input point Q |
scalar_u | uint256 | Multiplier for basepoint G |
scalar_v | uint256 | Multiplier for input point Q |
Returns
Name | Type | Description |
---|---|---|
X | uint256 | Resulting x-coordinate of the computed point |
verify
Verifies an ECDSA signature on the secp256r1 curve given the message, signature, and public key. This function is the only one exposed by the library
Note the required interactions with the precompled contract can revert the transaction
function verify(bytes32 message, uint256 r, uint256 s, uint256 qx, uint256 qy) internal returns (bool);
Parameters
Name | Type | Description |
---|---|---|
message | bytes32 | The original message that was signed |
r | uint256 | uint256 The r value of the ECDSA signature. |
s | uint256 | uint256 The s value of the ECDSA signature. |
qx | uint256 | The x value of the public key used for the signature |
qy | uint256 | The y value of the public key used for the signature |
Returns
Name | Type | Description |
---|---|---|
<none> | bool | bool True if the signature is valid, false otherwise |