Crypt-HashCash
view release on metacpan or search on metacpan
bin/hashcash.pl view on Meta::CPAN
}
my $coinexp = _hex($client->keydb->{id}); $coinexp = '0' x (32 - length($coinexp)) . $coinexp;
$coinexp = unpack('H*','[#]' . substr($client->sigscheme, 0, 1)) . $coinexp;
# print STDERR "COINEXP: $coinexp\n";
for (@$coins) {
# $coinexp .= ' ' . $_->as_string;
$coinexp .= $_->as_hex;
}
$coinexp = pack('H*', $coinexp);
if ($passphrase) {
my $cipher = Crypt::CBC->new (-key => $passphrase, -cipher => 'Rijndael', -header => 'salt');
$coinexp = $cipher->encrypt($coinexp);
}
$coinexp = _squish($coinexp);
my ($msg, $qr, $st) = ('Copy coins from below');
my $len = length($coinexp);
if ($len < 7090 ) {
my $qrfh; my $level;
my @version = qw( 0 41 77 127 187 255 322 370 461 552 652 772 883 1022 1101 1250 1408 1548 1725 1903 2061 2232
2409 2620 2812 3057 3283 3517 3669 3909 4158 4417 4686 4965 5253 5529 5836 6153 6479 6743 7089 );
for (1..40) { next if $len > $version[$_]; $version = $_; last; }
bin/hashcash.pl view on Meta::CPAN
$coins =~ /^5b235d(52|45)([0-9a-f]{32})(.*)$/; ($sigscheme, $vaultid, $coins) = ($1, _dec($2), $3);
my $coinsize = $sigscheme == 52 ? 296 : 170;
while (my $coinstr = substr($coins, 0, $coinsize, '')) { push @coinstrs, $coinstr }
}
else {
$dialog = Wx::TextEntryDialog->new( $frame, "Enter passphrase to decrypt coins", "Add coins to wallet");
if($dialog->ShowModal == wxID_CANCEL) {
return;
}
my $passphrase = $dialog->GetValue();
my $cipher = Crypt::CBC->new (-key => $passphrase, -cipher => 'Rijndael');
my $decrypted = $cipher->decrypt(pack 'H*', $coins); $decrypted =~ s/\s*$//;
return unless $decrypted =~ /^\[\#\](R|E)/;
$decrypted = unpack('H*',$decrypted);
$decrypted =~ /^5b235d(52|45)([0-9a-f]{32})(.*)$/; ($sigscheme, $vaultid, $coins) = ($1, _dec($2), $3);
my $coinsize = ($sigscheme == 52) ? 296 : 170;
while (my $coinstr = substr($coins, 0, $coinsize, '')) { push @coinstrs, $coinstr }
}
unless ($vaultid eq $client->keydb->{id}) {
$dialog = Wx::MessageDialog->new( $frame, "Please switch to the vault with ID\n$vaultid\nto import these coins.", "Add coins to wallet", wxOK);
if($dialog->ShowModal == wxID_OK) {
bin/vault-worker.pl view on Meta::CPAN
use strict;
use warnings;
use Crypt::HashCash::Vault::Bitcoin;
use Crypt::HashCash::Coin::Blinded;
use Crypt::HashCash::CoinRequest;
use Crypt::HashCash::Coin;
use Crypt::HashCash qw (_dec _hex _dectob85 _b85todec);
use Crypt::Random qw(makerandom);
use Crypt::EECDH;
use Crypt::CBC;
use File::HomeDir;
use Digest::MD5 qw(md5_hex);
use IPC::Queue::Duplex;
my $HASHCASH = $ENV{HASHCASHDIR} || File::HomeDir->my_home . '/.hashcash';
unless (-d $HASHCASH) {
die "Directory $HASHCASH doesn't exist and couldn't be created.\n" unless mkdir($HASHCASH, 0700);
}
bin/vault.pl view on Meta::CPAN
use vars qw(@ISA);
use Crypt::HashCash::Vault::Bitcoin;
use Crypt::HashCash::Coin::Blinded;
use Crypt::HashCash::CoinRequest;
use Crypt::HashCash::Coin;
use Crypt::HashCash qw (_dec _hex);
use Crypt::EECDH;
use Digest::MD5 qw(md5_hex);
use Net::Server::PreFork;
use File::HomeDir;
use Crypt::CBC;
my $HASHCASH = $ENV{HASHCASHDIR} || File::HomeDir->my_home . '/.hashcash';
unless (-d $HASHCASH) {
die "Directory $HASHCASH doesn't exist and couldn't be created.\n" unless mkdir($HASHCASH, 0700);
}
unless (-d "$HASHCASH/vaults") {
die "Directory $HASHCASH/.vaults doesn't exist and couldn't be created.\n" unless mkdir("$HASHCASH/vaults", 0700);
}
lib/Crypt/HashCash/Client.pm view on Meta::CPAN
use warnings;
use strict;
use Crypt::Random qw(makerandom);
use Bytes::Random::Secure;
use Crypt::RSA::Blind;
use Crypt::ECDSA::Blind;
use Crypt::HashCash::Coin;
use Crypt::HashCash::CoinRequest;
use Crypt::CBC;
use Persistence::Object::Simple;
use Crypt::EECDH;
use Crypt::HashCash qw (_dec _hex);
use Compress::Zlib;
use vars qw( $VERSION $AUTOLOAD );
our ( $VERSION ) = '$Revision: 1.130 $' =~ /\s+([\d\.]+)/;
sub new {
my $class = shift;
( run in 0.540 second using v1.01-cache-2.11-cpan-e1769b4cff6 )