The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Crypt::Perl::ECDSA::Generate - ECDSA key generation

SYNOPSIS

use Crypt::Perl::ECDSA::Generate ();

#$prkey is a C::P::E::PrivateKey instance.
my $prkey = Crypt::Perl::ECDSA::Generate::by_curve_name('secp521r1');

my $signature = $prkey->sign('Hello!');

die 'Wut' if $prkey->verify('Hello!', $signature);

#You can also, in case it’s useful, do this. It’s probably
#only useful if you’re developing a new curve or something … ??
my $prkey2 = Crypt::Perl::ECDSA::Generate::by_explicit_curve(
    {
        p => Crypt::Perl::BigInt->new(...),
        a => ...,
        b => ...,
        n => ...,
        h => ...,
        gx => ...,
        gy => ...,
    },
);

DISCUSSION

Thankfully, this is easy enough on processors that it’s feasible in pure Perl!