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

  1. BEGIN { if (-e $ENV{SITE}.'/lib') { use lib $ENV{SITE}.'/lib'; } }
  2. use essential qw(keyw);
  3. use encode qw(mbase58);
  4. use ECKeys qw($keys ecsign ecverif eckeygen saveKeys loadKeys);
  5. use YAML::Syck qw(Dump);
  6. my $other = &loadKeys('secrets/coinbase.yml');
  7. $keys->{coinbase} = $other->{coinbase};
  8. my $anon = eckeygen('anonymous' => 'This is an anonymous ECDSA key');
  9. my $id = eckeygen('identity' => 'Doctor I·T (demo)');
  10. my $miner = eckeygen('miner' => 'Toycoin Mining Rig Corp.');
  11. my $distrib = eckeygen('distribution' => 'ToyChain Distribution Account');
  12. printf "keys: %s\n",Dump($keys);
  13. &saveKeys('keyfile.yml',$keys);
  14. my $sig = &ecsign('coinbase',qq'["coinbase","50","This is a coinbase transaction of 50 coins"]');
  15. printf "- 50 coinbase: %s\n",$sig;
  16. my $sig = &ecsign('coinbase',qq'["coinbase","100","default coinbase"]');
  17. printf "- default coinbase: %s\n",$sig;
  18. $sig = &ecsign('identity',"this message is signed by $keys->{identity}{name}");
  19. printf "sig: %s\n",$sig;
  20. print "validating \n";
  21. my $valid = &ecverif($keys->{identity}{public},$sig,"this message is signed by $keys->{identity}{name}");
  22. printf "valid: %s\n",$valid;
  23. exit $?;
  24. 1;