Crypt-ECDSA-Blind
view release on metacpan or search on metacpan
lib/Crypt/ECDSA/Blind.pm view on Meta::CPAN
sub from_hex {
bless {d => Math::BigInt->from_hex(shift)}, 'Crypt::ECDSA::Blind::SecKey';
}
sub write {
1;
}
sub d {
shift->{d};
}
1; # End of Crypt::ECDSA::Blind::SecKey
package Crypt::ECDSA::Blind::Signature;
sub s {
Math::BigInt->from_hex(shift->{'s'});
}
sub R {
Crypt::ECDSA::Blind::_point_from_hex(shift->{R});
}
sub is_valid {
my $self = shift;
$self->{R} =~ /^[0-9a-f]+$/ and $self->{s} =~ /^[0-9a-f]+$/;
}
1; # End of Crypt::ECDSA::Blind::Signature
__END__
=head1 NAME
Crypt::ECDSA::Blind - Blind ECDSA Signatures
=head1 VERSION
$Revision: 1.015 $
$Date: Tue Oct 16 22:40:55 PDT 2018 $
=head1 SYNOPSIS
This module implements the blind ECDSA signature protocol outlined in
[1].
use Crypt::ECDSA::Blind;
my $ecdsab = new Crypt::ECDSA::Blind;
my ($pubkey, $seckey) = $ecdsab->keygen;
my $msg = 'Hello, world!';
my $init = $ecdsab->init;
my $req = $ecdsab->request( Key => $pubkey, Init => $init,
Message => $msg );
my $blindsig = $ecdsab->sign( Key => $seckey, Init => $init,
Plaintext => $req );
my $sig = $ecdsab->unblind( Key => $pubkey, Init => $init,
Signature => $blindsig );
print "Verified\n" if $ecdsab->verify( Key => $pubkey, Message => $msg,
Signature => $sig );
=head1 METHODS
=head2 new
Creates and returns a new Crypt::ECDSA::Blind object. The following
optional named parameters can be provided:
=over
DB - Full pathname of a file to use for the database of initialization
vectors. This can also be the special filename ':memory:' in which
case the database will be in RAM rather than on a disk file. The
default is '/tmp/ceb.db'.
=back
=head2 keygen
Generates and returns an ECDSA key-pair for blind signing.
=head2 init
Generates and returns an initialization vector for blind signing. The
initialization vector should be passed in to the request(), sign() and
unblind() methods in the Init named parameter.
=head2 preinit
Generates and saves an initialization vector for later retrieval by
init. Keeping pre-prepared initialization vectors available for use on
demand will speed up calls to init.
=head2 request
Generates and returns a blind signing request. The following named
parameters are required:
=over
Init - The initialization vector from init()
Key - The public key of the signer
Message - The message to be blind signed
=back
=head2 sign
Generates and returns a blind signature. The following named
parameters are required:
=over
Init - The initialization vector from init()
( run in 1.375 second using v1.01-cache-2.11-cpan-71847e10f99 )