PHP code example of pandora-una / paillier

1. Go to this page and download the library: Download pandora-una/paillier library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

pandora-una / paillier example snippets


$paillier = new Paillier();

//chave privada
$paillier->getPrivateKey();

//chave publica
$paillier->getPublicKey());


$paillier = new Paillier();

$msg = 123456781;

$encript = $paillier->getPublicKey()->encrypt($msg);

$msgDecript = $paillier->getPrivateKey()->decrypt($encript);



$paillier = new Paillier();
$v1 = 10;
$e1 = $paillier->getPublicKey()->encrypt($v1);
        
v2 = 15;
$e2 = $paillier->getPublicKey()->encrypt($v2);

$v3 = 3;
$e3 = $paillier->getPublicKey()->encrypt($v3);

$res = Paillier::sum($e1,$e2,$e3);

$dec = $paillier->getPrivateKey()->decrypt($res);

echo $dec; //= 28