| 1 | package Crypt::Perl::ECDSA::EC::Curve; | ||||||||||
| 2 | |||||||||||
| 3 | =encoding utf-8 | ||||||||||
| 4 | |||||||||||
| 5 | =head1 NAME | ||||||||||
| 6 | |||||||||||
| 7 | Crypt::Perl::ECDSA::EC::Curve | ||||||||||
| 8 | |||||||||||
| 9 | =head1 DISCUSSION | ||||||||||
| 10 | |||||||||||
| 11 | This interface is undocumented for now. | ||||||||||
| 12 | |||||||||||
| 13 | =cut | ||||||||||
| 14 | |||||||||||
| 15 | 7 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 7 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | 7 | ▶ | use Crypt::Perl::ECDSA::EC::FieldElement (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 7 | ▶ | use Crypt::Perl::ECDSA::EC::Point (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 7 | ▶ | use Crypt::Perl::X (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | |||||||||||
| 22 | #All bigints | ||||||||||
| 23 | sub new { | ||||||||||
| 24 | 345 | ▶ | my ( $class, $q, $a, $b ) = @_; | ||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 25 | |||||||||||
| 26 | 345 | ▶ | die Crypt::Perl::X::create('Generic', 'Need q, a, and b!') if grep { !defined } $q, $a, $b; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 27 | |||||||||||
| 28 | 345 | my $self = { | |||||||||
| 29 | q => $q, | ||||||||||
| 30 | a => $a, | ||||||||||
| 31 | b => $b, | ||||||||||
| 32 | infinity => Crypt::Perl::ECDSA::EC::Point->new_infinity(), | ||||||||||
| 33 | }; | ||||||||||
| 34 | |||||||||||
| 35 | 345 | return bless $self, $class; | |||||||||
| 36 | } | ||||||||||
| 37 | |||||||||||
| 38 | sub keylen { | ||||||||||
| 39 | 346 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
keylen: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 40 | |||||||||||
| 41 | 346 | return $self->{'q'}->bit_length(); | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | sub get_infinity { | ||||||||||
| 45 | 0 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
get_infinity: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 46 | 0 | return $self->{'infinity'}; | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | #Returns ECFieldElement | ||||||||||
| 50 | sub decode_point { | ||||||||||
| 51 | 545 | ▶ | my ($self, $x, $y) = @_; | ||||||||
|
Subroutine
decode_point: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 52 | |||||||||||
| 53 | #if ( $self->as_hex() =~ m<\A0x0[467]> ) { | ||||||||||
| 54 | # die 'Only uncompressed generators!'; | ||||||||||
| 55 | #} | ||||||||||
| 56 | |||||||||||
| 57 | 545 | return Crypt::Perl::ECDSA::EC::Point->new( $self, $self->from_bigint( $x ), $self->from_bigint( $y ) ); | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | #$x is a bigint | ||||||||||
| 61 | sub from_bigint { | ||||||||||
| 62 | 549600 | ▶ | my ($self, $x ) = @_; | ||||||||
|
Subroutine
from_bigint: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 63 | |||||||||||
| 64 | 549600 | return Crypt::Perl::ECDSA::EC::FieldElement->new( $self->{'q'}, $x ); | |||||||||
| 65 | } | ||||||||||
| 66 | |||||||||||
| 67 | 7 | 1; | |||||||||