line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
7
|
|
42
|
use strict; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
176
|
|
16
|
7
|
|
|
7
|
|
29
|
use warnings; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
146
|
|
17
|
|
|
|
|
|
|
|
18
|
7
|
|
|
7
|
|
2560
|
use Crypt::Perl::ECDSA::EC::FieldElement (); |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
117
|
|
19
|
7
|
|
|
7
|
|
2770
|
use Crypt::Perl::ECDSA::EC::Point (); |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
161
|
|
20
|
7
|
|
|
7
|
|
42
|
use Crypt::Perl::X (); |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
1656
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#All bigints |
23
|
|
|
|
|
|
|
sub new { |
24
|
345
|
|
|
345
|
0
|
1723
|
my ( $class, $q, $a, $b ) = @_; |
25
|
|
|
|
|
|
|
|
26
|
345
|
50
|
|
|
|
1312
|
die Crypt::Perl::X::create('Generic', 'Need q, a, and b!') if grep { !defined } $q, $a, $b; |
|
1035
|
|
|
|
|
3123
|
|
27
|
|
|
|
|
|
|
|
28
|
345
|
|
|
|
|
6399
|
my $self = { |
29
|
|
|
|
|
|
|
q => $q, |
30
|
|
|
|
|
|
|
a => $a, |
31
|
|
|
|
|
|
|
b => $b, |
32
|
|
|
|
|
|
|
infinity => Crypt::Perl::ECDSA::EC::Point->new_infinity(), |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
|
35
|
345
|
|
|
|
|
2099
|
return bless $self, $class; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub keylen { |
39
|
346
|
|
|
346
|
0
|
1002
|
my ($self) = @_; |
40
|
|
|
|
|
|
|
|
41
|
346
|
|
|
|
|
2605
|
return $self->{'q'}->bit_length(); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub get_infinity { |
45
|
0
|
|
|
0
|
0
|
0
|
my ($self) = @_; |
46
|
0
|
|
|
|
|
0
|
return $self->{'infinity'}; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
#Returns ECFieldElement |
50
|
|
|
|
|
|
|
sub decode_point { |
51
|
545
|
|
|
545
|
0
|
1999
|
my ($self, $x, $y) = @_; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#if ( $self->as_hex() =~ m<\A0x0[467]> ) { |
54
|
|
|
|
|
|
|
# die 'Only uncompressed generators!'; |
55
|
|
|
|
|
|
|
#} |
56
|
|
|
|
|
|
|
|
57
|
545
|
|
|
|
|
2024
|
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
|
549798
|
|
|
549798
|
0
|
1715542
|
my ($self, $x ) = @_; |
63
|
|
|
|
|
|
|
|
64
|
549798
|
|
|
|
|
1494606
|
return Crypt::Perl::ECDSA::EC::FieldElement->new( $self->{'q'}, $x ); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |