You are here

public static function ParagonIE_Sodium_Core32_Curve25519_Fe::fromArray in Automatic Updates 7

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

@internal You should not use this directly from another application

Parameters

array<int, ParagonIE_Sodium_Core32_Int32> $array:

bool $save_indexes:

Return value

self

Throws

SodiumException

TypeError

14 calls to ParagonIE_Sodium_Core32_Curve25519_Fe::fromArray()
ParagonIE_Sodium_Core32_Curve25519::fe_0 in vendor/paragonie/sodium_compat/src/Core32/Curve25519.php
Get a field element of size 10 with a value of 0
ParagonIE_Sodium_Core32_Curve25519::fe_1 in vendor/paragonie/sodium_compat/src/Core32/Curve25519.php
Get a field element of size 10 with a value of 1
ParagonIE_Sodium_Core32_Curve25519::fe_add in vendor/paragonie/sodium_compat/src/Core32/Curve25519.php
Add two field elements.
ParagonIE_Sodium_Core32_Curve25519::fe_cmov in vendor/paragonie/sodium_compat/src/Core32/Curve25519.php
Constant-time conditional move.
ParagonIE_Sodium_Core32_Curve25519::fe_frombytes in vendor/paragonie/sodium_compat/src/Core32/Curve25519.php
Give: 32-byte string. Receive: A field element object to use for internal calculations.

... See full list

File

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

Class

ParagonIE_Sodium_Core32_Curve25519_Fe
Class ParagonIE_Sodium_Core32_Curve25519_Fe

Code

public static function fromArray($array, $save_indexes = null) {
  $count = count($array);
  if ($save_indexes) {
    $keys = array_keys($array);
  }
  else {
    $keys = range(0, $count - 1);
  }
  $array = array_values($array);
  $obj = new ParagonIE_Sodium_Core32_Curve25519_Fe();
  if ($save_indexes) {
    for ($i = 0; $i < $count; ++$i) {
      $array[$i]->overflow = 0;
      $obj
        ->offsetSet($keys[$i], $array[$i]);
    }
  }
  else {
    for ($i = 0; $i < $count; ++$i) {
      $array[$i]->overflow = 0;
      $obj
        ->offsetSet($i, $array[$i]);
    }
  }
  return $obj;
}