Skip to main content

RSASSAPSS

Overview​

License: MIT​

library RSASSAPSS

Cryptography module

This library provides functionality to verify RSASSA-PSS signatures with MGF1 mask generation function.

Users may provide custom hash functions via Parameters struct. However, the usage of sha256 is recommended. The RSASSA-PSS signature verification costs ~340k gas.

Learn more about the algorithm here.

Structs info​

Parameters​

struct Parameters {
uint256 hashLength;
uint256 saltLength;
function (bytes) pure returns (bytes) hasher;
}

The RSASSA-PSS parameters.

Parameters:

NameTypeDescription
hashLengthuint256the hash function output length in bytes.
saltLengthuint256the pss encoding salt length in bytes.
hasherfunction (bytes) pure returns (bytes)the function-pointer to a custom hash function.

Functions info​

verifySha256​

function verifySha256(
bytes memory message_,
bytes memory s_,
bytes memory e_,
bytes memory n_
) internal view returns (bool)

Same as verify but with sha256 hash function preconfiguration.

verify​

function verify(
RSASSAPSS.Parameters memory params_,
bytes memory message_,
bytes memory s_,
bytes memory e_,
bytes memory n_
) internal view returns (bool)

Verifies RSAPSS-SSA signature with custom parameters.

Parameters:

NameTypeDescription
params_struct RSASSAPSS.ParametersThe parameters to specify the hash length, salt length, and hash function of choice.
message_bytesThe arbitrary message to be verified.
s_bytesThe "encrypted" signature
e_bytesThe public key exponent. 65537 is a recommended value.
n_bytesThe modulus of a public key.