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

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