You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

28 lines
944 B

BEGIN { if (-e $ENV{SITE}.'/lib') { use lib $ENV{SITE}.'/lib'; } }
use encode qw(mbase58);
use ECKeys qw($keys ecsign ecverif eckeygen saveKeys);
use YAML::Syck qw(Dump);
my $anon = eckeygen('anonymous' => 'This is an anonymous ECDSA key');
my $id = eckeygen('identity' => 'Doctor I·T (demo)');
my $miner = eckeygen('miner' => 'Toycoin Mining Rig Corp.');
my $miner = eckeygen('coinbase' => 'ToyChain Blockchain Bot');
&saveKeys();
printf "keys: %s\n",Dump($keys);
my $sig = &ecsign('coinbase',qq'["coinbase","50","This is a coinbase transaction of 50 coins"]');
printf "- 50 coinbase: %s\n",$sig;
my $sig = &ecsign('coinbase',qq'["coinbase","100","default coinbase"]');
printf "- default coinbase: %s\n",$sig;
$sig = &ecsign('identity',"this message is signed by $keys->{identity}{name}");
printf "sig: %s\n",$sig;
my $valid = &ecverif($keys->{identity}{public},$sig,"this message is signed by $keys->{identity}{name}");
exit $?;
1;