2017 © Pedro Peláez
 

library curve25519

Pure PHP implementation of the Curve25519 Diffie-Hellman function

image

leigh/curve25519

Pure PHP implementation of the Curve25519 Diffie-Hellman function

  • Monday, December 21, 2015
  • by lt
  • Repository
  • 4 Watchers
  • 10 Stars
  • 1,812 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 9 % Grown

The README.md

Curve25519 in PHP

This is a pure PHP implementation of the Curve25519 Diffie-Hellman function., (*1)

The library has been written to be high performance (relative to PHP), not pretty. It obviously doesn't perform anywhere close to a native implementation., (*2)

Usage:

$mySecret = random_bytes(32);
$myPublic = \Curve25519\publicKey($mySecret);
$shared   = \Curve25519\sharedKey($mySecret, $theirPublic);

Multi-party shared secrets:

When more than two parties are communicating, it is necessary to communicate intermediate values so that each party can compute a common shared secret, (*3)

$alicePrivate = str_repeat('a', 32);
$bobPrivate   = str_repeat('b', 32);
$carolPrivate = str_repeat('c', 32);

$alicePublic = \Curve25519\publicKey($alicePrivate); // Send to Bob
$bobPublic   = \Curve25519\publicKey($bobPrivate);   // Send to Carol
$carolPublic = \Curve25519\publicKey($carolPrivate); // Send to Alice

$aliceCarolShared = \Curve25519\sharedKey($alicePrivate, $carolPublic); // Send to Bob
$bobAliceShared   = \Curve25519\sharedKey($bobPrivate,   $alicePublic); // Send to Carol
$carolBobShared   = \Curve25519\sharedKey($carolPrivate, $bobPublic);   // Send to Alice

$aliceShared = \Curve25519\sharedKey($alicePrivate, $carolBobShared);
$bobShared   = \Curve25519\sharedKey($bobPrivate,   $aliceCarolShared);
$carolShared = \Curve25519\sharedKey($carolPrivate, $bobAliceShared);

// An adversary potentially observed f(a), f(b), f(c), f(ab), f(ac), and f(bc),
// whereas each party solved for f(abc)
var_dump($aliceShared === $bobShared && $bobShared === $carolShared);

The Versions

21/12 2015

dev-master

9999999-dev https://github.com/lt/PHP-Curve25519

Pure PHP implementation of the Curve25519 Diffie-Hellman function

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

security elliptic ecdh

21/12 2015

0.1.0

0.1.0.0 https://github.com/lt/PHP-Curve25519

Pure PHP implementation of the Curve25519 Diffie-Hellman function

  Sources   Download

MIT

The Requires

  • php >=5.4

 

The Development Requires

security elliptic ecdh