Skip to main content
Version: v1.2

Hasher

A SHA256 hash function for any number of input elements, and Poseidon hash functions for 2, 3, 4, 5, and 12 input elements.

sha256Hash

function sha256Hash(uint256[] array) public pure returns (uint256 result)

Computes the SHA256 hash of an array of uint256 elements.

Parameters

NameTypeDescription
arrayuint256[]The array of uint256 elements.

Return Values

NameTypeDescription
resultuint256The SHA256 hash of the array.

hash2

function hash2(uint256[2] array) public pure returns (uint256 result)

Computes the Poseidon hash of two uint256 elements.

Parameters

NameTypeDescription
arrayuint256[2]An array of two uint256 elements.

Return Values

NameTypeDescription
resultuint256The Poseidon hash of the two elements.

hash3

function hash3(uint256[3] array) public pure returns (uint256 result)

Computes the Poseidon hash of three uint256 elements.

Parameters

NameTypeDescription
arrayuint256[3]An array of three uint256 elements.

Return Values

NameTypeDescription
resultuint256The Poseidon hash of the three elements.

hash4

function hash4(uint256[4] array) public pure returns (uint256 result)

Computes the Poseidon hash of four uint256 elements.

Parameters

NameTypeDescription
arrayuint256[4]An array of four uint256 elements.

Return Values

NameTypeDescription
resultuint256The Poseidon hash of the four elements.

hash5

function hash5(uint256[5] array) public pure returns (uint256 result)

Computes the Poseidon hash of five uint256 elements.

Parameters

NameTypeDescription
arrayuint256[5]An array of five uint256 elements.

Return Values

NameTypeDescription
resultuint256The Poseidon hash of the five elements.

hashLeftRight

function hashLeftRight(uint256 left, uint256 right) public pure returns (uint256 result)

Computes the Poseidon hash of two uint256 elements.

Parameters

NameTypeDescription
leftuint256the first element to hash.
rightuint256the second element to hash.

Return Values

NameTypeDescription
resultuint256The Poseidon hash of the two elements.