The diffie hellman key exchange can be sped up by a factor of two if phpseclib's Math/BigInteger.php is used:
<?php
include('bigint.php'); // from PHPRPC
include('Math/BigInteger.php'); // from phpseclib
$a = '314b7a78721f2afa3c4fa09e2390c8f2a9a7df0c5c9070d6436f6470eb4c8f414500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111';
$b = '0d02f5c1ab5034a3bf277c2cab283553f42c8095b24c2d7cb8bc52ff09091edec200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111';
$c = '0ae6637ee85c1e90efca75028bb52a2c29e59e2133e07b75bed5ea4ac5d0373b4a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111';
$a = pack('H*', $a);
$b = pack('H*', $b);
$c = pack('H*', $c);
$start = microtime(true);
$xa = bigint_str2num($a);
$xb = bigint_str2num($b);
$xc = bigint_str2num($c);
echo bigint_num2dec(bigint_powmod($xa, $xb, $xc)) . "\r\n\r\n";
$elapsed = microtime(true) - $start;
echo "took $elapsed seconds\r\n\r\n";
$start = microtime(true);
$xa = new Math_BigInteger($a, 256);
$xb = new Math_BigInteger($b, 256);
$xc = new Math_BigInteger($c, 256);
echo $xa->modPow($xb, $xc) . "\r\n\r\n";
$elapsed = microtime(true) - $start;
echo "took $elapsed seconds\r\n\r\n";
?>
On my computer (which doesn't have gmp, bcmath, or the PECL extension big_int installed), PHPRPC takes 8.56 seconds to do that whereas phpseclib takes 4.89 seconds. Both give the same result - phpseclib just does it a lot faster.