Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
encedo committed Apr 16, 2015
1 parent 4260a41 commit 2024966
Showing 1 changed file with 48 additions and 3 deletions.
51 changes: 48 additions & 3 deletions README.md
@@ -1,9 +1,8 @@
# 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:
1. ed25519 implemention from https://github.com/floodyberry/ed25519-donna
2. original PHP curve25519 extension from https://github.com/lt/php-curve25519-ext
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:

Expand All @@ -16,3 +15,49 @@ make
sudo make install
```
Finally add `extension=ed25519.so` to your /etc/php.ini


### Usage:

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

```
$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 = "Hellow World";
$signature = ed25519_sign($message, $mySecret, $myPublic);
var_dump( ed25519_sign_open($message, $myPublic, $signature) );
?>

0 comments on commit 2024966

Please sign in to comment.