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.
 
 
 
 
 
 

33 lines
1.1 KiB

BEGIN { if (-e $ENV{SITE}.'/lib') { use lib $ENV{SITE}.'/lib'; } }
use essential qw(keyw);
use encode qw(mbase58);
use ECKeys qw($keys ecsign ecverif eckeygen saveKeys loadKeys);
use YAML::Syck qw(Dump);
my $other = &loadKeys('secrets/coinbase.yml');
$keys->{coinbase} = $other->{coinbase};
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 $distrib = eckeygen('distribution' => 'ToyChain Distribution Account');
printf "keys: %s\n",Dump($keys);
&saveKeys('keyfile.yml',$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;
print "validating \n";
my $valid = &ecverif($keys->{identity}{public},$sig,"this message is signed by $keys->{identity}{name}");
printf "valid: %s\n",$valid;
exit $?;
1;