ECDSA

Git Source

Library for handling Elliptic Curve Digital Signature Algorithm (ECDSA) operations on a compatible curve

Functions

zz2Aff

Convert from XYZZ coordinates to affine coordinates Learn more about the XYZZ representation here: https://hyperelliptic.org/EFD/g1p/auto-shortw-xyzz-3.html#addition-add-2008-s*

function zz2Aff(uint256 x, uint256 y, uint256 zz, uint256 zzz) internal returns (uint256 x1, uint256 y1);

Parameters

NameTypeDescription
xuint256The X-coordinate of the point in XYZZ representation
yuint256The Y-coordinate of the point in XYZZ representation
zzuint256The ZZ value of the point in XYZZ representation
zzzuint256The ZZZ value of the point in XYZZ representation

Returns

NameTypeDescription
x1uint256The X-coordinate of the point in affine representation
y1uint256The Y-coordinate of the point in affine representation

zzAddN

Adds a point in XYZZ coordinates to a point in affine coordinates

function zzAddN(
    uint256 x1,
    uint256 y1,
    uint256 zz1,
    uint256 zzz1,
    uint256 x2,
    uint256 y2
)
    internal
    pure
    returns (uint256 P0, uint256 P1, uint256 P2, uint256 P3);

Parameters

NameTypeDescription
x1uint256The X-coordinate of the first point
y1uint256The Y-coordinate of the first point
zz1uint256The ZZ value of the first point
zzz1uint256The ZZZ value of the first point
x2uint256The X-coordinate of the second point
y2uint256The Y-coordinate of the second point

Returns

NameTypeDescription
P0uint256The X-coordinate of the resulting point
P1uint256The Y-coordinate of the resulting point
P2uint256The ZZ value of the resulting point
P3uint256The ZZZ value of the resulting point

zzDouble

Performs point doubling operation in XYZZ coordinates on an elliptic curve

This implements the "dbl-2008-s-1" doubling formulas from Sutherland's 2008 paper

function zzDouble(
    uint256 x,
    uint256 y,
    uint256 zz,
    uint256 zzz
)
    internal
    pure
    returns (uint256 P0, uint256 P1, uint256 P2, uint256 P3);

Parameters

NameTypeDescription
xuint256The X-coordinate of the point
yuint256The Y-coordinate of the point
zzuint256The ZZ value of the point
zzzuint256The ZZZ value of the point

Returns

NameTypeDescription
P0uint256The X-coordinate of the resulting point after doubling
P1uint256The Y-coordinate of the resulting point after doubling
P2uint256The ZZ value of the resulting point after doubling
P3uint256The ZZZ value of the resulting point after doubling

affIsOnCurve

Check if a point in affine coordinates is on the curve

function affIsOnCurve(uint256 x, uint256 y) internal pure returns (bool);

Parameters

NameTypeDescription
xuint256The X-coordinate of the point
yuint256The Y-coordinate of the point

Returns

NameTypeDescription
<none>boolbool True if the point is on the curve, false otherwise

affAdd

Add two points on the elliptic curve in affine coordinates

function affAdd(uint256 x0, uint256 y0, uint256 x1, uint256 y1) internal returns (uint256 x2, uint256 y2);

Parameters

NameTypeDescription
x0uint256The X-coordinate of the first point
y0uint256The Y-coordinate of the first point
x1uint256The X-coordinate of the second point
y1uint256The Y-coordinate of the second point

Returns

NameTypeDescription
x2uint256The X-coordinate of the resulting point
y2uint256The Y-coordinate of the resulting point