blib/lib/Crypt/Perl/ECDSA/EC/Curve.pm untested

filter: Statementstmt 0.0% 0 / 28 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 45 CC 2 SCAR 10.0
CC
2
Cov
0%
new
6.0
keylen
2.0
get_infinity
2.0
CRAP 2.7
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 use strict;
16 use warnings;
17  
18 use Crypt::Perl::ECDSA::EC::FieldElement ();
19 use Crypt::Perl::ECDSA::EC::Point ();
20 use Crypt::Perl::X ();
21  
22 #All bigints
23 sub new {
24 my ( $class, $q, $a, $b ) = @_;
25  
26 die Crypt::Perl::X::create('Generic', 'Need q, a, and b!') if grep { !defined } $q, $a, $b;
27  
28 my $self = {
29 q => $q,
30 a => $a,
31 b => $b,
32 infinity => Crypt::Perl::ECDSA::EC::Point->new_infinity(),
33 };
34  
35 return bless $self, $class;
36 }
37  
38 sub keylen {
39 my ($self) = @_;
40  
41 return $self->{'q'}->bit_length();
42 }
43  
44 sub get_infinity {
45 my ($self) = @_;
46 return $self->{'infinity'};
47 }
48  
49 #Returns ECFieldElement
50 sub decode_point {
51 my ($self, $x, $y) = @_;
52  
53 #if ( $self->as_hex() =~ m<\A0x0[467]> ) {
54 # die 'Only uncompressed generators!';
55 #}
56  
57 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 my ($self, $x ) = @_;
63  
64 return Crypt::Perl::ECDSA::EC::FieldElement->new( $self->{'q'}, $x );
65 }
66  
67 1;