The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Crypt::Perl::ECDSA::PublicKey - object representation of ECDSA public key

SYNOPSIS

    #Use Parse.pm or a private key’s get_public_key()
    #rather #than instantiating this class directly.

    #This works even if the object came from a key file that doesn’t
    #contain the curve name.
    $pbkey->get_curve_name();

    if ($payload > ($pbkey->max_sign_bits() / 8)) {
        die "Payload too long!";
    }

    $pbkey->verify($payload, $sig) or die "Invalid signature!";

    #For JSON Web Algorithms (JWT et al.), cf. RFC 7518 page 8
    #This verifies against the appropriate SHA digest rather than
    #against the original message.
    $pbkey->verify_jwa($payload, $sig) or die "Invalid signature!";

    #----------------------------------------------------------------------

    #Includes “kty”, “crv”, “x”, and “y”.
    #Add in whatever else your application needs afterward.
    #
    #This will die() if you try to run it with a curve that
    #doesn’t have a known JWK “crv” value.
    #
    my $pub_jwk = $pbkey->get_struct_for_public_jwk();

    #Useful for JWTs
    my $jwt_alg = $pbkey->get_jwa_alg();

DISCUSSION

The SYNOPSIS above should be illustration enough of how to use this class.

Export methods (PEM, DER, etc.) are shown in Crypt::Perl::ECDSA.