Skip to content
On this page

Keys and signatures

Keys

On Tezos, each tz address is determined by hashing a public key. Public keys are of type sp.key and can be defined with sp.key(). For example, sp.key("edpkv3w95AcgCWQeoYm5szaEqXX71JkZ261s4wjH1NYRtibX879rDv")

Signatures

Keys can be used to sign data off-chain. For more details on this process, see Test accounts. The type sp.signature represents a digital signature.

sp.check_signature(key: sp.key, signature: sp.signature, message: sp.bytes) → sp.bool

Determine whether the signature signature has been produced by signing message with the private key corresponding to the public key key.

TIP

message is often built by packing a packable value. For example, message=sp.pack(sp.record(x=42))

Key hashes

The type sp.key_hash represents the hash of a public key. It can be defined with sp.key_hash(). For example, sp.key_hash("tz1h4EsGunH2Ue1T2uNs8mfKZ8XZoQji3HcK"). Key hashes are similar to tz addresses and only differ by their type.

sp.hash_key(key: sp.key) → sp.key_hash

Return the key hash of a public key key.

sp.implicit_account(key_hash: sp.key_hash) → sp.contract[sp.unit]

Return a sp.contract[unit] associated to the public key hash key_hash.

To get the sp.address address associated to a sp.key_hash you can do:

smartpy
address = sp.to_address(sp.implicit_account(key_hash))