ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Crypt-Ed25519/Ed25519.pm
(Generate patch)

Comparing Crypt-Ed25519/Ed25519.pm (file contents):
Revision 1.13 by root, Tue Feb 28 19:53:08 2017 UTC vs.
Revision 1.14 by root, Wed Aug 11 23:02:08 2021 UTC

36 # verify message 36 # verify message
37 $valid = Crypt::Ed25519::eddsa_verify $message, $pubkey, $signature; 37 $valid = Crypt::Ed25519::eddsa_verify $message, $pubkey, $signature;
38 38
39 # verify, but croak on failure 39 # verify, but croak on failure
40 Crypt::Ed25519:eddsa_verify_croak $message, $pubkey, $signature; 40 Crypt::Ed25519:eddsa_verify_croak $message, $pubkey, $signature;
41
42 ############################################
43 # Key exchange
44
45 # side A:
46 ($pubkey_a, $privkey_a) = Crypt::Ed25519::generate_keypair;
47 # send $pubkey to side B
48
49 # side B:
50 ($pubkey_b, $privkey_b) = Crypt::Ed25519::generate_keypair;
51 # send $pubkey to side A
52
53 # side A then calculates their shared secret:
54 $shared_secret = Crypt::Ed25519::key_exchange $pubkey_b, $privkey_a;
55
56 # and side B does this:
57 $shared_secret = Crypt::Ed25519::key_exchange $pubkey_a, $privkey_b;
58
59 # the generated $shared_secret will be the same - you cna now
60 # hash it with hkdf or something else to generate symmetric private keys
41 61
42=head1 DESCRIPTION 62=head1 DESCRIPTION
43 63
44This module implements Ed25519 public key generation, message signing and 64This module implements Ed25519 public key generation, message signing and
45verification. It is a pretty bare-bones implementation that implements 65verification. It is a pretty bare-bones implementation that implements
74=cut 94=cut
75 95
76package Crypt::Ed25519; 96package Crypt::Ed25519;
77 97
78BEGIN { 98BEGIN {
79 $VERSION = 1.04; 99 $VERSION = 1.05;
80 100
81 require XSLoader; 101 require XSLoader;
82 XSLoader::load Crypt::Ed25519::, $VERSION; 102 XSLoader::load Crypt::Ed25519::, $VERSION;
83} 103}
84 104
186derive the public key as needed. On the other hand, signing using the 206derive the public key as needed. On the other hand, signing using the
187private key is faster than using the secret key, so converting the secret 207private key is faster than using the secret key, so converting the secret
188key to a public/private key pair allows you to sign a small message, or 208key to a public/private key pair allows you to sign a small message, or
189many messages, faster. 209many messages, faster.
190 210
211=head1 Key Exchange
212
213As an extension to Ed25519, this module implements a key exchange similar
214(But not identical) to Curve25519. For this, both sides generate a keypair
215and send their public key to the other side. Then both sides can generate
216the same shared secret using this function:
217
218=over
219
220=item $shared_secret = Crypt::Ed25519::key_exchange $other_public_key, $own_private_key
221
222Return the 32 octet shared secret generated from the given public and
223private key. See SYNOPSIS for an actual example.
224
225=back
226
191=head1 SUPPORT FOR THE PERL MULTICORE SPECIFICATION 227=head1 SUPPORT FOR THE PERL MULTICORE SPECIFICATION
192 228
193This module supports the perl multicore specification 229This module supports the perl multicore specification
194(L<http://perlmulticore.schmorp.de/>) for key generation (usually the 230(L<http://perlmulticore.schmorp.de/>) for all operations, although it
195slowest operation), and all signing and verification functions. 231makes most sense to use it when signing or verifying longer messages.
196 232
197=head1 IMPLEMENTATIOIN 233=head1 IMPLEMENTATION
198 234
199This module currently uses "Nightcracker's Ed25519" implementation, which 235This module currently uses "Nightcracker's Ed25519" implementation, which
200is unmodified except for some portability fixes and static delcarations, 236is unmodified except for some portability fixes and static delcarations,
201but the interface is kept implementation-agnostic to allow usage of other 237but the interface is kept implementation-agnostic to allow usage of other
202implementations in the future. 238implementations in the future.
203 239
204=head1 AUTHOR 240=head1 AUTHOR
205 241
206 Marc Lehmann <schmorp@schmorp.de> 242 Marc Lehmann <schmorp@schmorp.de>
207 http://sfotware.schmorp.de/pkg/Crypt-Ed25519.html 243 http://software.schmorp.de/pkg/Crypt-Ed25519.html
208 244
209=cut 245=cut
210 246
2111 2471
212 248

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines