class secp521r1 extends Prime (View source)

## Properties

 protected object[] \$doubles Doubles from  Base protected BigInteger \$order The Order from  Prime protected PrimeFields \$factory Prime Field Integer factory from  Prime protected object \$a Cofficient for x^1 from  Prime protected object \$b Cofficient for x^0 from  Prime protected object \$p Base Point from  Prime protected object \$one The number one over the specified finite field from  Prime protected object \$two The number two over the specified finite field from  Prime protected object \$three The number three over the specified finite field from  Prime protected object \$four The number four over the specified finite field from  Prime protected object \$eight The number eight over the specified finite field from  Prime protected BigInteger \$modulo The modulo from  Prime

## Methods

object
randomInteger()

Returns a random integer

from  Base
object
convertInteger(BigInteger \$x)

Converts a BigInteger to a FiniteField integer

from  Base
int
getLengthInBytes()

Returns the length, in bytes, of the modulo

from  Base
int
getLength()

Returns the length, in bits, of the modulo

from  Base
array
multiplyPoint(array \$p, Integer \$d)

Multiply a point on the curve by a scalar

from  Base
FiniteField
createRandomMultiplier()

Creates a random scalar multiplier

from  Base
setOrder(BigInteger \$order)

Sets the Order

from  Base
getOrder()

Returns the Order

from  Base
object
setReduction(callable \$func)

Use a custom defined modular reduction function

from  Base
object[]
convertToAffine(array \$p)

Returns the affine point

from  Prime
object[]
convertToInternal(array \$p)

Converts an affine point to a jacobian coordinate

from  Prime
object[]
negatePoint(array \$p)

Negates a point

from  Base
int[]
multiplyAddPoints(array \$points, array \$scalars)

Multiply and Add Points

from  Prime
setModulo(BigInteger \$modulo)

Sets the modulo

from  Prime
setCoefficients(BigInteger \$a, BigInteger \$b)

Set coefficients a and b

from  Prime
PrimeInteger[]
setBasePoint(BigInteger|PrimeInteger \$x, BigInteger|PrimeInteger \$y)

Set x and y coordinates for the base point

from  Prime
array
getBasePoint()

Retrieve the base point as an array

from  Prime
FiniteField[]
jacobianAddPointMixedXY(array \$p, array \$q)

Adds two "fresh" jacobian form on the curve

from  Prime
FiniteField[]
jacobianAddPointMixedX(array \$p, array \$q)

Adds one "fresh" jacobian form on the curve

from  Prime
FiniteField[]
jacobianAddPoint(array \$p, array \$q)

Adds two jacobian coordinates on the curve

from  Prime
FiniteField[]
addPoint(array \$p, array \$q)

Adds two points on the curve

from  Prime
FiniteField[]
doublePointHelper(array \$p)

Returns the numerator and denominator of the slope

from  Prime
FiniteField[]
jacobianDoublePoint(array \$p)

Doubles a jacobian coordinate on the curve

from  Prime
FiniteField[]
jacobianDoublePointMixed(array \$p)

Doubles a "fresh" jacobian coordinate on the curve

from  Prime
FiniteField[]
doublePoint(array \$p)

Doubles a point on a curve

from  Prime
array
derivePoint(\$m)

Returns the X coordinate and the derived Y coordinate

from  Prime
bool
verifyPoint(array \$p)

Tests whether or not the x / y values satisfy the equation

from  Prime
getModulo()

Returns the modulo

from  Prime
getA()

Returns the a coefficient

from  Prime
getB()

Returns the a coefficient

from  Prime
__construct()

No description

## Details

### in Base at line 63``` object randomInteger() ```

Returns a random integer

 object

### in Base at line 73``` object convertInteger(BigInteger \$x) ```

Converts a BigInteger to a FiniteField integer

#### Parameters

 BigInteger \$x

 object

### in Base at line 83``` int getLengthInBytes() ```

Returns the length, in bytes, of the modulo

 int

### in Base at line 93``` int getLength() ```

Returns the length, in bits, of the modulo

 int

### 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:

