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")
For details about the different address types and their cryptographic schemes, see Address Types.
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 signingmessage
with the private key corresponding to the public keykey
.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.implicit_account(key_hash: sp.key_hash) → sp.contract[sp.unit]
Return a
sp.contract[unit]
associated to the public key hashkey_hash
.This function treats the implicit account as a smart contract with a "default" entrypoint that accepts
sp.unit
and does nothing. This allows you to send tez to implicit accounts usingsp.transfer
.To get the
sp.address
address associated to asp.key_hash
you can do:smartpyaddress = sp.to_address(sp.implicit_account(key_hash))
Related function
To check if an address is an implicit account and get its key hash, you can use
sp.is_implicit_account
.