ParagonIE_Sodium_Core_Curve25519
- Source
wp-includes/sodium_compat/src/Core/Curve25519.php:16
Class ParagonIE_Sodium_Core_Curve25519
Description
Implements Curve25519 core functions
Based on the ref10 curve25519 code provided by libsodium
Compatibility
- WordPress
- core
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Methods · 51
- fe_0()Get a field element of size 10 with a value of 0
- fe_1()Get a field element of size 10 with a value of 1
- fe_add()Add two field elements.
- fe_cmov()Constant-time conditional move.
- fe_copy()Create a copy of a field element.
- fe_frombytes()Give: 32-byte string.
- fe_tobytes()Convert a field element to a byte string.
- fe_isnegative()Is a field element negative? (1 = yes, 0 = no. Used in calculations.)
- fe_isnonzero()Returns 0 if this field element results in all NUL bytes.
- fe_mul()Multiply two field elements
- fe_neg()Get the negative values for each piece of the field element.
- fe_sq()Square a field element
- fe_sq2()Square and double a field element
- fe_invert()
- fe_pow22523()
- fe_sub()Subtract two field elements.
- ge_add()Add two group elements.
- slide()
- ge_frombytes_negate_vartime()
- ge_madd()
- ge_msub()
- ge_p1p1_to_p2()
- ge_p1p1_to_p3()
- ge_p2_0()
- ge_p2_dbl()
- ge_p3_0()
- ge_p3_to_cached()
- ge_p3_to_p2()
- ge_p3_tobytes()
- ge_p3_dbl()
- ge_precomp_0()
- equal()
- negative()
- cmov()Conditional move
- ge_cmov_cached()
- ge_cmov8_cached()
- ge_select()
- ge_sub()Subtract two group elements.
- ge_tobytes()Convert a group element to a byte string.
- ge_double_scalarmult_vartime()
- ge_scalarmult()
- ge_scalarmult_base()
- sc_muladd()Calculates (ab + c) mod l where l = 2^252 + 27742317777372353535851937790883648493
- sc_reduce()
- ge_mul_l()multiply by the order of the main subgroup l = 2^252+27742317777372353535851937790883648493
- sc25519_mul()
- sc25519_sq()
- sc25519_sqmul()
- sc25519_invert()
- clamp()
- fe_normalize()Ensure limbs are less than 28 bits long to prevent float promotion.
Source code
abstract class ParagonIE_Sodium_Core_Curve25519 extends ParagonIE_Sodium_Core_Curve25519_H{ /** * Get a field element of size 10 with a value of 0 * * @internal You should not use this directly from another application * * @return ParagonIE_Sodium_Core_Curve25519_Fe */ public static function fe_0() { return new ParagonIE_Sodium_Core_Curve25519_Fe(); } /** * Get a field element of size 10 with a value of 1 * * @internal You should not use this directly from another application * * @return ParagonIE_Sodium_Core_Curve25519_Fe */ public static function fe_1() { $fe = new ParagonIE_Sodium_Core_Curve25519_Fe(); $fe->e0 = 1; return $fe; } /** * Add two field elements. * * @internal You should not use this directly from another application * * @param ParagonIE_Sodium_Core_Curve25519_Fe $f * @param ParagonIE_Sodium_Core_Curve25519_Fe $g * @return ParagonIE_Sodium_Core_Curve25519_Fe * @psalm-suppress MixedAssignment * @psalm-suppress MixedOperand */ public static function fe_add( ParagonIE_Sodium_Core_Curve25519_Fe $f, ParagonIE_Sodium_Core_Curve25519_Fe $g ) { return new ParagonIE_Sodium_Core_Curve25519_Fe( (int)($f->e0 + $g->e0), (int)($f->e1 + $g->e1), (int)($f->e2 + $g->e2), (int)($f->e3 + $g->e3), (int)($f->e4 + $g->e4), (int)($f->e5 + $g->e5), (int)($f->e6 + $g->e6), (int)($f->e7 + $g->e7), (int)($f->e8 + $g->e8), (int)($f->e9 + $g->e9) ); } /** * Constant-time conditional move. * * @internal You should not use this directly from another application * * @param ParagonIE_Sodium_Core_Curve25519_Fe $f * @param ParagonIE_Sodium_Core_Curve25519_Fe $g * @param int $b * @return ParagonIE_Sodium_Core_Curve25519_Fe * @psalm-suppress MixedAssignment */ public static function fe_cmov( ParagonIE_Sodium_Core_Curve25519_Fe $f, ParagonIE_Sodium_Core_Curve25519_Fe $g, $b = 0 ) { $h = new ParagonIE_Sodium_Core_Curve25519_Fe(); $b *= -1; $x = (($f->e0 ^ $g->e0) & $b); $h->e0 = $f->e0 ^ $x; $x = (($f->e1 ^ $g->e1) & $b); $h->e1 = $f->e1 ^ $x; $x = (($f->e2 ^ $g->e2) & $b); $h->e2 = $f->e2 ^ $x; $x = (($f->e3 ^ $g->e3) & $b); $h->e3 = $f->e3 ^ $x; $x = (($f->e4 ^ $g->e4) & $b); $h->e4 = $f->e4 ^ $x;Changelog
Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/sodium_compat/src/Core/Curve25519.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.