Edit File by line
/home/zeestwma/richards.../wp-inclu.../sodium_c.../src/Core
File: Ed25519.php
<?php
[0] Fix | Delete
[1] Fix | Delete
if (class_exists('ParagonIE_Sodium_Core_Ed25519', false)) {
[2] Fix | Delete
return;
[3] Fix | Delete
}
[4] Fix | Delete
if (!class_exists('ParagonIE_Sodium_Core_Curve25519', false)) {
[5] Fix | Delete
require_once dirname(__FILE__) . '/Curve25519.php';
[6] Fix | Delete
}
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Class ParagonIE_Sodium_Core_Ed25519
[10] Fix | Delete
*/
[11] Fix | Delete
abstract class ParagonIE_Sodium_Core_Ed25519 extends ParagonIE_Sodium_Core_Curve25519
[12] Fix | Delete
{
[13] Fix | Delete
const KEYPAIR_BYTES = 96;
[14] Fix | Delete
const SEED_BYTES = 32;
[15] Fix | Delete
const SCALAR_BYTES = 32;
[16] Fix | Delete
[17] Fix | Delete
/**
[18] Fix | Delete
* @internal You should not use this directly from another application
[19] Fix | Delete
*
[20] Fix | Delete
* @return string (96 bytes)
[21] Fix | Delete
* @throws Exception
[22] Fix | Delete
* @throws SodiumException
[23] Fix | Delete
* @throws TypeError
[24] Fix | Delete
*/
[25] Fix | Delete
public static function keypair()
[26] Fix | Delete
{
[27] Fix | Delete
$seed = random_bytes(self::SEED_BYTES);
[28] Fix | Delete
$pk = '';
[29] Fix | Delete
$sk = '';
[30] Fix | Delete
self::seed_keypair($pk, $sk, $seed);
[31] Fix | Delete
return $sk . $pk;
[32] Fix | Delete
}
[33] Fix | Delete
[34] Fix | Delete
/**
[35] Fix | Delete
* @internal You should not use this directly from another application
[36] Fix | Delete
*
[37] Fix | Delete
* @param string $pk
[38] Fix | Delete
* @param string $sk
[39] Fix | Delete
* @param string $seed
[40] Fix | Delete
* @return string
[41] Fix | Delete
* @throws SodiumException
[42] Fix | Delete
* @throws TypeError
[43] Fix | Delete
*/
[44] Fix | Delete
public static function seed_keypair(&$pk, &$sk, $seed)
[45] Fix | Delete
{
[46] Fix | Delete
if (self::strlen($seed) !== self::SEED_BYTES) {
[47] Fix | Delete
throw new RangeException('crypto_sign keypair seed must be 32 bytes long');
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
/** @var string $pk */
[51] Fix | Delete
$pk = self::publickey_from_secretkey($seed);
[52] Fix | Delete
$sk = $seed . $pk;
[53] Fix | Delete
return $sk;
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
/**
[57] Fix | Delete
* @internal You should not use this directly from another application
[58] Fix | Delete
*
[59] Fix | Delete
* @param string $keypair
[60] Fix | Delete
* @return string
[61] Fix | Delete
* @throws TypeError
[62] Fix | Delete
*/
[63] Fix | Delete
public static function secretkey($keypair)
[64] Fix | Delete
{
[65] Fix | Delete
if (self::strlen($keypair) !== self::KEYPAIR_BYTES) {
[66] Fix | Delete
throw new RangeException('crypto_sign keypair must be 96 bytes long');
[67] Fix | Delete
}
[68] Fix | Delete
return self::substr($keypair, 0, 64);
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* @internal You should not use this directly from another application
[73] Fix | Delete
*
[74] Fix | Delete
* @param string $keypair
[75] Fix | Delete
* @return string
[76] Fix | Delete
* @throws TypeError
[77] Fix | Delete
*/
[78] Fix | Delete
public static function publickey($keypair)
[79] Fix | Delete
{
[80] Fix | Delete
if (self::strlen($keypair) !== self::KEYPAIR_BYTES) {
[81] Fix | Delete
throw new RangeException('crypto_sign keypair must be 96 bytes long');
[82] Fix | Delete
}
[83] Fix | Delete
return self::substr($keypair, 64, 32);
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
/**
[87] Fix | Delete
* @internal You should not use this directly from another application
[88] Fix | Delete
*
[89] Fix | Delete
* @param string $sk
[90] Fix | Delete
* @return string
[91] Fix | Delete
* @throws SodiumException
[92] Fix | Delete
* @throws TypeError
[93] Fix | Delete
*/
[94] Fix | Delete
public static function publickey_from_secretkey($sk)
[95] Fix | Delete
{
[96] Fix | Delete
/** @var string $sk */
[97] Fix | Delete
$sk = hash('sha512', self::substr($sk, 0, 32), true);
[98] Fix | Delete
$sk[0] = self::intToChr(
[99] Fix | Delete
self::chrToInt($sk[0]) & 248
[100] Fix | Delete
);
[101] Fix | Delete
$sk[31] = self::intToChr(
[102] Fix | Delete
(self::chrToInt($sk[31]) & 63) | 64
[103] Fix | Delete
);
[104] Fix | Delete
return self::sk_to_pk($sk);
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
/**
[108] Fix | Delete
* @param string $pk
[109] Fix | Delete
* @return string
[110] Fix | Delete
* @throws SodiumException
[111] Fix | Delete
* @throws TypeError
[112] Fix | Delete
*/
[113] Fix | Delete
public static function pk_to_curve25519($pk)
[114] Fix | Delete
{
[115] Fix | Delete
if (self::small_order($pk)) {
[116] Fix | Delete
throw new SodiumException('Public key is on a small order');
[117] Fix | Delete
}
[118] Fix | Delete
$A = self::ge_frombytes_negate_vartime(self::substr($pk, 0, 32));
[119] Fix | Delete
$p1 = self::ge_mul_l($A);
[120] Fix | Delete
if (!self::fe_isnonzero($p1->X)) {
[121] Fix | Delete
throw new SodiumException('Unexpected zero result');
[122] Fix | Delete
}
[123] Fix | Delete
[124] Fix | Delete
# fe_1(one_minus_y);
[125] Fix | Delete
# fe_sub(one_minus_y, one_minus_y, A.Y);
[126] Fix | Delete
# fe_invert(one_minus_y, one_minus_y);
[127] Fix | Delete
$one_minux_y = self::fe_invert(
[128] Fix | Delete
self::fe_sub(
[129] Fix | Delete
self::fe_1(),
[130] Fix | Delete
$A->Y
[131] Fix | Delete
)
[132] Fix | Delete
);
[133] Fix | Delete
[134] Fix | Delete
# fe_1(x);
[135] Fix | Delete
# fe_add(x, x, A.Y);
[136] Fix | Delete
# fe_mul(x, x, one_minus_y);
[137] Fix | Delete
$x = self::fe_mul(
[138] Fix | Delete
self::fe_add(self::fe_1(), $A->Y),
[139] Fix | Delete
$one_minux_y
[140] Fix | Delete
);
[141] Fix | Delete
[142] Fix | Delete
# fe_tobytes(curve25519_pk, x);
[143] Fix | Delete
return self::fe_tobytes($x);
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
/**
[147] Fix | Delete
* @internal You should not use this directly from another application
[148] Fix | Delete
*
[149] Fix | Delete
* @param string $sk
[150] Fix | Delete
* @return string
[151] Fix | Delete
* @throws SodiumException
[152] Fix | Delete
* @throws TypeError
[153] Fix | Delete
*/
[154] Fix | Delete
public static function sk_to_pk($sk)
[155] Fix | Delete
{
[156] Fix | Delete
return self::ge_p3_tobytes(
[157] Fix | Delete
self::ge_scalarmult_base(
[158] Fix | Delete
self::substr($sk, 0, 32)
[159] Fix | Delete
)
[160] Fix | Delete
);
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
/**
[164] Fix | Delete
* @internal You should not use this directly from another application
[165] Fix | Delete
*
[166] Fix | Delete
* @param string $message
[167] Fix | Delete
* @param string $sk
[168] Fix | Delete
* @return string
[169] Fix | Delete
* @throws SodiumException
[170] Fix | Delete
* @throws TypeError
[171] Fix | Delete
*/
[172] Fix | Delete
public static function sign($message, $sk)
[173] Fix | Delete
{
[174] Fix | Delete
/** @var string $signature */
[175] Fix | Delete
$signature = self::sign_detached($message, $sk);
[176] Fix | Delete
return $signature . $message;
[177] Fix | Delete
}
[178] Fix | Delete
[179] Fix | Delete
/**
[180] Fix | Delete
* @internal You should not use this directly from another application
[181] Fix | Delete
*
[182] Fix | Delete
* @param string $message A signed message
[183] Fix | Delete
* @param string $pk Public key
[184] Fix | Delete
* @return string Message (without signature)
[185] Fix | Delete
* @throws SodiumException
[186] Fix | Delete
* @throws TypeError
[187] Fix | Delete
*/
[188] Fix | Delete
public static function sign_open($message, $pk)
[189] Fix | Delete
{
[190] Fix | Delete
/** @var string $signature */
[191] Fix | Delete
$signature = self::substr($message, 0, 64);
[192] Fix | Delete
[193] Fix | Delete
/** @var string $message */
[194] Fix | Delete
$message = self::substr($message, 64);
[195] Fix | Delete
[196] Fix | Delete
if (self::verify_detached($signature, $message, $pk)) {
[197] Fix | Delete
return $message;
[198] Fix | Delete
}
[199] Fix | Delete
throw new SodiumException('Invalid signature');
[200] Fix | Delete
}
[201] Fix | Delete
[202] Fix | Delete
/**
[203] Fix | Delete
* @internal You should not use this directly from another application
[204] Fix | Delete
*
[205] Fix | Delete
* @param string $message
[206] Fix | Delete
* @param string $sk
[207] Fix | Delete
* @return string
[208] Fix | Delete
* @throws SodiumException
[209] Fix | Delete
* @throws TypeError
[210] Fix | Delete
*/
[211] Fix | Delete
public static function sign_detached($message, $sk)
[212] Fix | Delete
{
[213] Fix | Delete
# crypto_hash_sha512(az, sk, 32);
[214] Fix | Delete
$az = hash('sha512', self::substr($sk, 0, 32), true);
[215] Fix | Delete
[216] Fix | Delete
# az[0] &= 248;
[217] Fix | Delete
# az[31] &= 63;
[218] Fix | Delete
# az[31] |= 64;
[219] Fix | Delete
$az[0] = self::intToChr(self::chrToInt($az[0]) & 248);
[220] Fix | Delete
$az[31] = self::intToChr((self::chrToInt($az[31]) & 63) | 64);
[221] Fix | Delete
[222] Fix | Delete
# crypto_hash_sha512_init(&hs);
[223] Fix | Delete
# crypto_hash_sha512_update(&hs, az + 32, 32);
[224] Fix | Delete
# crypto_hash_sha512_update(&hs, m, mlen);
[225] Fix | Delete
# crypto_hash_sha512_final(&hs, nonce);
[226] Fix | Delete
$hs = hash_init('sha512');
[227] Fix | Delete
hash_update($hs, self::substr($az, 32, 32));
[228] Fix | Delete
hash_update($hs, $message);
[229] Fix | Delete
$nonceHash = hash_final($hs, true);
[230] Fix | Delete
[231] Fix | Delete
# memmove(sig + 32, sk + 32, 32);
[232] Fix | Delete
$pk = self::substr($sk, 32, 32);
[233] Fix | Delete
[234] Fix | Delete
# sc_reduce(nonce);
[235] Fix | Delete
# ge_scalarmult_base(&R, nonce);
[236] Fix | Delete
# ge_p3_tobytes(sig, &R);
[237] Fix | Delete
$nonce = self::sc_reduce($nonceHash) . self::substr($nonceHash, 32);
[238] Fix | Delete
$sig = self::ge_p3_tobytes(
[239] Fix | Delete
self::ge_scalarmult_base($nonce)
[240] Fix | Delete
);
[241] Fix | Delete
[242] Fix | Delete
# crypto_hash_sha512_init(&hs);
[243] Fix | Delete
# crypto_hash_sha512_update(&hs, sig, 64);
[244] Fix | Delete
# crypto_hash_sha512_update(&hs, m, mlen);
[245] Fix | Delete
# crypto_hash_sha512_final(&hs, hram);
[246] Fix | Delete
$hs = hash_init('sha512');
[247] Fix | Delete
hash_update($hs, self::substr($sig, 0, 32));
[248] Fix | Delete
hash_update($hs, self::substr($pk, 0, 32));
[249] Fix | Delete
hash_update($hs, $message);
[250] Fix | Delete
$hramHash = hash_final($hs, true);
[251] Fix | Delete
[252] Fix | Delete
# sc_reduce(hram);
[253] Fix | Delete
# sc_muladd(sig + 32, hram, az, nonce);
[254] Fix | Delete
$hram = self::sc_reduce($hramHash);
[255] Fix | Delete
$sigAfter = self::sc_muladd($hram, $az, $nonce);
[256] Fix | Delete
$sig = self::substr($sig, 0, 32) . self::substr($sigAfter, 0, 32);
[257] Fix | Delete
[258] Fix | Delete
try {
[259] Fix | Delete
ParagonIE_Sodium_Compat::memzero($az);
[260] Fix | Delete
} catch (SodiumException $ex) {
[261] Fix | Delete
$az = null;
[262] Fix | Delete
}
[263] Fix | Delete
return $sig;
[264] Fix | Delete
}
[265] Fix | Delete
[266] Fix | Delete
/**
[267] Fix | Delete
* @internal You should not use this directly from another application
[268] Fix | Delete
*
[269] Fix | Delete
* @param string $sig
[270] Fix | Delete
* @param string $message
[271] Fix | Delete
* @param string $pk
[272] Fix | Delete
* @return bool
[273] Fix | Delete
* @throws SodiumException
[274] Fix | Delete
* @throws TypeError
[275] Fix | Delete
*/
[276] Fix | Delete
public static function verify_detached($sig, $message, $pk)
[277] Fix | Delete
{
[278] Fix | Delete
if (self::strlen($sig) < 64) {
[279] Fix | Delete
throw new SodiumException('Signature is too short');
[280] Fix | Delete
}
[281] Fix | Delete
if ((self::chrToInt($sig[63]) & 240) && self::check_S_lt_L(self::substr($sig, 32, 32))) {
[282] Fix | Delete
throw new SodiumException('S < L - Invalid signature');
[283] Fix | Delete
}
[284] Fix | Delete
if (self::small_order($sig)) {
[285] Fix | Delete
throw new SodiumException('Signature is on too small of an order');
[286] Fix | Delete
}
[287] Fix | Delete
if ((self::chrToInt($sig[63]) & 224) !== 0) {
[288] Fix | Delete
throw new SodiumException('Invalid signature');
[289] Fix | Delete
}
[290] Fix | Delete
$d = 0;
[291] Fix | Delete
for ($i = 0; $i < 32; ++$i) {
[292] Fix | Delete
$d |= self::chrToInt($pk[$i]);
[293] Fix | Delete
}
[294] Fix | Delete
if ($d === 0) {
[295] Fix | Delete
throw new SodiumException('All zero public key');
[296] Fix | Delete
}
[297] Fix | Delete
[298] Fix | Delete
/** @var bool The original value of ParagonIE_Sodium_Compat::$fastMult */
[299] Fix | Delete
$orig = ParagonIE_Sodium_Compat::$fastMult;
[300] Fix | Delete
[301] Fix | Delete
// Set ParagonIE_Sodium_Compat::$fastMult to true to speed up verification.
[302] Fix | Delete
ParagonIE_Sodium_Compat::$fastMult = true;
[303] Fix | Delete
[304] Fix | Delete
/** @var ParagonIE_Sodium_Core_Curve25519_Ge_P3 $A */
[305] Fix | Delete
$A = self::ge_frombytes_negate_vartime($pk);
[306] Fix | Delete
[307] Fix | Delete
/** @var string $hDigest */
[308] Fix | Delete
$hDigest = hash(
[309] Fix | Delete
'sha512',
[310] Fix | Delete
self::substr($sig, 0, 32) .
[311] Fix | Delete
self::substr($pk, 0, 32) .
[312] Fix | Delete
$message,
[313] Fix | Delete
true
[314] Fix | Delete
);
[315] Fix | Delete
[316] Fix | Delete
/** @var string $h */
[317] Fix | Delete
$h = self::sc_reduce($hDigest) . self::substr($hDigest, 32);
[318] Fix | Delete
[319] Fix | Delete
/** @var ParagonIE_Sodium_Core_Curve25519_Ge_P2 $R */
[320] Fix | Delete
$R = self::ge_double_scalarmult_vartime(
[321] Fix | Delete
$h,
[322] Fix | Delete
$A,
[323] Fix | Delete
self::substr($sig, 32)
[324] Fix | Delete
);
[325] Fix | Delete
[326] Fix | Delete
/** @var string $rcheck */
[327] Fix | Delete
$rcheck = self::ge_tobytes($R);
[328] Fix | Delete
[329] Fix | Delete
// Reset ParagonIE_Sodium_Compat::$fastMult to what it was before.
[330] Fix | Delete
ParagonIE_Sodium_Compat::$fastMult = $orig;
[331] Fix | Delete
[332] Fix | Delete
return self::verify_32($rcheck, self::substr($sig, 0, 32));
[333] Fix | Delete
}
[334] Fix | Delete
[335] Fix | Delete
/**
[336] Fix | Delete
* @internal You should not use this directly from another application
[337] Fix | Delete
*
[338] Fix | Delete
* @param string $S
[339] Fix | Delete
* @return bool
[340] Fix | Delete
* @throws SodiumException
[341] Fix | Delete
* @throws TypeError
[342] Fix | Delete
*/
[343] Fix | Delete
public static function check_S_lt_L($S)
[344] Fix | Delete
{
[345] Fix | Delete
if (self::strlen($S) < 32) {
[346] Fix | Delete
throw new SodiumException('Signature must be 32 bytes');
[347] Fix | Delete
}
[348] Fix | Delete
$L = array(
[349] Fix | Delete
0xed, 0xd3, 0xf5, 0x5c, 0x1a, 0x63, 0x12, 0x58,
[350] Fix | Delete
0xd6, 0x9c, 0xf7, 0xa2, 0xde, 0xf9, 0xde, 0x14,
[351] Fix | Delete
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
[352] Fix | Delete
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10
[353] Fix | Delete
);
[354] Fix | Delete
$c = 0;
[355] Fix | Delete
$n = 1;
[356] Fix | Delete
$i = 32;
[357] Fix | Delete
[358] Fix | Delete
/** @var array<int, int> $L */
[359] Fix | Delete
do {
[360] Fix | Delete
--$i;
[361] Fix | Delete
$x = self::chrToInt($S[$i]);
[362] Fix | Delete
$c |= (
[363] Fix | Delete
(($x - $L[$i]) >> 8) & $n
[364] Fix | Delete
);
[365] Fix | Delete
$n &= (
[366] Fix | Delete
(($x ^ $L[$i]) - 1) >> 8
[367] Fix | Delete
);
[368] Fix | Delete
} while ($i !== 0);
[369] Fix | Delete
[370] Fix | Delete
return $c === 0;
[371] Fix | Delete
}
[372] Fix | Delete
[373] Fix | Delete
/**
[374] Fix | Delete
* @param string $R
[375] Fix | Delete
* @return bool
[376] Fix | Delete
* @throws SodiumException
[377] Fix | Delete
* @throws TypeError
[378] Fix | Delete
*/
[379] Fix | Delete
public static function small_order($R)
[380] Fix | Delete
{
[381] Fix | Delete
/** @var array<int, array<int, int>> $blocklist */
[382] Fix | Delete
$blocklist = array(
[383] Fix | Delete
/* 0 (order 4) */
[384] Fix | Delete
array(
[385] Fix | Delete
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
[386] Fix | Delete
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
[387] Fix | Delete
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
[388] Fix | Delete
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
[389] Fix | Delete
),
[390] Fix | Delete
/* 1 (order 1) */
[391] Fix | Delete
array(
[392] Fix | Delete
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
[393] Fix | Delete
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
[394] Fix | Delete
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
[395] Fix | Delete
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
[396] Fix | Delete
),
[397] Fix | Delete
/* 2707385501144840649318225287225658788936804267575313519463743609750303402022 (order 8) */
[398] Fix | Delete
array(
[399] Fix | Delete
0x26, 0xe8, 0x95, 0x8f, 0xc2, 0xb2, 0x27, 0xb0,
[400] Fix | Delete
0x45, 0xc3, 0xf4, 0x89, 0xf2, 0xef, 0x98, 0xf0,
[401] Fix | Delete
0xd5, 0xdf, 0xac, 0x05, 0xd3, 0xc6, 0x33, 0x39,
[402] Fix | Delete
0xb1, 0x38, 0x02, 0x88, 0x6d, 0x53, 0xfc, 0x05
[403] Fix | Delete
),
[404] Fix | Delete
/* 55188659117513257062467267217118295137698188065244968500265048394206261417927 (order 8) */
[405] Fix | Delete
array(
[406] Fix | Delete
0xc7, 0x17, 0x6a, 0x70, 0x3d, 0x4d, 0xd8, 0x4f,
[407] Fix | Delete
0xba, 0x3c, 0x0b, 0x76, 0x0d, 0x10, 0x67, 0x0f,
[408] Fix | Delete
0x2a, 0x20, 0x53, 0xfa, 0x2c, 0x39, 0xcc, 0xc6,
[409] Fix | Delete
0x4e, 0xc7, 0xfd, 0x77, 0x92, 0xac, 0x03, 0x7a
[410] Fix | Delete
),
[411] Fix | Delete
/* p-1 (order 2) */
[412] Fix | Delete
array(
[413] Fix | Delete
0x13, 0xe8, 0x95, 0x8f, 0xc2, 0xb2, 0x27, 0xb0,
[414] Fix | Delete
0x45, 0xc3, 0xf4, 0x89, 0xf2, 0xef, 0x98, 0xf0,
[415] Fix | Delete
0xd5, 0xdf, 0xac, 0x05, 0xd3, 0xc6, 0x33, 0x39,
[416] Fix | Delete
0xb1, 0x38, 0x02, 0x88, 0x6d, 0x53, 0xfc, 0x85
[417] Fix | Delete
),
[418] Fix | Delete
/* p (order 4) */
[419] Fix | Delete
array(
[420] Fix | Delete
0xb4, 0x17, 0x6a, 0x70, 0x3d, 0x4d, 0xd8, 0x4f,
[421] Fix | Delete
0xba, 0x3c, 0x0b, 0x76, 0x0d, 0x10, 0x67, 0x0f,
[422] Fix | Delete
0x2a, 0x20, 0x53, 0xfa, 0x2c, 0x39, 0xcc, 0xc6,
[423] Fix | Delete
0x4e, 0xc7, 0xfd, 0x77, 0x92, 0xac, 0x03, 0xfa
[424] Fix | Delete
),
[425] Fix | Delete
/* p+1 (order 1) */
[426] Fix | Delete
array(
[427] Fix | Delete
0xec, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
[428] Fix | Delete
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
[429] Fix | Delete
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
[430] Fix | Delete
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f
[431] Fix | Delete
),
[432] Fix | Delete
/* p+2707385501144840649318225287225658788936804267575313519463743609750303402022 (order 8) */
[433] Fix | Delete
array(
[434] Fix | Delete
0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
[435] Fix | Delete
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
[436] Fix | Delete
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
[437] Fix | Delete
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f
[438] Fix | Delete
),
[439] Fix | Delete
/* p+55188659117513257062467267217118295137698188065244968500265048394206261417927 (order 8) */
[440] Fix | Delete
array(
[441] Fix | Delete
0xee, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
[442] Fix | Delete
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
[443] Fix | Delete
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
[444] Fix | Delete
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f
[445] Fix | Delete
),
[446] Fix | Delete
/* 2p-1 (order 2) */
[447] Fix | Delete
array(
[448] Fix | Delete
0xd9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
[449] Fix | Delete
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
[450] Fix | Delete
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
[451] Fix | Delete
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
[452] Fix | Delete
),
[453] Fix | Delete
/* 2p (order 4) */
[454] Fix | Delete
array(
[455] Fix | Delete
0xda, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
[456] Fix | Delete
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
[457] Fix | Delete
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
[458] Fix | Delete
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
[459] Fix | Delete
),
[460] Fix | Delete
/* 2p+1 (order 1) */
[461] Fix | Delete
array(
[462] Fix | Delete
0xdb, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
[463] Fix | Delete
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
[464] Fix | Delete
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
[465] Fix | Delete
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
[466] Fix | Delete
)
[467] Fix | Delete
);
[468] Fix | Delete
/** @var int $countBlocklist */
[469] Fix | Delete
$countBlocklist = count($blocklist);
[470] Fix | Delete
[471] Fix | Delete
for ($i = 0; $i < $countBlocklist; ++$i) {
[472] Fix | Delete
$c = 0;
[473] Fix | Delete
for ($j = 0; $j < 32; ++$j) {
[474] Fix | Delete
$c |= self::chrToInt($R[$j]) ^ (int) $blocklist[$i][$j];
[475] Fix | Delete
}
[476] Fix | Delete
if ($c === 0) {
[477] Fix | Delete
return true;
[478] Fix | Delete
}
[479] Fix | Delete
}
[480] Fix | Delete
return false;
[481] Fix | Delete
}
[482] Fix | Delete
[483] Fix | Delete
/**
[484] Fix | Delete
* @param string $s
[485] Fix | Delete
* @return string
[486] Fix | Delete
* @throws SodiumException
[487] Fix | Delete
*/
[488] Fix | Delete
public static function scalar_complement($s)
[489] Fix | Delete
{
[490] Fix | Delete
$t_ = self::L . str_repeat("\x00", 32);
[491] Fix | Delete
sodium_increment($t_);
[492] Fix | Delete
$s_ = $s . str_repeat("\x00", 32);
[493] Fix | Delete
ParagonIE_Sodium_Compat::sub($t_, $s_);
[494] Fix | Delete
return self::sc_reduce($t_);
[495] Fix | Delete
}
[496] Fix | Delete
[497] Fix | Delete
/**
[498] Fix | Delete
* @return string
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function