Skip to content

MakarandMane/curve25519-php

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Curve25519 extension for PHP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 98.7%
  • C++ 1.1%
  • M4 0.2%