PHP Classes

Easy PHP ECC: Encrypt, decrypt and sign messages with PHPECC

Recommend this page to a friend!
  Info   View files Documentation   View files View files (26)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 44 All time: 10,743 This week: 100Up
Version License PHP version Categories
easy-ecc 1.0.0MIT/X Consortium ...5PHP 5, Cryptography
Description 

Author

This package can encrypt, decrypt and sign messages with PHPECC.

It provides wrapper classes around PHPECC package to perform several operations with encrypted messages. Currently it case:

- Generate private key
- Get the public key
- Get the signature for a message using a public key
- Generate data to exchange keys using the private key of the origin and the public key of the destination

Picture of Scott Arciszewski
  Performance   Level  
Name: Scott Arciszewski <contact>
Classes: 36 packages by
Country: United States United States
Age: ???
All time rank: 1182171 in United States United States
Week rank: 312 Up38 in United States United States Up
Innovation award
Innovation award
Nominee: 28x

Winner: 1x

Documentation

Easy-ECC

Build Status Latest Stable Version Latest Unstable Version License Downloads

A usability wrapper for PHP ECC.

Installing

composer require paragonie/easy-ecc

Using Easy-ECC

<?php
use ParagonIE\EasyECC\EasyECC;

// Generate an instance; defaults to Curve25519
$ecc = new EasyECC();

// Get a keypair
$alice_sk = $ecc->generatePrivateKey();
$alice_pk = $alice_sk->getPublicKey();

// Signing a message (with PEM-formatted signatures):
$message = 'This is extremely simple to use correctly.';
$signature = $ecc->sign($message, $alice_sk);

if (!$ecc->verify($message, $alice_pk, $signature)) {
    throw new Exception('Signature validation failed');
}

// Let's do a key exchange:
$bob_sk = $ecc->generatePrivateKey();
$bob_pk = $alice_sk->getPublicKey();

$alice_to_bob = $ecc->keyExchange($alice_sk, $bob_pk, true);
$bob_to_alice = $ecc->keyExchange($bob_sk, $alice_pk, false);

Other Easy-ECC Modes

secp256k1 + SHA256

<?php
use ParagonIE\EasyECC\EasyECC;

$ecc = new EasyECC('K256');

NIST P256 + SHA256

<?php
use ParagonIE\EasyECC\EasyECC;

$ecc = new EasyECC('P256');

NIST P384 + SHA384

<?php
use ParagonIE\EasyECC\EasyECC;

$ecc = new EasyECC('P384');

ECDSA-Specific Features

<?php
use ParagonIE\EasyECC\EasyECC;
use ParagonIE\EasyECC\ECDSA\{PublicKey, SecretKey};

// Generate an instance
$ecc = new EasyECC('P256');

// Get a keypair
/ @var SecretKey $alice_sk */
$alice_sk = $ecc->generatePrivateKey();
/ @var PublicKey $alice_pk */
$alice_pk = $alice_sk->getPublicKey();

// Serialize as PEM (for OpenSSL compatibility):
$alice_sk_pem = $alice_sk->exportPem();
$alice_pk_pem = $alice_pk->exportPem();

// Serialize public key as compressed point (for brevity):
$alice_pk_cpt = $alice_pk->toString();

$message = 'This is extremely simple to use correctly.';
// Signing a message (with IEEE-P1363-formatted signatures):
$signature = $ecc->sign($message, $alice_sk, true);
if (!$ecc->verify($message, $alice_pk, $signature, true)) {
    throw new Exception('Signature validation failed');
}

// Let's do a key exchange:
$bob_sk = $ecc->generatePrivateKey();
$bob_pk = $alice_sk->getPublicKey();

$alice_to_bob = $ecc->keyExchange($alice_sk, $bob_pk, true);
$bob_to_alice = $ecc->keyExchange($bob_sk, $alice_pk, false);

Support Contracts

If your company uses this library in their products or services, you may be interested in purchasing a support contract from Paragon Initiative Enterprises.


  Files folder image Files  
File Role Description
Files folder image.github (1 directory)
Files folder imagesrc (1 file, 4 directories)
Files folder imagetests (4 files, 2 directories)
Accessible without login Plain text file autoload-shim.php Example Example script
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file psalm.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files  /  .github  
File Role Description
Files folder imageworkflows (1 file)

  Files folder image Files  /  .github  /  workflows  
File Role Description
  Accessible without login Plain text file ci.yml Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageCurve25519 (5 files)
Files folder imageECDSA (4 files)
Files folder imageException (2 files)
Files folder imageIntegration (1 file)
  Accessible without login Plain text file EasyECC.php Class Class source

  Files folder image Files  /  src  /  Curve25519  
File Role Description
  Accessible without login Plain text file EdwardsPublicKey.php Class Class source
  Accessible without login Plain text file EdwardsSecretKey.php Class Class source
  Accessible without login Plain text file MontgomeryPublicKey.php Class Class source
  Accessible without login Plain text file MontgomerySecretKey.php Class Class source
  Accessible without login Plain text file X25519.php Class Class source

  Files folder image Files  /  src  /  ECDSA  
File Role Description
  Accessible without login Plain text file PublicKey.php Class Class source
  Accessible without login Plain text file PublicKeyDerParser.php Class Class source
  Accessible without login Plain text file SecretKey.php Class Class source
  Accessible without login Plain text file Signature.php Class Class source

  Files folder image Files  /  src  /  Exception  
File Role Description
  Accessible without login Plain text file ConfigException.php Class Class source
  Accessible without login Plain text file NotImplementedException.php Class Class source

  Files folder image Files  /  src  /  Integration  
File Role Description
  Accessible without login Plain text file Defuse.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageECDSA (1 file)
Files folder imageIntegration (1 file)
  Accessible without login Plain text file K256Test.php Class Class source
  Accessible without login Plain text file P256Test.php Class Class source
  Accessible without login Plain text file P384Test.php Class Class source
  Accessible without login Plain text file SodiumTest.php Class Class source

  Files folder image Files  /  tests  /  ECDSA  
File Role Description
  Accessible without login Plain text file SignatureTest.php Class Class source

  Files folder image Files  /  tests  /  Integration  
File Role Description
  Accessible without login Plain text file DefuseTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:44
This week:0
All time:10,743
This week:100Up