Cryptographic Signatures
The signature
type is used for Tezos signatures (edsig,
spsig). Signatures are created by casting a string. Beware of failure
if the signature is invalid.
Here is how you can define a signature:
const my_sig: signature =
"edsigthTzJ8X7MPmNeEwybRAvdxS1pupqcM5Mk4uCuyZAe7uEk68YpuGDeViW8wSXMrCi5CwoNgqs8V2w8ayB5dMJzrYCHhD8C7" as
signature;
Checking
Sometimes a contract will want to check that a message has been signed
by a particular key. For example, a point-of-sale system might want a
customer to sign a transaction so it can be processed
asynchronously. You can do this in LIGO using the key
and
signature
types.
⚠️ There is no way to generate a signed message in LIGO. This is because that would require storing a private key on chain, at which point it is not... private anymore.
const check_signature =
(pk: key, signed: signature, msg: bytes) =>
Crypto.check(pk, signed, msg);