Crypt-RSA-Blind
view release on metacpan or search on metacpan
lib/Crypt/RSA/Blind.pm view on Meta::CPAN
Crypt::RSA::Blind - Blind RSA signatures
=head1 VERSION
$Revision: 1.035 $
$Date: Wed Jun 11 13:34:13 EST 2025 $
=cut
=head1 SYNOPSIS
use Crypt::RSA::Blind;
use Try::Tiny;
my $rsab = new Crypt::RSA::Blind;
my ($pubkey, $seckey) = $rsab->keygen(Size => 4096);
my $msg = "Hello, world!";
# RSABSSA-PSS methods (RFC 9474)
my $slen = 48; # Salt length (in bytes). 0 for no salt.
my ($blinded_msg, $blinding) = $rsab->blind ( { PublicKey => $pubkey,
Message => $msg,
sLen => $slen } );
my $blind_sig = $rsab->blind_sign( { SecretKey => $seckey,
PublicKey => $pubkey,
BlindedMessage => $blinded_msg } );
my $sig = $rsab->finalize( { PublicKey => $pubkey,
BlindSig => $blind_sig,
Blinding => $blinding,
Message => $msg,
sLen => $slen } );
print "OK\n" if try { $rsab->pss_verify( { PublicKey => $pubkey,
Signature => $sig,
Message => $msg,
sLen => $slen } ) };
# Use old API methods as wrappers for RSABSSA-PSS methods
$rsab->set_oldapi(1); # Enable old API wrappers (default)
# Alternately, use old API methods as originally implemented
$rsab->set_oldapi(0); # Disable old API wrappers (deprecated)
# Old interface
my $init = $rsab->init;
my $req = $rsab->request( Key => $pubkey,
Init => $init,
Message => $msg );
my $blindsig = $rsab->sign( Key => $seckey,
PublicKey => $pubkey,
Message => $req );
my $sig = $rsab->unblind( Key => $pubkey,
Init => $init,
Signature => $blindsig );
print "OK\n" if $rsab->verify( Key => $pubkey,
Message => $msg,
Signature => $sig );
=head1 METHODS
=head2 new
Creates and returns a new C<Crypt::RSA::Blind> object.
=head2 keygen
Generates and returns an RSA key-pair of specified bitsize. This is a
synonym for C<Crypt::RSA::Key::generate>. Arguments and return values
are described in the L<Crypt::RSA::Key> manpage.
=head2 init
Generates and returns an initialization vector.
The RSA blind signature protocol doesn't require the use of
initialization vectors. However, this module can use them to keep
track of the blinding factor for different signing requests, so it is
convenient to use initialization vectors when creating multiple
interlaved signing requests.
When using initialization vectors, the vector should be passed as the
C<Init> named argument to the C<blind> and C<finalize> methods
(in the old deprecated interface, to the C<request> and C<unblind>
methods).
Alternately, you can keep track of the blinding factor for each
request in your own code. In this case, you can supply the blinding
factor as the C<Blinding> named argument to the C<finalize> method,
instead of providing an initialization vector as the C<Init> argument
to C<blind> and C<finalize>.
Initialization vectors are not persistent across different invocations
of a script, so if you need to call C<blind> and C<finalize> in
different processes, you will need to record and persist the blinding
factor yourself.
=head2 blind
Generate a blinding factor and a blinded message for signing.
Returns a list of two binary strings. The first is a the blinded
message for signing, the second is the blinding factor used. Raises an
exception on error.
Expects a hashref containing named arguments. The following arguments
are required:
=over
B<PublicKey> - The public key of the signer
B<Message> - The message to be blind signed
( run in 1.191 second using v1.01-cache-2.11-cpan-71847e10f99 )