Constants

salsa20_KEY

salsa20_KEY

salsa20_NONCE

salsa20_NONCE

salsa20_INPUT

salsa20_INPUT

salsa20_OUTPUT

salsa20_OUTPUT

salsa20_CONST

salsa20_CONST

hsalsa20_KEY

hsalsa20_KEY

hsalsa20_INPUT

hsalsa20_INPUT

hsalsa20_OUTPUT

hsalsa20_OUTPUT

hsalsa20_CONST

hsalsa20_CONST

xsalsa20_KEY

xsalsa20_KEY

xsalsa20_NONCE

xsalsa20_NONCE

stream_salsa20_KEY

stream_salsa20_KEY

stream_salsa20_NONCE

stream_salsa20_NONCE

poly1305_KEY

poly1305_KEY

poly1305_OUTPUT

poly1305_OUTPUT

onetimeauth_KEY

onetimeauth_KEY

onetimeauth_OUTPUT

onetimeauth_OUTPUT

secretbox_KEY

secretbox_KEY

secretbox_NONCE

secretbox_NONCE

secretbox_ZERO

secretbox_ZERO

secretbox_BOXZERO

secretbox_BOXZERO

scalarmult_INPUT

scalarmult_INPUT

scalarmult_SCALAR

scalarmult_SCALAR

box_PRIVATEKEY

box_PRIVATEKEY

box_PUBLICKEY

box_PUBLICKEY

box_NONCE

box_NONCE

sign_PRIVATEKEY

sign_PRIVATEKEY

sign_PUBLICKEY

sign_PUBLICKEY

sign_SIGNATURE

sign_SIGNATURE

Properties

$instance

$instance : 

Type

Methods

instance()

instance() : \Salt

Returns

\Salt

randombytes()

randombytes(  $length = 32) : string

Helper function to generate random string.

Parameters

$length

Returns

string

equal()

equal(  $x,   $y) : boolean

Returns true if $x === $y

Parameters

$x
$y

Returns

boolean

crypto_core_salsa20()

crypto_core_salsa20(  $in,   $key,   $const) 

Parameters

$in
$key
$const

crypto_core_hsalsa20()

crypto_core_hsalsa20(  $in,   $key,   $const) 

Parameters

$in
$key
$const

crypto_onetimeauth()

crypto_onetimeauth(  $in,   $length,   $key) 

Parameters

$in
$length
$key

crypto_onetimeauth_verify()

crypto_onetimeauth_verify(  $mac,   $in,   $length,   $key) 

Parameters

$mac
$in
$length
$key

crypto_stream_salsa20()

crypto_stream_salsa20(  $length,   $nonce,   $key) 

Parameters

$length
$nonce
$key

crypto_stream_salsa20_xor()

crypto_stream_salsa20_xor(  $in,   $length,   $nonce,   $key) 

Parameters

$in
$length
$nonce
$key

crypto_stream_xsalsa20()

crypto_stream_xsalsa20(  $length,   $nonce,   $key) 

Parameters

$length
$nonce
$key

crypto_stream_xsalsa20_xor()

crypto_stream_xsalsa20_xor(  $in,   $length,   $nonce,   $key) 

Parameters

$in
$length
$nonce
$key

crypto_stream()

crypto_stream(  $length,   $nonce,   $key) 

Parameters

$length
$nonce
$key

crypto_stream_xor()

crypto_stream_xor(  $in,   $length,   $nonce,   $key) 

Parameters

$in
$length
$nonce
$key

crypto_secretbox()

crypto_secretbox(  $message,   $length,   $nonce,   $key) 

Parameters

$message
$length
$nonce
$key

crypto_secretbox_open()

crypto_secretbox_open(  $ciphertext,   $length,   $nonce,   $key) 

Parameters

$ciphertext
$length
$nonce
$key

crypto_scalarmult()

crypto_scalarmult(  $in,   $scalar) 

Parameters

$in
$scalar

crypto_scalarmult_base()

crypto_scalarmult_base(  $in) 

Parameters

$in

crypto_box_keypair()

crypto_box_keypair() 

crypto_box_beforenm()

crypto_box_beforenm(  $publickey,   $privatekey) 

Parameters

$publickey
$privatekey

crypto_box_afternm()

crypto_box_afternm(  $input,   $length,   $nonce,   $key) 

Parameters

$input
$length
$nonce
$key

crypto_box()

crypto_box(  $input,   $length,   $nonce,   $publickey,   $privatekey) 