#### Parameters

 array \$p Integer \$d

 array

### in Base at line 130``` FiniteField createRandomMultiplier() ```

Creates a random scalar multiplier

#### Return Value

 FiniteField

### in Base at line 144``` setOrder(BigInteger \$order) ```

Sets the Order

#### Parameters

 BigInteger \$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

#### Parameters

 callable \$func

 object

### in Prime at line 745``` 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)

#### Parameters

 array \$p

#### Return Value

 object[]

### in Prime at line 764``` object[] convertToInternal(array \$p) ```

Converts an affine point to a jacobian coordinate

#### Parameters

 array \$p

#### Return Value

 object[]

### in Base at line 194``` object[] negatePoint(array \$p) ```

Negates a point

#### Parameters

 array \$p

#### Return Value

 object[]

### in Prime at line 512``` int[] multiplyAddPoints(array \$points, array \$scalars) ```

Multiply and Add Points

#### Parameters

 array \$points array \$scalars

 int[]

### in Prime at line 121``` setModulo(BigInteger \$modulo) ```

Sets the modulo

#### Parameters

 BigInteger \$modulo

### in Prime at line 136``` setCoefficients(BigInteger \$a, BigInteger \$b) ```

Set coefficients a and b

#### Parameters

 BigInteger \$a BigInteger \$b

### in Prime at line 152``` PrimeInteger[] setBasePoint(BigInteger|PrimeInteger \$x, BigInteger|PrimeInteger \$y) ```

Set x and y coordinates for the base point

#### Parameters

 BigInteger|PrimeInteger \$x BigInteger|PrimeInteger \$y

#### Return Value

 PrimeInteger[]

### in Prime at line 174``` array getBasePoint() ```

Retrieve the base point as an array

 array

### in Prime at line 192``` protected FiniteField[] jacobianAddPointMixedXY(array \$p, array \$q) ```

Adds two "fresh" jacobian form on the curve

#### Parameters

 array \$p array \$q

#### Return Value

 FiniteField[]

### in Prime at line 222``` protected FiniteField[] jacobianAddPointMixedX(array \$p, array \$q) ```

Adds one "fresh" jacobian form on the curve

The second parameter should be the "fresh" one

#### Parameters

 array \$p array \$q

#### Return Value

 FiniteField[]

### in Prime at line 256``` protected FiniteField[] jacobianAddPoint(array \$p, array \$q) ```

Adds two jacobian coordinates on the curve

#### Parameters

 array \$p array \$q

#### Return Value

 FiniteField[]

### in Prime at line 293``` FiniteField[] addPoint(array \$p, array \$q) ```

Adds two points on the curve

#### Parameters

 array \$p array \$q

#### Return Value

 FiniteField[]

### in Prime at line 349``` protected FiniteField[] doublePointHelper(array \$p) ```

Returns the numerator and denominator of the slope

#### Parameters

 array \$p

#### Return Value

 FiniteField[]

### in Prime at line 361``` protected FiniteField[] jacobianDoublePoint(array \$p) ```

Doubles a jacobian coordinate on the curve

#### Parameters

 array \$p

#### Return Value

 FiniteField[]

### in Prime at line 383``` protected FiniteField[] jacobianDoublePointMixed(array \$p) ```

Doubles a "fresh" jacobian coordinate on the curve

#### Parameters

 array \$p

#### Return Value

 FiniteField[]

### in Prime at line 403``` FiniteField[] doublePoint(array \$p) ```

Doubles a point on a curve

#### Parameters

 array \$p

#### Return Value

 FiniteField[]

### in Prime at line 436``` array derivePoint(\$m) ```

Returns the X coordinate and the derived Y coordinate

 \$m

 array

### in Prime at line 464``` bool verifyPoint(array \$p) ```

Tests whether or not the x / y values satisfy the equation

#### Parameters

 array \$p

 bool

### in Prime at line 480``` BigInteger getModulo() ```

Returns the modulo

### in Prime at line 490``` Integer getA() ```

Returns the a coefficient

### in Prime at line 500``` Integer getB() ```

Returns the a coefficient