All Projects → mgp25 → curve25519-php

mgp25 / curve25519-php

Licence: MIT license
Curve25519 extension for PHP

Programming Languages

c
50402 projects - #5 most used programming language
C++
36643 projects - #6 most used programming language
M4
1887 projects

Curve25519 extension for PHP

php sponsor

Curve25519 library with Ed25519 signatures extension for PHP. It supports PHP 8.

Usage

$randomBytes = random_bytes(32);
$private = curve25519_private($randomBytes);
$public  = curve25519_public($private);
        
$agreement = curve25519_shared($private, $public);
$signature = curve25519_sign(random_bytes(64), $private, $message);
$verified  = curve25519_verify($public, $message, $signature) == 0;

If you are using it in combination with LibSignal for PHP:

$randomBytes = random_bytes(32);
$private = curve25519_private($randomBytes);
$public  = curve25519_public($private);
$keyPair = new ECKeyPair(new DjbECPublicKey($public), new DjbECPrivateKey($private));
        
$agreement = curve25519_shared($keyPair->getPrivateKey(), $keyPair->getPublicKey());
$signature = curve25519_sign(random_bytes(64), $signingKey->getPrivateKey(), $message);
$verified  = curve25519_verify($signingKey->getPublicKey(), $message, $signature) == 0;

Installation

Linux and MacOS

phpize
./configure
make
sudo make install

When installed, make sure to add it in your php.ini env:

php --ini # will reveal your .ini path
# Edit the file and add:
extension=curve25519
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].