Signatures โ
The type of signatures in SmartPy is sp.TSignature.
The corresponding type in Michelson is
See reference Signatures and State Channels.
Operations โ
Check signature โ
sp.check_signature(<public_key>,ย <signature>,ย <original_content_bytes>)
Determine whether the signature s
(a sp.TSignature value) has been produced by signing b
(a sp.TBytes value) with the private key corresponding to k
(a sp.TKey public key value).
Example โ
k = sp.key("edpkuBknW28nW72KG6RoHtYW7p12T6GKc7nAbwYX5m8Wd9sDVC9yav")
s = sp.signature("edsigu3QszDjUpeqYqbvhyRxMpVFamEnvm9FYnt7YiiNt9nmjYfh8ZTbsybZ5WnBkhA7zfHsRVyuTnRsGLR6fNHt1Up1FxgyRtF")
b = sp.bytes("0x00aabb")
sp.check_signature(k, s, b)
Make signature โ
sp.make_signature(secret_key, message,ย message_formatย =ย 'Raw')
Forge a signature compatible with sp.check_signature(...)
; the message
is a sp.TBytes value (usually the result of an sp.pack
call), the message_format
can also be "Hex"
in which case the message will be interpreted as an hexadecimal string.
Example โ
sp.make_signature(
"edskRq1xuW7TCYzdFm1JQLi1Hz4MNDVP6ukQHVEEh3bVqyuzv7pXXjaGsXZuMbwtd3kQFp3LQ7GQzkLeprNEijKhQKzsxrYrUz",
sp.bytes("0x00aabb"),
message_format = 'Raw'
)
sp.make_signature
is not available for compilation to Michelson as a smart contract cannot manipulate secret keys.
It can only be used in Tests and Scenarios.