| 1 | package Hush::Util; | ||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use Exporter 'import'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Carp qw/longmess/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | our @EXPORT_OK = qw/ | |||||||||
| 7 | barf timing now | ||||||||||
| 8 | is_valid_zaddr | ||||||||||
| 9 | is_valid_privkey | ||||||||||
| 10 | /; | ||||||||||
| 11 | 1 | ▶ | use Time::HiRes qw/gettimeofday tv_interval/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 0 | ▶ | sub now { [gettimeofday] } | ||||||||
|
Subroutine
now: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 14 | 0 | ▶ | sub barf { die longmess(@_); } | ||||||||
|
Subroutine
barf: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 15 | |||||||||||
| 16 | 0 | ▶ | sub timing { | ||||||||
|
Subroutine
timing: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 17 | 0 | my ($t0,$t1) = @_; | |||||||||
| 18 | 0 | return sprintf "%1.4f", tv_interval($t0,$t1); | |||||||||
| 19 | } | ||||||||||
| 20 | |||||||||||
| 21 | # valid for HUSH+ZEC, we need tables for other prefixes | ||||||||||
| 22 | 0 | ▶ | sub is_valid_zaddr { | ||||||||
|
Subroutine
is_valid_zaddr: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 23 | 0 | my ($z) = @_; | |||||||||
| 24 | #warn "zaddr=$z"; | ||||||||||
| 25 | |||||||||||
| 26 | # TODO: only base58 is valid | ||||||||||
| 27 | 0 | ▶ | if ($z =~ m/^zc[a-z0-9]{93}$/i) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 28 | 0 | return 1; | |||||||||
| 29 | } else { | ||||||||||
| 30 | 0 | return 0; | |||||||||
| 31 | } | ||||||||||
| 32 | } | ||||||||||
| 33 | # we never look at taddr privkeys | ||||||||||
| 34 | # valid for HUSH+ZEC, we need tables for other prefixes | ||||||||||
| 35 | 0 | ▶ | sub is_valid_privkey { | ||||||||
|
Subroutine
is_valid_privkey: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 36 | 0 | my ($p) = @_; | |||||||||
| 37 | 0 | $p =~ s!^hushlist://!!g; | |||||||||
| 38 | 0 | ▶ | if ($p =~ m/^SK[a-z0-9]{53}$/i) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 0 | return 1; | |||||||||
| 40 | } else { | ||||||||||
| 41 | 0 | return 0; | |||||||||
| 42 | } | ||||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | |||||||||||
| 46 | 1 | 1; | |||||||||