ParagonIE_Sodium_Core_Ristretto255

Extends\ParagonIE_Sodium_Core_Ed25519

Class ParagonIE_Sodium_Core_Ristretto255

Implements Curve25519 core functions

Based on the ref10 curve25519 code provided by libsodium

package

Default

Methods

_string_to_element

_string_to_element(\?string $ctx,string $msg,integer $hash_alg): string
static
Throws
\SodiumException

Arguments

$ctx

\?string

$msg

string

$hash_alg

integer

Response

string

abs

abs(integer $integer,integer $size): integer
inheritedstatic

Arguments

$integer

integer

$size

integer

(16, 32, 64)

Response

integer

clamp

clamp(string $s): string
inheritedstatic

Arguments

$s

string

Response

string

If a variable does not match a given type, throw a TypeError.

declareScalarType(mixed &$mixedVar = null,string $type = 'void',integer $argumentIndex): void
inheritedstatic
Throws
\TypeError
\SodiumException

Arguments

$mixedVar

mixed

$type

string

$argumentIndex

integer

fe_abs

fe_abs(\ParagonIE_Sodium_Core_Curve25519_Fe $f): \ParagonIE_Sodium_Core_Curve25519_Fe
static
Throws
\SodiumException

Arguments

Response

\ParagonIE_Sodium_Core_Curve25519_Fe

fe_cneg

fe_cneg(\ParagonIE_Sodium_Core_Curve25519_Fe $f,integer $b): \ParagonIE_Sodium_Core_Curve25519_Fe
static

Ensure limbs are less than 28 bits long to prevent float promotion.

fe_normalize(\ParagonIE_Sodium_Core_Curve25519_Fe $f): \ParagonIE_Sodium_Core_Curve25519_Fe
inheritedstatic

This uses a constant-time conditional swap under the hood.

Arguments

Response

\ParagonIE_Sodium_Core_Curve25519_Fe

ge_cmov8_cached

ge_cmov8_cached(array<mixed,\ParagonIE_Sodium_Core_Curve25519_Ge_Cached> $cached,integer $b): \ParagonIE_Sodium_Core_Curve25519_Ge_Cached
inheritedstatic
Throws
\SodiumException

Arguments

$b

integer

Response

\ParagonIE_Sodium_Core_Curve25519_Ge_Cached

ge_cmov_cached

ge_cmov_cached(\ParagonIE_Sodium_Core_Curve25519_Ge_Cached $t,\ParagonIE_Sodium_Core_Curve25519_Ge_Cached $u,integer $b): \ParagonIE_Sodium_Core_Curve25519_Ge_Cached
inheritedstatic

multiply by the order of the main subgroup l = 2^252+27742317777372353535851937790883648493

ge_mul_l(\ParagonIE_Sodium_Core_Curve25519_Ge_P3 $A): \ParagonIE_Sodium_Core_Curve25519_Ge_P3
inheritedstatic

ge_precomp_0

ge_precomp_0(): \ParagonIE_Sodium_Core_Curve25519_Ge_Precomp
inheritedstatic

Convert a group element to a byte string.

ge_tobytes(\ParagonIE_Sodium_Core_Curve25519_Ge_P2 $h): string
inheritedstatic
Throws
\SodiumException
\TypeError

Arguments

Response

string

h2c_string_to_hash

h2c_string_to_hash(integer $hLen,\?string $ctx,string $msg,integer $hash_alg): string
static
Throws
\SodiumException

Arguments

$hLen

integer

$ctx

\?string

$msg

string

$hash_alg

integer

Response

string

h2c_string_to_hash_sha256

h2c_string_to_hash_sha256(integer $hLen,\?string $ctx,string $msg): string
static
psalm-suppress

PossiblyInvalidArgument hash API

Throws
\SodiumException

Arguments

$hLen

integer

$ctx

\?string

$msg

string

Response

string

h2c_string_to_hash_sha512

h2c_string_to_hash_sha512(integer $hLen,\?string $ctx,string $msg): string
static
psalm-suppress

PossiblyInvalidArgument hash API

Throws
\SodiumException

Arguments

$hLen

integer

$ctx

\?string

$msg

string

Response

string

Catch hash_update() failures and throw instead of silently proceeding

hash_update( &$hs,string $data): void
inheritedstatic
psalm-suppress

PossiblyInvalidArgument

Throws
\SodiumException

Arguments

$hs

$data

string

Evaluate whether or not two strings are equal (in constant-time)

hashEquals(string $left,string $right): boolean
inheritedstatic
Throws
\SodiumException
\TypeError

Arguments

$left

string

$right

string

Response

boolean

is_valid_point

is_valid_point(string $p): integer
static
Throws
\SodiumException

Arguments

$p

string

Response

integer

pk_to_curve25519

pk_to_curve25519(string $pk): string
inheritedstatic
Throws
\SodiumException
\TypeError

Arguments

$pk

string

Response

string

ristretto255_add

ristretto255_add(string $p,string $q): string
static
Throws
\SodiumException

Arguments

$p

string

$q

string

Response

string

ristretto255_elligator

ristretto255_elligator(\ParagonIE_Sodium_Core_Curve25519_Fe $t): \ParagonIE_Sodium_Core_Curve25519_Ge_P3
static

ristretto255_from_hash

ristretto255_from_hash(string $h): string
static
Throws
\SodiumException

Arguments

$h

string

Response

string

ristretto255_frombytes

