You are here

public static function ParagonIE_Sodium_Core_Curve25519::fe_invert in Automatic Updates 7

Same name and namespace in other branches
  1. 8 vendor/paragonie/sodium_compat/src/Core/Curve25519.php \ParagonIE_Sodium_Core_Curve25519::fe_invert()

@internal You should not use this directly from another application

Parameters

ParagonIE_Sodium_Core_Curve25519_Fe $Z:

Return value

ParagonIE_Sodium_Core_Curve25519_Fe

5 calls to ParagonIE_Sodium_Core_Curve25519::fe_invert()
ParagonIE_Sodium_Core_Curve25519::ge_p3_tobytes in vendor/paragonie/sodium_compat/src/Core/Curve25519.php
@internal You should not use this directly from another application
ParagonIE_Sodium_Core_Curve25519::ge_tobytes in vendor/paragonie/sodium_compat/src/Core/Curve25519.php
Convert a group element to a byte string.
ParagonIE_Sodium_Core_Ed25519::pk_to_curve25519 in vendor/paragonie/sodium_compat/src/Core/Ed25519.php
ParagonIE_Sodium_Core_X25519::crypto_scalarmult_curve25519_ref10 in vendor/paragonie/sodium_compat/src/Core/X25519.php
@internal You should not use this directly from another application
ParagonIE_Sodium_Core_X25519::edwards_to_montgomery in vendor/paragonie/sodium_compat/src/Core/X25519.php
@internal You should not use this directly from another application

File

vendor/paragonie/sodium_compat/src/Core/Curve25519.php, line 1038

Class

ParagonIE_Sodium_Core_Curve25519
Class ParagonIE_Sodium_Core_Curve25519

Code

public static function fe_invert(ParagonIE_Sodium_Core_Curve25519_Fe $Z) {
  $z = clone $Z;
  $t0 = self::fe_sq($z);
  $t1 = self::fe_sq($t0);
  $t1 = self::fe_sq($t1);
  $t1 = self::fe_mul($z, $t1);
  $t0 = self::fe_mul($t0, $t1);
  $t2 = self::fe_sq($t0);
  $t1 = self::fe_mul($t1, $t2);
  $t2 = self::fe_sq($t1);
  for ($i = 1; $i < 5; ++$i) {
    $t2 = self::fe_sq($t2);
  }
  $t1 = self::fe_mul($t2, $t1);
  $t2 = self::fe_sq($t1);
  for ($i = 1; $i < 10; ++$i) {
    $t2 = self::fe_sq($t2);
  }
  $t2 = self::fe_mul($t2, $t1);
  $t3 = self::fe_sq($t2);
  for ($i = 1; $i < 20; ++$i) {
    $t3 = self::fe_sq($t3);
  }
  $t2 = self::fe_mul($t3, $t2);
  $t2 = self::fe_sq($t2);
  for ($i = 1; $i < 10; ++$i) {
    $t2 = self::fe_sq($t2);
  }
  $t1 = self::fe_mul($t2, $t1);
  $t2 = self::fe_sq($t1);
  for ($i = 1; $i < 50; ++$i) {
    $t2 = self::fe_sq($t2);
  }
  $t2 = self::fe_mul($t2, $t1);
  $t3 = self::fe_sq($t2);
  for ($i = 1; $i < 100; ++$i) {
    $t3 = self::fe_sq($t3);
  }
  $t2 = self::fe_mul($t3, $t2);
  $t2 = self::fe_sq($t2);
  for ($i = 1; $i < 50; ++$i) {
    $t2 = self::fe_sq($t2);
  }
  $t1 = self::fe_mul($t2, $t1);
  $t1 = self::fe_sq($t1);
  for ($i = 1; $i < 5; ++$i) {
    $t1 = self::fe_sq($t1);
  }
  return self::fe_mul($t1, $t0);
}