function check_ElGScalarExp_correctness($pk, $sk)
{
    $group = $pk["group"];
    $Zq = range(0, $group["order"] - 1);
    foreach ($group["G"] as $m) {
        foreach ($Zq as $scalar) {
            if (_DEBUG >= 8) {
                echo "Checking ElGamal scalar exp for {$m} and {$scalar}...";
            }
            $c = ElG_Enc($m, $pk);
            $cmult = ElG_ScalarExp($c, $scalar, $pk);
            if (modular_exp($m, $scalar, $group["modulo"]) != ElG_Dec($cmult, $pk, $sk)) {
                if (_DEBUG >= 1) {
                    echo "\nERROR : ElGamal homomorphic scalar exponentiation error for m = {$m} and scalar = {$scalar}\n";
                }
                return false;
            }
            if (_DEBUG >= 8) {
                echo "\n";
            }
        }
    }
    return true;
}
 if ($keys == false) {
     echo "Error at key generation...";
     exit;
 }
 $end_time = microtime(true);
 $cumul["keygen"] += 1000 * ($end_time - $begin_time);
 list($pk, $sk) = array_values($keys);
 $group = $pk["group"];
 $a = $group["G"][array_rand($group["G"])];
 $b = $group["G"][array_rand($group["G"])];
 $begin_time = microtime(true);
 $ca = ElG_Enc($a, $pk);
 $end_time = microtime(true);
 $cumul["enc"] += 1000 * ($end_time - $begin_time);
 $begin_time = microtime(true);
 ElG_Dec($ca, $pk, $sk);
 $end_time = microtime(true);
 $cumul["dec"] += 1000 * ($end_time - $begin_time);
 $cb = ElG_Enc($b, $pk);
 $begin_time = microtime(true);
 ElG_Mult($ca, $cb, $pk);
 $end_time = microtime(true);
 $cumul["mult"] += 1000 * ($end_time - $begin_time);
 $begin_time = microtime(true);
 ElG_PlainMult($ca, $b, $pk);
 $end_time = microtime(true);
 $cumul["plainmult"] += 1000 * ($end_time - $begin_time);
 $begin_time = microtime(true);
 ElG_ScalarExp($ca, $b, $pk);
 $end_time = microtime(true);
 $cumul["scexp"] += 1000 * ($end_time - $begin_time);