PublicKey

NAME

Crypt::TweetNacl::PublicKey - public key crypto library

SYNOPSIS

use Crypt::TweetNacl::PublicKey;
# create keys
    my $alice = KeyPair.new;
    my $bob = KeyPair.new;
# create Buf to encrypt
    my $msg = 'Hello World'.encode('UTF-8');
# encrypt
    my $cb = CryptoBox.new(pk => $alice.public , sk => $bob.secret);
    my $data = $cb.encrypt($msg);
# decrypt
    my $cbo = CryptoBoxOpen.new(pk => $bob.public , sk => $alice.secret);
    my $rmsg = $cbo.decrypt($data);
    say $rmsg.decode('UTF-8')

DESCRIPTION

key generation

class KeyPair creates a public/secret keypair. And stores them in
   attributes public and secret.

ciphertext handling

class ciphertext consists of two attributes: data and a nonce.
The constructor accepts:
   - CArray with 16 leading zeros, removes them and stores them into the attribute data.
   - And a 24Byte nonce.
The data without leading zeros can be accessed with the .data accessor.
   The data with leading zeros can be accessed with the .zdata accessor.
The idea is to transport data(no leading zeros) and nonce to the
   receiver combine them into a new ciphertext and decrypt into the
   plaintext message. Somehow this is still missing...

encryption

class CryptoBox encrypts for a public key
The constructor accepts:
    - the public key of the receiver
    - the secret key of the sender
method encrypt accepts a Buf and returns class ciphertext

decryption

class CryptoBoxOpen decrypts for and verifies the sender
   The constructor accepts:
    - the secret key of the receiver
    - the public key of the sender
method decrypt accepts a ciphertext and returns a Buf

OPTIONS

RETURN VALUE

In case problems arise this is reported by an exception.

ERRORS

DIAGNOSTICS

EXAMPLES

ENVIRONMENT

panda --installed list
   - Linenoise        [installed]
   - TweetNacl        [installed]
   - panda            [installed]

FILES

CAVEATS

Various other(not documented) classes and methods might be exported
   by the library. Please ignore them.

BUGS

RESTRICTIONS

NOTES

SEE ALSO

- https://nacl.cr.yp.to/box.html
   - https://tweetnacl.cr.yp.to/tweetnacl-20131229.pdf

AUTHOR

Frank Hartmann

HISTORY

v0.0.1 initial version offered at #perl6

); }

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.