Skip to main content
Version: Next

Hash of Keys

It is often desirable to hash a public key. In Michelson, certain data structures, such as maps, will not allow the use of the key type. Even if this were not the case, hashes are much smaller than keys, and storage on blockchains comes at a premium cost. You can hash keys with the predefined function Crypto.hash_key returning a value of type key_hash.

const check_hash_key = (kh1: key_hash, k2: key) => {
let kh2 = Crypto.hash_key(k2);
return [kh1 == kh2, kh2];
};