File "RandomGeneratorFactory-20260422190128.php"
Full Path: /home/digidjwy/public_html/wp-content/plugins/mycryptocheckout/vendor/mdanter/ecc/src/Random/RandomGeneratorFactory-20260422190128.php
File size: 1.63 KB
MIME-type: text/x-php
Charset: utf-8
<?php
namespace Mdanter\Ecc\Random;
use Mdanter\Ecc\Crypto\Key\PrivateKeyInterface;
use Mdanter\Ecc\Math\MathAdapterFactory;
class RandomGeneratorFactory
{
/**
* @param bool $debug
* @return DebugDecorator|RandomNumberGeneratorInterface|null
*/
public static function getRandomGenerator($debug = false)
{
return self::wrapAdapter(
new RandomNumberGenerator(
MathAdapterFactory::getAdapter($debug)
),
'random_bytes',
$debug
);
}
/**
* @param PrivateKeyInterface $privateKey
* @param \GMP $messageHash
* @param string $algo
* @param bool $debug
* @return DebugDecorator|RandomNumberGeneratorInterface
*/
public static function getHmacRandomGenerator(PrivateKeyInterface $privateKey, \GMP $messageHash, $algo, $debug = false)
{
return self::wrapAdapter(
new HmacRandomNumberGenerator(
MathAdapterFactory::getAdapter($debug),
$privateKey,
$messageHash,
$algo
),
'rfc6979',
$debug
);
}
/**
* @param RandomNumberGeneratorInterface $generator
* @param $name
* @param bool $debug
* @return DebugDecorator|RandomNumberGeneratorInterface
*/
private static function wrapAdapter(RandomNumberGeneratorInterface $generator, $name, $debug = false)
{
if ($debug === true) {
return new DebugDecorator($generator, $name);
}
return $generator;
}
}