Prime
class Prime extends Base (View source)
Curves over y^2 = x^3 + a*x + b
Properties
protected object[] | $doubles | Doubles | from Base |
protected BigInteger | $order | The Order | |
protected PrimeFields | $factory | Prime Field Integer factory | |
protected object | $a | Cofficient for x^1 | |
protected object | $b | Cofficient for x^0 | |
protected object | $p | Base Point | |
protected object | $one | The number one over the specified finite field | |
protected object | $two | The number two over the specified finite field | |
protected object | $three | The number three over the specified finite field | |
protected object | $four | The number four over the specified finite field | |
protected object | $eight | The number eight over the specified finite field | |
protected BigInteger | $modulo | The modulo |
Methods
Returns the affine point
Converts an affine point to a jacobian coordinate
Multiply and Add Points
Set x and y coordinates for the base point
Retrieve the base point as an array
Adds two "fresh" jacobian form on the curve
Adds one "fresh" jacobian form on the curve
Adds two jacobian coordinates on the curve
Adds two points on the curve
Returns the numerator and denominator of the slope
Doubles a jacobian coordinate on the curve
Doubles a "fresh" jacobian coordinate on the curve
Doubles a point on a curve
Returns the X coordinate and the derived Y coordinate
Tests whether or not the x / y values satisfy the equation
Returns the modulo
Details
in
Base at line 63
object
randomInteger()
Returns a random integer
in
Base at line 73
object
convertInteger(BigInteger $x)
Converts a BigInteger to a FiniteField integer
in
Base at line 83
int
getLengthInBytes()
Returns the length, in bytes, of the modulo
in
Base at line 93
int
getLength()
Returns the length, in bits, of the modulo
in
Base at line 108
array
multiplyPoint(array $p, Integer $d)
Multiply a point on the curve by a scalar
Uses the montgomery ladder technique as described here:
https://en.wikipedia.org/wiki/Elliptic_curve_point_multiplication#Montgomery_ladder https://github.com/phpecc/phpecc/issues/16#issuecomment-59176772
in
Base at line 130
FiniteField
createRandomMultiplier()
Creates a random scalar multiplier
in
Base at line 144
setOrder(BigInteger $order)
Sets the Order
in
Base at line 154
BigInteger
getOrder()
Returns the Order
in
Base at line 164
object
setReduction(callable $func)
Use a custom defined modular reduction function
object[]
convertToAffine(array $p)
Returns the affine point
A Jacobian Coordinate is of the form (x, y, z). To convert a Jacobian Coordinate to an Affine Point you do (x / z^2, y / z^3)
object[]
convertToInternal(array $p)
Converts an affine point to a jacobian coordinate
in
Base at line 194
object[]
negatePoint(array $p)
Negates a point
int[]
multiplyAddPoints(array $points, array $scalars)
Multiply and Add Points
Adapted from https://git.io/vxPUH
setModulo(BigInteger $modulo)
Sets the modulo
setCoefficients(BigInteger $a, BigInteger $b)
Set coefficients a and b
PrimeInteger[]
setBasePoint(BigInteger|PrimeInteger $x, BigInteger|PrimeInteger $y)
Set x and y coordinates for the base point
array
getBasePoint()
Retrieve the base point as an array
protected FiniteField[]
jacobianAddPointMixedXY(array $p, array $q)
Adds two "fresh" jacobian form on the curve
protected FiniteField[]
jacobianAddPointMixedX(array $p, array $q)
Adds one "fresh" jacobian form on the curve
The second parameter should be the "fresh" one
protected FiniteField[]
jacobianAddPoint(array $p, array $q)
Adds two jacobian coordinates on the curve
FiniteField[]
addPoint(array $p, array $q)
Adds two points on the curve
protected FiniteField[]
doublePointHelper(array $p)
Returns the numerator and denominator of the slope
protected FiniteField[]
jacobianDoublePoint(array $p)
Doubles a jacobian coordinate on the curve
protected FiniteField[]
jacobianDoublePointMixed(array $p)
Doubles a "fresh" jacobian coordinate on the curve
FiniteField[]
doublePoint(array $p)
Doubles a point on a curve
array
derivePoint($m)
Returns the X coordinate and the derived Y coordinate
bool
verifyPoint(array $p)
Tests whether or not the x / y values satisfy the equation
BigInteger
getModulo()
Returns the modulo
Integer
getA()
Returns the a coefficient
Integer
getB()
Returns the a coefficient