There is a related question, but the differences are still not clear. These five types are mentioned in the Michelson whitedoc with the following definitions:

  • address: An untyped address (implicit account or smart contract).
  • contract 'param: A contract, with the type of its code, contract unit for implicit accounts.
  • key: A public cryptographic key.
  • key_hash: The hash of a public cryptographic key.
  • signature: A cryptographic signature.

    1. What is the difference between key_hash and address? It seems like for both I can do PUSH address "tz1..." and PUSH key_hash "tz1..." using the same string literal. I remember seeing something about reveal. What does reveal mean?

    2. Why can I convert between address and contract. But not between address and key_hash?

    3. What is the difference between key and key_hash? When would I have a key, but not a key_hash?

    4. What is a cryptographic signature and what are some of the use cases in Michelson?

    5. Any other important details about these data types.

2 Answers 2

  1. key_hash is blake2b hash of a public key, in the base58 encoded form it can start only with tz, but address is more general, it can also hold KT accounts;
  2. There are no instructions for that, probably because it's a rare and arguable case; EDIT: as pointed out by Raphaël, you can convert key_hash to contract and then to address using IMPLICIT_ACCOUNT ; ADDRESS
  3. As was mentioned, key_hash is blake2b hash of key. You would need a key for checking a signature for instance;
  4. Allow me to link wikipedia https://en.wikipedia.org/wiki/EdDSA. A bright example is a multisig contract;
  5. Check out the new Michelson documentation https://tezos.gitlab.io/michelson-reference/

To sum up:

  • key represents a public key (a point on the elliptic curve)
  • key_hash is blake2b hash of key
  • address is a general representation of Tezos accounts, including both - tz and KT addresses
  • signature is a result of signing a message with a private key using the elliptic curve digital signature scheme.

Why can I convert between address and contract. But not between address and key_hash?

There is the (IMPLICIT_ACCOUNT) instruction to go from key_hash to address. For the other direction, there was (a feature request) but it was closed because no use case has been presented to motivate it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.