line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bitcoin::Crypto::Types; |
2
|
|
|
|
|
|
|
$Bitcoin::Crypto::Types::VERSION = '1.008_01'; # TRIAL |
3
|
|
|
|
|
|
|
$Bitcoin::Crypto::Types::VERSION = '1.00801'; |
4
|
19
|
|
|
19
|
|
75052
|
use v5.10; |
|
19
|
|
|
|
|
93
|
|
5
|
19
|
|
|
19
|
|
192
|
use strict; |
|
19
|
|
|
|
|
54
|
|
|
19
|
|
|
|
|
424
|
|
6
|
19
|
|
|
19
|
|
92
|
use warnings; |
|
19
|
|
|
|
|
42
|
|
|
19
|
|
|
|
|
881
|
|
7
|
|
|
|
|
|
|
|
8
|
19
|
|
|
|
|
275
|
use Type::Library -extends => [ qw( |
9
|
|
|
|
|
|
|
Types::Standard |
10
|
|
|
|
|
|
|
Types::Common::Numeric |
11
|
|
|
|
|
|
|
Types::Common::String |
12
|
19
|
|
|
19
|
|
10106
|
) ]; |
|
19
|
|
|
|
|
748290
|
|
13
|
19
|
|
|
19
|
|
4242210
|
use Type::Coercion; |
|
19
|
|
|
|
|
50
|
|
|
19
|
|
|
|
|
580
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# make sure Math::BigInt is properly loaded - this module loads it |
16
|
19
|
|
|
19
|
|
4536
|
use Bitcoin::Crypto::Helpers; |
|
19
|
|
|
|
|
72
|
|
|
19
|
|
|
|
|
1201
|
|
17
|
19
|
|
|
19
|
|
158
|
use Bitcoin::Crypto::Config; |
|
19
|
|
|
|
|
58
|
|
|
19
|
|
|
|
|
6969
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
__PACKAGE__->add_type( |
20
|
|
|
|
|
|
|
name => 'BIP44Purpose', |
21
|
|
|
|
|
|
|
parent => Maybe [Enum->of(44, 49, 84)], |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
__PACKAGE__->add_type( |
25
|
|
|
|
|
|
|
name => 'IntMaxBits', |
26
|
|
|
|
|
|
|
parent => PositiveOrZeroInt, |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
constraint_generator => sub { |
29
|
|
|
|
|
|
|
my $bits = assert_PositiveInt(shift); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# for same bits as system, no need for special constraint |
32
|
|
|
|
|
|
|
return sub { 1 } |
33
|
|
|
|
|
|
|
if Bitcoin::Crypto::Config::ivsize * 8 == $bits; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# can't handle |
36
|
|
|
|
|
|
|
die 'IntMaxBits only handles up to ' . (Bitcoin::Crypto::Config::ivsize * 8) . ' bits on this system' |
37
|
|
|
|
|
|
|
if Bitcoin::Crypto::Config::ivsize * 8 < $bits; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
my $limit = 1 << $bits; |
40
|
|
|
|
|
|
|
return sub { |
41
|
|
|
|
|
|
|
return $_ < $limit; |
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
}, |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
inline_generator => sub { |
46
|
|
|
|
|
|
|
my $bits = shift; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
return sub { |
49
|
|
|
|
|
|
|
# for same bits as system, no need for special constraint |
50
|
|
|
|
|
|
|
return (undef, qq{ 1 }) |
51
|
|
|
|
|
|
|
if Bitcoin::Crypto::Config::ivsize * 8 == $bits; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $varname = pop; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $limit = 1 << $bits; |
56
|
|
|
|
|
|
|
return (undef, qq{ $varname < $limit }); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
}, |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
message => sub { |
61
|
|
|
|
|
|
|
my $bits = shift; |
62
|
|
|
|
|
|
|
return "Value does not fit in $bits bits"; |
63
|
|
|
|
|
|
|
}, |
64
|
|
|
|
|
|
|
); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Internal use only |
69
|
|
|
|
|
|
|
|