Various math helper functions.
fun checkSignature(hash: Int, signature: Slice, public_key: Int): Bool;
Checks the Ed25519
hash (a 256-bit unsigned integer, usually computed as the hash of some data) using
public_key (also represented by a 256-bit unsigned integer). The signature must contain at least 512 data bits; only the first 512 bits are used. If the signature is valid, the result is true; otherwise, it is false.
CHKSIGNU creates a 256-bit slice with the
hash and calls
CHKSIGNS. That is, if hash is computed as the hash of some data, this data is hashed twice, the second hashing occurring inside
fun checkDataSignature(data: Slice, signature: Slice, public_key: Slice): Bool;
signature is a valid Ed25519 signature of the data portion of
public_key, similarly to
checkSignature. If the bit length of
data is not divisible by eight, it throws a cell underflow exception. The verification of Ed25519 signatures is a standard one, with sha256 used to reduce
data to the 256-bit number that is actually signed. If the signature is valid, the result is true; otherwise, it is false.
fun sha256(data: Slice): Int; fun sha256(data: String): Int;
Computes sha256 of byte-string. The result is a 256-bit unsigned integer. Slice or string must have no refs and have number of bits divisible by 8. Passing constant string computes hash in compile time that could be useful for some optimizations.
fun min(x: Int, y: Int): Int;
Computes the minimum of two integers
fun max(x: Int, y: Int): Int;
Computes the maximum of two integers
fun abs(x: Int): Int
Computes the absolute value of the integer
fun pow(a: Int, b: Int): Int
Computes the exponent