NAME
Crypt::Bear::EC::PrivateKey - An EC private key in BearSSL
VERSION
version 0.002
SYNOPSIS
my $private_key = Crypt::Bear::EC::PrivateKey->generate('secp256r1', $prng); my $signature = $private_key->ecdsa_sign('sha256', $hash); my $shared = $private_key->ecdh_key_exchange($some_public_key);
DESCRIPTION
This represents a elliptic curve private key. The curve type can be one of the following:
'sect163k1'
'sect163r1'
'sect163r2'
'sect193r1'
'sect193r2'
'sect233k1'
'sect233r1'
'sect239k1'
'sect283k1'
'sect283r1'
'sect409k1'
'sect409r1'
'sect571k1'
'sect571r1'
'secp160k1'
'secp160r1'
'secp160r2'
'secp192k1'
'secp192r1'
'secp224k1'
'secp224r1'
'secp256k1'
'secp256r1'
'secp384r1'
'secp521r1'
'brainpoolP256r1'
'brainpoolP384r1'
'brainpoolP512r1'
'curve25519'
'curve448'
Common values include 'curve25519'
, 'curve448'
, 'secp256r1'
, 'secp384r1'
, 'secp521r1'
.
METHODS
new($curve, $point)
This returns a new private key representing the given $point
on $curve
.
generate($curve, $prng)
This class method generates a new private key on $curve
, using a Crypt::Bear::PRNG
to do so.
ecdsa_sign($hash_type, $hash_value)
This signs a hash using ecdsa. Currently this is only supported with 'secp256r1'
, 'secp384r1'
and 'secp521r1'
.
ecdh_key_exchange($public_key)
This does a diffie-hellman key exchange with the given public key, and returns the result.
public_key()
This generates the public key matching this private key.
curve()
This returns the curve of this private key.
AUTHOR
Leon Timmermans <fawaka@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2024 by Leon Timmermans.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.