TIP-191, much like EIP-191 in Ethereum, defines a standard for signing messages in the Tron network. The protocol is designed to allow users to sign plain messages in a way that can be securely verified. This includes specifying how messages should be formatted and signed to ensure they are distinguishable from transactions and other types of data. The TIP-191 standard does not involve complex structures like JSON or detailed data typing as in EIP-712. Instead, it focuses on the secure signing of simpler, plain-text messages. Here’s how it generally works:Documentation Index
Fetch the complete documentation index at: https://fireblocks-43c4b3ee-chore-add-cli.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
- Message Formatting: The message to be signed is typically prepared with a specific prefix to distinguish it from transaction data. This prefix is crucial to prevent certain types of attacks where signed data could be misused.
- Prefixing the Message: Similar to EIP-191, a common practice in message signing under TIP-191 would involve adding a prefix that clarifies the message is a signed message and not part of a transaction. The prefix often used in Ethereum (and likely a similar approach in Tron) is
"\x19Tron Signed Message:\n", where\x19serves as a control character to differentiate the data. - Hashing: Once the message is concatenated with the prefix, it is hashed using a cryptographic hash function, typically
SHA-256. This hash ensures that the message is converted into a fixed-length, unique data set. - Signing: The resulting hash is then signed using the private key of the signer’s Tron wallet. Tron also uses ECDSA for digital signatures, similar to Bitcoin and Ethereum.
Tron Typed Message Signing In Fireblocks:
Below you can find a TypeScript SDK example for TIP191 Typed Message Signing. This is very similar to Ethereum and Bitcoin while the main differences are theassetId and the type of the message:
Structuring The Signature:
The final signature is just the concatenatedr, s and v values of the signature, prefixed with 0x while the returned v (integer) is 0/1 ( 1 byte in hex so 00 /01) or the same as EVM signature structuring:
Validating The Signature:
In the example below we are usingverifyMessageV2() from the TronWeb JS library: