Language
Reference
Math

Math

Various math helper functions.

checkSignature

fun checkSignature(hash: Int, signature: Slice, public_key: Int): Bool;

Checks the Ed25519 signature of 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. Note that 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 CHKSIGNS.

checkDataSignature

fun checkDataSignature(data: Slice, signature: Slice, public_key: Int): Bool;

Checks whether signature is a valid Ed25519 signature of the data portion of data using 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.

sha256

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.

min

fun min(x: Int, y: Int): Int;

Computes the minimum of two integers x and y.

max

fun max(x: Int, y: Int): Int;

Computes the maximum of two integers x and y.

abs

fun abs(x: Int): Int

Computes the absolute value of the integer x.

pow

fun pow(a: Int, b: Int): Int

Computes the exponent b of a.