Parameters

$input
$length
$nonce
$publickey
$privatekey

crypto_box_open_afternm()

crypto_box_open_afternm(  $ciphertext,   $length,   $nonce,   $key) 

Parameters

$ciphertext
$length
$nonce
$key

crypto_box_open()

crypto_box_open(  $ciphertext,   $length,   $nonce,   $publickey,   $privatekey) 

Parameters

$ciphertext
$length
$nonce
$publickey
$privatekey

crypto_sign_keypair()

crypto_sign_keypair(  $seed = null) : array

Generates a secret key and a corresponding public key.

Parameters

$seed

Returns

array —

private key, public key

crypto_sign()

crypto_sign(  $msg,   $mlen,   $secretkey) : \FieldElement

Signs a message using the signer's private key and returns the signed message.

Parameters

$msg
$mlen
$secretkey

Returns

\FieldElement

signed message

crypto_sign_open()

crypto_sign_open(  $signedmsg,   $smlen,   $publickey) : mixed

Verifies the signature of a signed message using signer's publickey.

Parameters

$signedmsg
$smlen
$publickey

Returns

mixed

decodeInput()

decodeInput(  $value) : \FieldElement

Get bytes presentation from a value.

Parameters

$value

Returns

\FieldElement

onetimeauth()

onetimeauth(  $msg,   $key) : \FieldElement

Authenticates a message using a secret key.

Parameters

$msg
$key

Returns

\FieldElement

16 bytes authenticator

onetimeauth_verify()

onetimeauth_verify(  $mac,   $msg,   $secretkey) : boolean

Check if $mac is a correct authenticator of a message under a secret key.

Parameters

$mac
$msg
$secretkey

Returns

boolean

secretbox()

secretbox(  $msg,   $nonce,   $key) : \FieldElement

Encrypts and authenticates a message using a secret key and a nonce.

Parameters

$msg
$nonce
$key

Returns

\FieldElement

secretbox_open()

secretbox_open(  $ciphertext,   $nonce,   $key) : \FieldElement

Verifies and decrypts a chipertext using a secret key and a nonce.

Parameters

$ciphertext
$nonce
$key

Returns

\FieldElement

scalarmult()

scalarmult(  $secretkey,   $publickey) : \FieldElement

Curve25519 scalar multiplication.

Parameters

$secretkey
$publickey

Returns

\FieldElement

scalarmult_base()

scalarmult_base(  $secretkey) : \FieldElement

Curve25519 scalar base multiplication.

Parameters

$secretkey

Returns

\FieldElement

box()

box(  $msg,   $secretkey,   $publickey,   $nonce) : \FieldElement

Encrypts and authenticates a message using sender's secret key, receiver's public key and a nonce.

Parameters

$msg
$secretkey
$publickey
$nonce

Returns

\FieldElement

chipertext

box_open()

box_open(  $ciphertext,   $secretkey,   $publickey,   $nonce) : \FieldElement

Decrypts a chipertext using the receiver's secret key, sender's public key and a nonce.

Parameters

$ciphertext
$secretkey
$publickey
$nonce

Returns

\FieldElement

the message

box_keypair()

box_keypair() : array

Generates a secret key and a corresponding public key.

Returns

array —

secret key, public key

sign()

sign(  $msg,   $secretkey) : \FieldElement

Signs a message using the signer's private key and returns the signature.

Parameters

$msg
$secretkey

Returns

\FieldElement

64 byte signature

sign_verify()

sign_verify(  $msg,   $signature,   $publickey) : boolean

Verifies the signature of a message using signer's publickey.

Parameters

$msg
$signature
$publickey

Returns

boolean

sign_keypair()

sign_keypair(  $seed = null) : array

Generates a secret key and a corresponding public key.

Parameters

$seed

Returns

array —

secret key, public key

encrypt()

encrypt(  $input,   $data,   $nonce,   $secretkey) : \FieldElement

Chacha20Poly1305 AEAD encryption.

Parameters

$input
$data
$nonce
$secretkey

Returns

\FieldElement

ciphertext

decrypt()

decrypt(  $ciphertext,   $data,   $nonce,   $secretkey) : \FieldElement

Chacha20Poly1305 AEAD decryption.

Parameters

$ciphertext
$data
$nonce
$secretkey

Returns

\FieldElement

the message

hash()

hash(  $str,   $key = null) : \FieldElement

Generate hash value using Blake2b.

Parameters

$str
$key

Returns

\FieldElement

64 byte