NAME

Crypt::PK::ECC - Public key cryptography based on EC

SYNOPSIS

### OO interface

#Encryption: Alice
my $pub = Crypt::PK::ECC->new('Bob_pub_ecc1.der'); 
my $ct = $pub->encrypt("secret message");
#
#Encryption: Bob (received ciphertext $ct)
my $priv = Crypt::PK::ECC->new('Bob_priv_ecc1.der');
my $pt = $priv->decrypt($ct);
 
#Signature: Alice
my $priv = Crypt::PK::ECC->new('Alice_priv_ecc1.der');
my $sig = $priv->sign($message);
#
#Signature: Bob (received $message + $sig)
my $pub = Crypt::PK::ECC->new('Alice_pub_ecc1.der');
$pub->verify($sig, $message) or die "ERROR";

#Shared secret
my $priv = Crypt::PK::ECC->new('Alice_priv_ecc1.der');
my $pub = Crypt::PK::ECC->new('Bob_pub_ecc1.der'); 
my $shared_secret = $priv->shared_secret($pub);

#Key generation
my $pk = Crypt::PK::ECC->new();
$pk->generate_key(24);
my $private_der = $pk->export_key_der('private');
my $public_der = $pk->export_key_der('public');
my $public_ansi_x963 = $pk->export_key_x963();

### Functional interface

#Encryption: Alice
my $ct = ecc_encrypt('Bob_pub_ecc1.der', "secret message");
#Encryption: Bob (received ciphertext $ct)
my $pt = ecc_decrypt('Bob_priv_ecc1.der', $ct);
 
#Signature: Alice
my $sig = ecc_sign('Alice_priv_ecc1.der', $message);
#Signature: Bob (received $message + $sig)
ecc_verify('Alice_pub_ecc1.der', $sig, $message) or die "ERROR";

#Shared secret
my $shared_secret = ecc_shared_secret('Alice_priv_ecc1.der', 'Bob_pub_ecc1.der');

FUNCTIONS

ecc_encrypt

ecc_decrypt

ecc_sign

ecc_verify

ecc_shared_secret

METHODS

new

generate_key

$pk->generate_key($keysize);
# $keysize .. key size in bytes: 12, 16, 20, 24, 28, 32, 48 or 65

import_key

import_key_x963

export_key_der

export_key_x963

encrypt

decrypt

sign

verify

shared_secret

is_private

size