# NAME

Math::EllipticCurve::Prime - elliptic curve operations over prime fields

# VERSION

version 0.003

# SYNOPSIS

```
use Math::EllipticCurve::Prime;
my $curve = Math::EllipticCurve::Prime->from_name('secp256r1');
my $point = $curve->g; # Base point of the curve.
$point->bdbl; # In-place operation.
print "(" . $point->x . ", " . $point->y . ")\n";
```

# DESCRIPTION

This class represents an elliptic curve over a prime field. These curves are commonly used in cryptography. Consequently, a set of commonly-used curves (and aliases for those curves) is provided by name. The curve itself is generally not very interesting; Math::EllipticCurve::Prime::Point will see much more use in the typical scenario.

# METHODS

## new

Creates a new curve. This function takes a hash of parameters. The curve can either be specified by name (parameter name) using a common name for the curve, or the components can be specified individually.

The parameters are p, a prime; a and b, the constants which define the curve; g, the base point, which functions as a generator; n, the order of g; and h, the cofactor. The integers can either be specified as hexadecimal strings or Math::BigInt instances, and the base point can be specified either as an instance of Meth::EllipticCurve::Prime::Point or a string suitable for that class's from_hex function.

## from_name

Takes a single argument, the name of the curve.

## name

Returns the canonical name of this curve if it was created by name.

## p

Returns a Math::BigInt representing p, the prime.

## a

Returns a Math::BigInt representing a, the coefficient of x and one of the numbers which defines the curve.

## b

Returns a Math::BigInt representing b, the constant and one of the numbers which defines the curve.

## g

Returns a Math::EllipticCurve::Prime::Point object representing g, the base point and generator.

## n

Returns a Math::BigInt object representing n, the order of g.

## h

Returns a Math::BigInt object representing h, the cofactor.

# CAVEATS

This module will function just fine with the default Math::BigInt, but it will be unusably slow. If Math::BigInt::FastCalc is available, it will be just somewhat slow (679 seconds to run the testsuite). For reasonable performance, Math::BigInt::GMP (25 seconds) is strongly recommended.

# AUTHOR

brian m. carlson <sandals@crustytoothpaste.net>

# COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by brian m. carlson.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.