You are here

public static function ParagonIE_Sodium_Core32_Curve25519_Fe::fromIntArray in Automatic Updates 8

Same name and namespace in other branches
  1. 7 vendor/paragonie/sodium_compat/src/Core32/Curve25519/Fe.php \ParagonIE_Sodium_Core32_Curve25519_Fe::fromIntArray()

@internal You should not use this directly from another application

Parameters

array<int, int> $array:

bool $save_indexes:

Return value

self

Throws

SodiumException

TypeError

1 call to ParagonIE_Sodium_Core32_Curve25519_Fe::fromIntArray()
ParagonIE_Sodium_Core32_Curve25519::ge_frombytes_negate_vartime in vendor/paragonie/sodium_compat/src/Core32/Curve25519.php
@internal You should not use this directly from another application

File

vendor/paragonie/sodium_compat/src/Core32/Curve25519/Fe.php, line 67

Class

ParagonIE_Sodium_Core32_Curve25519_Fe
Class ParagonIE_Sodium_Core32_Curve25519_Fe

Code

public static function fromIntArray($array, $save_indexes = null) {
  $count = count($array);
  if ($save_indexes) {
    $keys = array_keys($array);
  }
  else {
    $keys = range(0, $count - 1);
  }
  $array = array_values($array);
  $set = array();

  /** @var int $i */

  /** @var int $v */
  foreach ($array as $i => $v) {
    $set[$i] = ParagonIE_Sodium_Core32_Int32::fromInt($v);
  }
  $obj = new ParagonIE_Sodium_Core32_Curve25519_Fe();
  if ($save_indexes) {
    for ($i = 0; $i < $count; ++$i) {
      $set[$i]->overflow = 0;
      $obj
        ->offsetSet($keys[$i], $set[$i]);
    }
  }
  else {
    for ($i = 0; $i < $count; ++$i) {
      $set[$i]->overflow = 0;
      $obj
        ->offsetSet($i, $set[$i]);
    }
  }
  return $obj;
}