prime192v2
extends Prime
in package
Curves over y^2 = x^3 + a*x + b
Table of Contents
Properties
- $a : object
- Cofficient for x^1
- $b : object
- Cofficient for x^0
- $doubles : array<string|int, object>
- Doubles
- $eight : object
- The number eight over the specified finite field
- $factory : PrimeFields
- Prime Field Integer factory
- $four : object
- The number four over the specified finite field
- $modulo : BigInteger
- The modulo
- $one : object
- The number one over the specified finite field
- $order : BigInteger
- The Order
- $p : object
- Base Point
- $three : object
- The number three over the specified finite field
- $two : object
- The number two over the specified finite field
- $naf : array<string|int, int>
- NAF Points
Methods
- __construct() : mixed
- addPoint() : array<string|int, FiniteField>
- Adds two points on the curve
- convertInteger() : object
- Converts a BigInteger to a FiniteField integer
- convertToAffine() : array<string|int, Integer>
- Returns the affine point
- convertToInternal() : array<string|int, Integer>
- Converts an affine point to a jacobian coordinate
- createRandomMultiplier() : FiniteField
- Creates a random scalar multiplier
- derivePoint() : array<string|int, mixed>
- Returns the X coordinate and the derived Y coordinate
- doublePoint() : array<string|int, FiniteField>
- Doubles a point on a curve
- getA() : Integer
- Returns the a coefficient
- getB() : Integer
- Returns the a coefficient
- getBasePoint() : array<string|int, mixed>
- Retrieve the base point as an array
- getLength() : int
- Returns the length, in bits, of the modulo
- getLengthInBytes() : int
- Returns the length, in bytes, of the modulo
- getModulo() : BigInteger
- Returns the modulo
- getOrder() : BigInteger
- Returns the Order
- multiplyAddPoints() : array<string|int, int>
- Multiply and Add Points
- multiplyPoint() : array<string|int, mixed>
- Multiply a point on the curve by a scalar
- negatePoint() : array<string|int, object>
- Negates a point
- randomInteger() : object
- Returns a random integer
- setBasePoint() : array<string|int, Integer>
- Set x and y coordinates for the base point
- setCoefficients() : mixed
- Set coefficients a and b
- setModulo() : mixed
- Sets the modulo
- setOrder() : mixed
- Sets the Order
- setReduction() : object
- Use a custom defined modular reduction function
- verifyPoint() : bool
- Tests whether or not the x / y values satisfy the equation
- doublePointHelper() : array<string|int, FiniteField>
- Returns the numerator and denominator of the slope
- jacobianAddPoint() : array<string|int, FiniteField>
- Adds two jacobian coordinates on the curve
- jacobianAddPointMixedX() : array<string|int, FiniteField>
- Adds one "fresh" jacobian form on the curve
- jacobianAddPointMixedXY() : array<string|int, FiniteField>
- Adds two "fresh" jacobian form on the curve
- jacobianDoublePoint() : array<string|int, FiniteField>
- Doubles a jacobian coordinate on the curve
- jacobianDoublePointMixed() : array<string|int, FiniteField>
- Doubles a "fresh" jacobian coordinate on the curve
- getJSFPoints() : array<string|int, int>
- Precomputes points in Joint Sparse Form
- getNAFPoints() : array<string|int, int>
- Precomputes NAF points
Properties
$a
Cofficient for x^1
protected
object
$a
$b
Cofficient for x^0
protected
object
$b
$doubles
Doubles
protected
array<string|int, object>
$doubles
$eight
The number eight over the specified finite field
protected
object
$eight
$factory
Prime Field Integer factory
protected
PrimeFields
$factory
$four
The number four over the specified finite field
protected
object
$four
$modulo
The modulo
protected
BigInteger
$modulo
$one
The number one over the specified finite field
protected
object
$one
$order
The Order
protected
BigInteger
$order
$p
Base Point
protected
object
$p
$three
The number three over the specified finite field
protected
object
$three
$two
The number two over the specified finite field
protected
object
$two
$naf
NAF Points
private
array<string|int, int>
$naf
Methods
__construct()
public
__construct() : mixed
addPoint()
Adds two points on the curve
public
addPoint(array<string|int, mixed> $p, array<string|int, mixed> $q) : array<string|int, FiniteField>
Parameters
- $p : array<string|int, mixed>
- $q : array<string|int, mixed>
Return values
array<string|int, FiniteField>convertInteger()
Converts a BigInteger to a FiniteField integer
public
convertInteger(BigInteger $x) : object
Parameters
- $x : BigInteger
Return values
objectconvertToAffine()
Returns the affine point
public
convertToAffine(array<string|int, mixed> $p) : array<string|int, Integer>
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)
Parameters
- $p : array<string|int, mixed>
Return values
array<string|int, Integer>convertToInternal()
Converts an affine point to a jacobian coordinate
public
convertToInternal(array<string|int, mixed> $p) : array<string|int, Integer>
Parameters
- $p : array<string|int, mixed>
Return values
array<string|int, Integer>createRandomMultiplier()
Creates a random scalar multiplier
public
createRandomMultiplier() : FiniteField
Return values
FiniteFieldderivePoint()
Returns the X coordinate and the derived Y coordinate
public
derivePoint(mixed $m) : array<string|int, mixed>
Parameters
- $m : mixed
Return values
array<string|int, mixed>doublePoint()
Doubles a point on a curve
public
doublePoint(array<string|int, mixed> $p) : array<string|int, FiniteField>
Parameters
- $p : array<string|int, mixed>
Return values
array<string|int, FiniteField>getA()
Returns the a coefficient
public
getA() : Integer
Return values
IntegergetB()
Returns the a coefficient
public
getB() : Integer
Return values
IntegergetBasePoint()
Retrieve the base point as an array
public
getBasePoint() : array<string|int, mixed>
Return values
array<string|int, mixed>getLength()
Returns the length, in bits, of the modulo
public
getLength() : int
Return values
intgetLengthInBytes()
Returns the length, in bytes, of the modulo
public
getLengthInBytes() : int
Return values
intgetModulo()
Returns the modulo
public
getModulo() : BigInteger
Return values
BigIntegergetOrder()
Returns the Order
public
getOrder() : BigInteger
Return values
BigIntegermultiplyAddPoints()
Multiply and Add Points
public
multiplyAddPoints(array<string|int, mixed> $points, array<string|int, mixed> $scalars) : array<string|int, int>
Adapted from https://git.io/vxPUH
Parameters
- $points : array<string|int, mixed>
- $scalars : array<string|int, mixed>
Return values
array<string|int, int>multiplyPoint()
Multiply a point on the curve by a scalar
public
multiplyPoint(array<string|int, mixed> $p, Integer $d) : array<string|int, mixed>
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
Parameters
- $p : array<string|int, mixed>
- $d : Integer
Return values
array<string|int, mixed>negatePoint()
Negates a point
public
negatePoint(array<string|int, mixed> $p) : array<string|int, object>
Parameters
- $p : array<string|int, mixed>
Return values
array<string|int, object>randomInteger()
Returns a random integer
public
randomInteger() : object
Return values
objectsetBasePoint()
Set x and y coordinates for the base point
public
setBasePoint(BigInteger|Integer $x, BigInteger|Integer $y) : array<string|int, Integer>
Parameters
- $x : BigInteger|Integer
- $y : BigInteger|Integer
Return values
array<string|int, Integer>setCoefficients()
Set coefficients a and b
public
setCoefficients(BigInteger $a, BigInteger $b) : mixed
Parameters
- $a : BigInteger
- $b : BigInteger
setModulo()
Sets the modulo
public
setModulo(BigInteger $modulo) : mixed
Parameters
- $modulo : BigInteger
setOrder()
Sets the Order
public
setOrder(BigInteger $order) : mixed
Parameters
- $order : BigInteger
setReduction()
Use a custom defined modular reduction function
public
setReduction(callable $func) : object
Parameters
- $func : callable
Return values
objectverifyPoint()
Tests whether or not the x / y values satisfy the equation
public
verifyPoint(array<string|int, mixed> $p) : bool
Parameters
- $p : array<string|int, mixed>
Return values
booldoublePointHelper()
Returns the numerator and denominator of the slope
protected
doublePointHelper(array<string|int, mixed> $p) : array<string|int, FiniteField>
Parameters
- $p : array<string|int, mixed>
Return values
array<string|int, FiniteField>jacobianAddPoint()
Adds two jacobian coordinates on the curve
protected
jacobianAddPoint(array<string|int, mixed> $p, array<string|int, mixed> $q) : array<string|int, FiniteField>
Parameters
- $p : array<string|int, mixed>
- $q : array<string|int, mixed>
Return values
array<string|int, FiniteField>jacobianAddPointMixedX()
Adds one "fresh" jacobian form on the curve
protected
jacobianAddPointMixedX(array<string|int, mixed> $p, array<string|int, mixed> $q) : array<string|int, FiniteField>
The second parameter should be the "fresh" one
Parameters
- $p : array<string|int, mixed>
- $q : array<string|int, mixed>
Return values
array<string|int, FiniteField>jacobianAddPointMixedXY()
Adds two "fresh" jacobian form on the curve
protected
jacobianAddPointMixedXY(array<string|int, mixed> $p, array<string|int, mixed> $q) : array<string|int, FiniteField>
Parameters
- $p : array<string|int, mixed>
- $q : array<string|int, mixed>
Return values
array<string|int, FiniteField>jacobianDoublePoint()
Doubles a jacobian coordinate on the curve
protected
jacobianDoublePoint(array<string|int, mixed> $p) : array<string|int, FiniteField>
Parameters
- $p : array<string|int, mixed>
Return values
array<string|int, FiniteField>jacobianDoublePointMixed()
Doubles a "fresh" jacobian coordinate on the curve
protected
jacobianDoublePointMixed(array<string|int, mixed> $p) : array<string|int, FiniteField>
Parameters
- $p : array<string|int, mixed>
Return values
array<string|int, FiniteField>getJSFPoints()
Precomputes points in Joint Sparse Form
private
static getJSFPoints(Integer $k1, Integer $k2) : array<string|int, int>
Adapted from https://git.io/vxrpD
Parameters
Return values
array<string|int, int>getNAFPoints()
Precomputes NAF points
private
getNAFPoints(mixed $point, mixed $wnd) : array<string|int, int>
Adapted from https://git.io/vxY1f
Parameters
- $point : mixed
- $wnd : mixed