Skip to main content

Crypto

cameligo

val blake2b : bytes -> bytes

jsligo

let blake2b: (b: bytes) => bytes

Runs the blake2b hash algorithm over the given bytes data and returns a bytes representing the hash.

let hasherman_blake = (s: bytes):bytes => Crypto.blake2b(s);
cameligo

val sha256 : bytes -> bytes

jsligo

let sha256: (b: bytes) => bytes

Runs the sha256 hash algorithm over the given bytes data and returns a bytes representing the hash.

let hasherman = (s: bytes): bytes => Crypto.sha256(s);
cameligo

val sha512 : bytes -> bytes

jsligo

let sha512: (b: bytes) => bytes

Runs the sha512 hash algorithm over the given bytes data and returns a bytes representing the hash.

let hasherman512 = (s: bytes): bytes => Crypto.sha512(s);
cameligo

val sha3 : bytes -> bytes

jsligo

let sha3: (b: bytes) => bytes

Runs the sha3 hash algorithm over the given bytes data and returns a bytes representing the hash.

let hasherman3 = (s: bytes): bytes => Crypto.sha3(s);
cameligo

val keccak : bytes -> bytes

jsligo

let keccak: (b: bytes) => bytes

Runs the keccak over the given bytes data and returns a bytes representing the hash.

let hasherman_keccak = (s: bytes): bytes => Crypto.keccak(s);
cameligo

val hash_key : key -> key_hash

jsligo

let hash_key: (k: key) => key_hash

Hashes a key for easy comparison and storage.

let check_hash_key = (kh1: key_hash, k2: key) : [bool, key_hash] => {
let kh2 : key_hash = Crypto.hash_key(k2);
if (kh1 == kh2) { return [true, kh2]; } else { return [false, kh2]; };
};
cameligo

val check : key -> signature -> bytes -> bool

jsligo

let check: (k: key, s: signature, b: bytes) => bool

Check that a message has been signed by a particular key.

⚠️ There is no way to generate a signed message in LIGO. This is because that would require storing a private key on chain, at which point it isn't very private anymore.

function check_signature (pk: key, signed: signature, msg: bytes) : bool {
return Crypto.check(pk, signed, msg)
};