Skip to content

mgp25/curve25519-php

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
bin
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

Sponsor this project

 

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •