PHP extension is wrapping ed25519, an Elliptic Curve Digital Signature Algortithm, developed by Dan Bernstein, Niels Duif, Tanja Lange, Peter Schwabe, and Bo-Yin Yang.
Switch branches/tags
Nothing to show
Clone or download
Latest commit d281956 Jul 20, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
debian debianization Apr 20, 2016
.gitignore debianization Apr 20, 2016
LICENSE Update LICENSE Jul 20, 2018
README.md Merge pull request #1 from charlesportwoodii/master Apr 21, 2016
config.m4 First dirty commit - do not use it Apr 16, 2015
curve25519-donna-32bit.h First dirty commit - do not use it Apr 16, 2015
curve25519-donna-64bit.h First dirty commit - do not use it Apr 16, 2015
curve25519-donna-helpers.h First dirty commit - do not use it Apr 16, 2015
curve25519-donna-sse2.h First dirty commit - do not use it Apr 16, 2015
ed25519-donna-32bit-sse2.h First dirty commit - do not use it Apr 16, 2015
ed25519-donna-32bit-tables.h First dirty commit - do not use it Apr 16, 2015
ed25519-donna-64bit-sse2.h First dirty commit - do not use it Apr 16, 2015
ed25519-donna-64bit-tables.h First dirty commit - do not use it Apr 16, 2015
ed25519-donna-64bit-x86-32bit.h First dirty commit - do not use it Apr 16, 2015
ed25519-donna-64bit-x86.h First dirty commit - do not use it Apr 16, 2015
ed25519-donna-basepoint-table.h First dirty commit - do not use it Apr 16, 2015
ed25519-donna-batchverify.h First dirty commit - do not use it Apr 16, 2015
ed25519-donna-impl-base.h First dirty commit - do not use it Apr 16, 2015
ed25519-donna-impl-sse2.h First dirty commit - do not use it Apr 16, 2015
ed25519-donna-portable-identify.h First dirty commit - do not use it Apr 16, 2015
ed25519-donna-portable.h First dirty commit - do not use it Apr 16, 2015
ed25519-donna.h First dirty commit - do not use it Apr 16, 2015
ed25519-ext.c PHP7 Compatibility Apr 15, 2016
ed25519-ext.h PHP7 Compatibility Apr 15, 2016
ed25519-hash-custom.h First dirty commit - do not use it Apr 16, 2015
ed25519-hash.h First dirty commit - do not use it Apr 16, 2015
ed25519-randombytes-custom.h First dirty commit - do not use it Apr 16, 2015
ed25519-randombytes.h First dirty commit - do not use it Apr 16, 2015
ed25519.c First dirty commit - do not use it Apr 16, 2015
ed25519.h First dirty commit - do not use it Apr 16, 2015
modm-donna-32bit.h First running version Apr 16, 2015
modm-donna-64bit.h First running version Apr 16, 2015
regression.h First running version Apr 16, 2015

README.md

php-ed25519-ext

PHP extension wrapping ed25519, an Elliptic Curve Digital Signature Algortithm, developed by Dan Bernstein, Niels Duif, Tanja Lange, Peter Schwabe, and Bo-Yin Yang.

This extensions is based on two projects: ed25519 implemention from https://github.com/floodyberry/ed25519-donna and original PHP curve25519 extension from https://github.com/lt/php-curve25519-ext

How to install:

git clone git://github.com/encedo/php-ed25519-ext.git
cd php-ed25519-ext
phpize
./configure
make
sudo make install

Finally add extension=ed25519.so to your /etc/php.ini

Building a Debian package

You can build it as a Debian package using

git clone git://github.com/encedo/php-ed25519-ext.git
cd php-ed25519-ext
sudo apt-get install php5-dev dh-php5
fakeroot debian/rules binary

Usage:

Generate 32 secret random bytes from a cryptographically safe source e.g.

// PHP 7
$mySecret = random_bytes(32);

// <= PHP 5.6
$mySecret = openssl_random_pseudo_bytes(32);

Then generate the corresponding 32-byte public key by calling

$myPublic = ed25519_publickey($mySecret);

To sign a $message simply call

$signature = ed25519_sign($message, $mySecret, $myPublic);

To verify the $signature for a given $message against $myPublic call

$status = ed25519_sign_open($message,  $myPublic, $signature);

If $status === TRUE the $signature is just fine :)

Example test.php:

<?php

$mySecret = openssl_random_pseudo_bytes(32);
$myPublic = ed25519_publickey($mySecret);

$message = 'Hello, World!';

$signature = ed25519_sign($message, $mySecret, $myPublic);
var_dump( ed25519_sign_open($message,  $myPublic, $signature) );

?>