5.4 KiB
id | title | description | hide_table_of_contents |
---|---|---|---|
crypto-reference | Crypto | Cryptographic operations | true |
import Syntax from '@theme/Syntax'; import SyntaxTitle from '@theme/SyntaxTitle';
type key type key type keyA public cryptographic key.
type key_hash type key_hash type key_hashThe hash of a public cryptographic key.
type signature type signature type signatureA cryptographic signature.
function blake2b : bytes -> bytes val blake2b : bytes -> bytes let blake2b: bytes => bytesRuns the blake2b hash algorithm
over the given bytes
data and returns a bytes
representing the hash.
function hasherman_blake (const s: bytes) : bytes is Crypto.blake2b(s)
Note that
blake2b
is deprecated. Please useCrypto.blake2b
.
let hasherman_blake (s: bytes) : bytes = Crypto.blake2b s
let hasherman_blake = (s: bytes) => Crypto.blake2b(s);
function sha256 : bytes -> bytes
val sha256 : bytes -> bytes
let sha256: bytes => bytes
Runs the sha256 hash algorithm over the given
bytes
data and returns a bytes
representing the hash.
function hasherman (const s : bytes) : bytes is Crypto.sha256(s)
Note that
sha_256
is deprecated. Please useCrypto.sha256
.
let hasherman (s : bytes) : bytes =
Crypto.sha256 s
let hasherman = (s: bytes): bytes => Crypto.sha256(s);
function sha512 : bytes -> bytes
val sha512 : bytes -> bytes
let sha512: bytes => bytes
Runs the sha512 hash algorithm over the given
bytes
data and returns a bytes
representing the hash.
function hasherman512 (const s: bytes) : bytes is Crypto.sha512(s)
Note that
sha_512
is deprecated. Please useCrypto.sha512
.
let hasherman512 (s: bytes) : bytes = Crypto.sha512 s
let hasherman512 = (s: bytes) => Crypto.sha512(s);
function hash_key : key -> key_hash
val hash_key : key -> key_hash
let hash_key: key => key_hash
Hashes a key for easy comparison and storage.
function check_hash_key (const kh1 : key_hash; const k2 : key) : bool * key_hash is block {
var ret : bool := False ;
var kh2 : key_hash := Crypto.hash_key(k2) ;
if kh1 = kh2 then ret := True else skip;
} with (ret, kh2)
Note that
hash_key
is deprecated. Please useCrypto.hash_key
.
let check_hash_key (kh1, k2: key_hash * key) : bool * key_hash =
let kh2 : key_hash = Crypto.hash_key k2 in
if kh1 = kh2
then (true, kh2)
else (false, kh2)
let check_hash_key = ((kh1, k2): (key_hash, key)) : (bool, key_hash) => {
let kh2 : key_hash = Crypto.hash_key(k2);
if (kh1 == kh2) {
(true, kh2);
}
else {
(false, kh2);
}
};
function check : key -> signature -> bytes -> bool
val check : key -> signature -> bytes -> bool
let check: (key, signature, 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
(const pk: key;
const signed: signature;
const msg: bytes) : bool
is Crypto.check(pk, signed, msg)
Note that
crypto_check
is deprecated. Please useCrypto.check
.
let check_signature (pk, signed, msg: key * signature * bytes) : bool =
Crypto.check pk signed msg
let check_signature = ((pk, signed, msg): (key, signature, bytes)) : bool => {
Crypto.check(pk, signed, msg);
};