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;
}
     $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);
     $begin_time = microtime(true);
     ElG_Rerand($ca, $pk);
     $end_time = microtime(true);
     $cumul["rerand"] += 1000 * ($end_time - $begin_time);
 }
 echo "For {$limit} tests and a security of {$lambda} bits, mean ElGamal running times are:\n";
 echo "\tKeyGen: ", $cumul["keygen"] / $limit, "ms\n";
 echo "\tEnc: ", $cumul["enc"] / $limit, "ms\n";
 echo "\tDec: ", $cumul["dec"] / $limit, "ms\n";
 echo "\tMult: ", $cumul["mult"] / $limit, "ms\n";
 echo "\tPlainMult: ", $cumul["plainmult"] / $limit, "ms\n";
 echo "\tScalarExp: ", $cumul["scexp"] / $limit, "ms\n";
 echo "\tRerand: ", $cumul["rerand"] / $limit, "ms\n";