ristretto255_frombytes(string $s,boolean $skipCanonicalCheck = false): \array{h:
static
Throws
\SodiumException

Arguments

$s

string

$skipCanonicalCheck

boolean

Response

\array{h:

ParagonIE_Sodium_Core_Curve25519_Ge_P3, res: int}

ristretto255_p3_tobytes

ristretto255_p3_tobytes(\ParagonIE_Sodium_Core_Curve25519_Ge_P3 $h): string
static
Throws
\SodiumException

Arguments

Response

string

ristretto255_point_is_canonical

ristretto255_point_is_canonical(string $s): integer
static
Throws
\SodiumException

Arguments

$s

string

Response

integer

ristretto255_random

ristretto255_random(): string
static
Throws
\SodiumException
\Exception

Response

string

ristretto255_scalar_add

ristretto255_scalar_add(string $x,string $y): string
static

Arguments

$x

string

$y

string

Response

string

ristretto255_scalar_complement

ristretto255_scalar_complement(string $s): string
static
Throws
\SodiumException

Arguments

$s

string

Response

string

ristretto255_scalar_from_string

ristretto255_scalar_from_string(string $ctx,string $msg,integer $hash_alg): string
static
Throws
\SodiumException

Arguments

$ctx

string

$msg

string

$hash_alg

integer

Response

string

ristretto255_scalar_invert

ristretto255_scalar_invert(string $s): string
static

Arguments

$s

string

Response

string

ristretto255_scalar_mul

ristretto255_scalar_mul(string $x,string $y): string
static

Arguments

$x

string

$y

string

Response

string

ristretto255_scalar_negate

ristretto255_scalar_negate(string $s): string
static
Throws
\SodiumException

Arguments

$s

string

Response

string

ristretto255_scalar_random

ristretto255_scalar_random(): string
static
Throws
\SodiumException

Response

string

ristretto255_scalar_reduce

ristretto255_scalar_reduce(string $s): string
static

Arguments

$s

string

Response

string

ristretto255_scalar_sub

ristretto255_scalar_sub(string $x,string $y): string
static

Arguments

$x

string

$y

string

Response

string

ristretto255_sqrt_ratio_m1

ristretto255_sqrt_ratio_m1(\ParagonIE_Sodium_Core_Curve25519_Fe $u,\ParagonIE_Sodium_Core_Curve25519_Fe $v): \array{x:
static
Throws
\SodiumException

Arguments

Response

\array{x:

ParagonIE_Sodium_Core_Curve25519_Fe, nonsquare: int}

ristretto255_sub

ristretto255_sub(string $p,string $q): string
static
Throws
\SodiumException

Arguments

$p

string

$q

string

Response

string

sc25519_invert

sc25519_invert(string $s): string
inheritedstatic

Arguments

$s

string

Response

string

sc25519_mul

sc25519_mul(string $a,string $b): string
inheritedstatic

Arguments

$a

string

$b

string

Response

string

sc25519_sq

sc25519_sq(string $s): string
inheritedstatic

Arguments

$s

string

Response

string

sc25519_sqmul

sc25519_sqmul(string $s,integer $n,string $a): string
inheritedstatic

Arguments

$s

string

$n

integer

$a

string

Response

string

scalar_add

scalar_add(string $a,string $b): string
inheritedstatic
Throws
\SodiumException

Arguments

$a

string

$b

string

Response

string

scalar_complement

scalar_complement(string $s): string
inheritedstatic
Throws
\SodiumException

Arguments

$s

string

Response

string

scalar_negate

scalar_negate(string $s): string
inheritedstatic
Throws
\SodiumException

Arguments

$s

string

Response

string

scalar_random

scalar_random(): string
inheritedstatic
Throws
\SodiumException

Response

string

scalar_sub

scalar_sub(string $x,string $y): string
inheritedstatic
Throws
\SodiumException

Arguments

$x

string

$y

string

Response

string

scalarmult_ristretto255

scalarmult_ristretto255(string $n,string $p): string
static
Throws
\SodiumException

Arguments

$n

string

$p

string

Response

string

scalarmult_ristretto255_base

scalarmult_ristretto255_base(string $n): string
static
Throws
\SodiumException

Arguments

$n

string

Response

string

small_order

small_order(string $R): boolean
inheritedstatic
Throws
\SodiumException
\TypeError

Arguments

$R

string

Response

boolean

Constants

crypto_core_ristretto255_HASHBYTES

crypto_core_ristretto255_HASHBYTES

HASH_SC_L

HASH_SC_L

CORE_H2C_SHA256

CORE_H2C_SHA256

CORE_H2C_SHA512

CORE_H2C_SHA512

KEYPAIR_BYTES

KEYPAIR_BYTES
inherited

SEED_BYTES

SEED_BYTES
inherited

SCALAR_BYTES

SCALAR_BYTES
inherited

L

L
inherited

Properties

See: libsodium's crypto_core/curve25519/ref10/base.h

base :\array<int,
inheritedstatic
var

array<int, array<int, array<int, int>>>> Basically, int[32][8][3][10]

Type(s)

\array

See: libsodium's crypto_core/curve25519/ref10/base2.h

base2 :array
inheritedstatic
var

basically int[8][3]

Type(s)

array

37095705934669439343138083508754565189542113879843219016388785533085940283555

d :\array<int,
inheritedstatic
var

int>

Type(s)

\array

2 * d = 16295367250680780974490674513165176452449235426866156013048779062215315747161

d2 :\array<int,
inheritedstatic
var

int>

Type(s)

\array

sqrt(-1)

sqrtm1 :\array<int,
inheritedstatic
var

int>

Type(s)

\array

1 / sqrt(a - d)

invsqrtamd :\array<int,
inheritedstatic
var

int>

Type(s)

\array

sqrt(ad - 1) with a = -1 (mod p)

sqrtadm1 :\array<int,
inheritedstatic
var

int>

Type(s)

\array

1 - d ^ 2

onemsqd :\array<int,
inheritedstatic
var

int>

Type(s)

\array

(d - 1) ^ 2

sqdmone :\array<int,
inheritedstatic
var

int>

Type(s)

\array