You can sign a Cell with ton-crypto
or ton-core, and later verify it using check_signature
or check_data_signature
from stdlib.fc
in FunC.
Here's an approximate code snippet that you should review:
sign(yourCell.hash(), keypair.secretKey);
## And in the FunC contract, check like this:
check_signature(cell_hash(your_cell), signature, public_key)
For more details, you can refer to the TON documentation on signature checks.
On the other hand, in Tact language, we also has the same feature in the Smart Contract side like this:
external(msg: ExtMessage) {
let hash: Int = beginCell().storeUint(msg.seqno, 32).storeUint(msg.valid_until, 32).storeRef(msg.message_parameters.toCell()).endCell().hash();
require(checkSignature(hash, msg.signature, self.publicKey), "Invalid Signature"); // 😃😃😃 We checek the hash here
require(msg.seqno == self.seqno, "Invalid Seqno");
require(now() <= msg.valid_until, "Invalid Time");
acceptMessage();
self.seqno = self.seqno + 1;
send(msg.message_parameters);
}