For details read Perl NOC. After June 25

brian m. carlson >
Math-EllipticCurve-Prime-0.001 >
Math::EllipticCurve::Prime::Point

Module Version: 0.001
Math::EllipticCurve::Prime::Point - points for elliptic curve operations over prime fields

version 0.001

use Math::EllipticCurve::Prime::Point;

my $p = Math::EllipticCurve::Prime::Point->new(curve => 'secp256r1', x => Math::BigInt->new('0x01ff'), y => Math::BigInt->new('0x03bc')); # not real points on the curve my $p2 = $p->double; print "(" . $p2->x . ", " . $p2->y . ")\n";

# Creates a point at infinity. my $p3 = Math::EllipticCurve::Prime::Point->new(curve => 'secp256r1');

# Creates a point from a hexadecimal SEC representation. my $p4 = Math::EllipticCurve::Prime::Point->from_hex("0401ff03bc"); $p4->curve(Math::EllipticCurve::Prime->new(name => 'secp256r1'));

This class represents a point on a given elliptic curve. Using the methods provided, arithmetic operations can be performed, including point addition and scalar multiplication. Currently the operations are limited to these, as these are the operations most commonly used in cryptography.

Create a new point. This constructor takes a hash as its sole argument. If the arguments x and y are both provided, assumes that these are instances of Math::BigInt. If x and y are not both provided, creates a new point at infinity.

This method takes a hexadecimal-encoded representation of a point in the SEC format and creates a new Math::EllipticCurve::Prime::Point object. Currently this only understands uncompressed points (first byte 0x04) and the point at infinity.

This method takes a representation of a point in the SEC format and creates a new Math::EllipticCurve::Prime::Point object. Calls from_hex under the hood.

This method produces a hexadecimal string representing a point in the uncompressed SEC format.

This method produces a byte string representing a point in the uncompressed SEC format.

Makes a copy of the current point.

A synonym for copy.

Multiplies this point by a scalar. The scalar should be a Math::BigInt. Like Math::BigInt, this modifies the present point. If you want to preserve this point, use the copy method to create a clone of the current point.

Requires that a curve has been set.

Adds this point to another point. Like Math::BigInt, this modifies the present point. If you want to preserve this point, use the copy method to create a clone of the current point.

Requires that a curve has been set.

Doubles the current point. Like Math::BigInt, this modifies the present point. If you want to preserve this point, use the copy method to create a clone of the current point.

Requires that a curve has been set.

Multiplies this point by a scalar. Returns a new point object.

Requires that a curve has been set.

Adds this point to another point. Returns a new point object.

Requires that a curve has been set.

Doubles this point. Returns a new point object.

Requires that a curve has been set.

Returns true if this point is the point at infinity, false otherwise.

Returns a Math::BigInt representing the x-coordinate of the point. Returns undef if this is the point at infinity. You should make a copy of the returned object; otherwise, you will modify the point.

Returns a Math::BigInt representing the y-coordinate of the point. Returns undef if this is the point at infinity. You should make a copy of the returned object; otherwise, you will modify the point.

Returns the Math::EllipticCurve::Prime curve associated with this point, if any. Optionally takes an argument to set the curve.

brian m. carlson <sandals@crustytoothpaste.net>

This software is copyright (c) 2012 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.

syntax highlighting: