Skip to main content
Version: v1.3_alpha

CurveBabyJubJub

A

uint256 A

D

uint256 D

Q

uint256 Q

pointAdd

function pointAdd(uint256 _x1, uint256 _y1, uint256 _x2, uint256 _y2) internal view returns (uint256 x3, uint256 y3)

Add 2 points on baby jubjub curve Formula for adding 2 points on a twisted Edwards curve: x3 = (x1y2 + y1x2) / (1 + dx1x2y1y2) y3 = (y1y2 - ax1x2) / (1 - dx1x2y1y2)

pointDouble

function pointDouble(uint256 _x1, uint256 _y1) internal view returns (uint256 x2, uint256 y2)

Double a point on baby jubjub curve Doubling can be performed with the same formula as addition

pointMul

function pointMul(uint256 _x1, uint256 _y1, uint256 _d) internal view returns (uint256 x2, uint256 y2)

Multiply a point on baby jubjub curve by a scalar Use the double and add algorithm

isOnCurve

function isOnCurve(uint256 _x, uint256 _y) internal pure returns (bool)

Check if a given point is on the curve (168700x^2 + y^2) - (1 + 168696x^2y^2) == 0

submod

function submod(uint256 _a, uint256 _b, uint256 _mod) internal pure returns (uint256)

Perform modular subtraction

inverse

function inverse(uint256 _a) internal view returns (uint256)

Compute modular inverse of a number

expmod

function expmod(uint256 _b, uint256 _e, uint256 _m) internal view returns (uint256 o)

Helper function to call the bigModExp precompile