Skip to content

feat(node): accept a TronLink signature (TIP-191 signMessageV2) on a transaction - #24

Merged
MehranMazhar merged 1 commit into
mainfrom
feat/tronlink-signature
Oct 6, 2026
Merged

MehranMazhar merged 1 commit into
mainfrom
feat/tronlink-signature

Conversation

@MehranMazhar

Copy link
Copy Markdown
Member

What this changes

The node now accepts a third signature on a transaction: the one TronLink makes. This is a consensus change.

TronLink will not sign a bare hash. It signs a text with signMessageV2 (TIP-191). That is personal_sign with the prefix \x19TRON Signed Message:\n in place of \x19Ethereum Signed Message:\n. A TRON account is the same kind of key as an Ethereum key: the same curve, the same Keccak-256 and the same 20 address bytes. TRON only writes the address in base58 with a 0x41 prefix. So a TronLink account is already a valid Clutch account, and only the digest is new.

Scheme Signed by Digest
1 the SDK's own key, the treasury, the faucet Keccak256(hash string) (unchanged)
2 MetaMask, Trust Wallet Keccak256("\x19Ethereum Signed Message:\n" + len + "clutch-tx:{chain_id}:{hash}") (unchanged)
3 (new) TronLink Keccak256("\x19TRON Signed Message:\n" + len + "clutch-tx:{chain_id}:{hash}")

Each scheme has its own digest, so one cannot pass for another. The text names the chain, and verify_hash ties the hash to chain_id, so a signature cannot move to another chain or another transaction. The wire format and the hash do not change. Block, authority and mint-cosignature checks are untouched.

Rollout rule: a node without this build rejects a block that carries a TronLink transaction, so every validator must run it before the first TronLink transaction. Nothing sends one until the Hub API, SDK and demo app release that follows this PR.

Tests (by name in CI)

  • tron_sign_bytes_has_the_tip191_layout, the_tron_and_ethereum_digests_of_one_text_differ
  • a_signature_tronweb_made_verifies: the signature comes from TronWeb 6.5.1 itself (trx.signMessageV2, the library TronLink wraps), not from this code. I also checked the digest layout with a second library (@noble) before I wrote the Rust.
  • verify_signature_accepts_a_tronlink_signature, …_the_sign_tron_helper, …_the_signature_tronweb_made
  • refused: …_rejects_a_tronlink_signature_for_another_chain, …_from_another_key, …_for_another_transaction, and verify_signature_accepts_each_prefix_and_no_other (a prefix the node does not know is refused)
  • whole path (pool, authored block, balance): a_tronlink_signed_transfer_is_accepted_and_applied, a_tronlink_signature_made_for_another_chain_is_refused

Not in this PR

The Hub API login, the SDK signer and the demo app. They follow in clutch-hub, after this build is live on stage.

🤖 Generated with Claude Code

…transaction

TronLink will not sign a bare hash either. It signs a text with signMessageV2
(TIP-191). That is personal_sign with the prefix "\x19TRON Signed Message:\n"
in place of the Ethereum one. The key, the curve, the Keccak-256 and the 20
address bytes are the same as for an Ethereum key, so a TronLink account is a
Clutch account already. TRON only writes the address in base58.

Transaction::verify_signature now accepts a third scheme, next to the
hash-string signature and the personal_sign one:

  Keccak256("\x19TRON Signed Message:\n" + len + "clutch-tx:{chain_id}:{hash}")

Each scheme has its own digest, so one cannot pass for another, and the text
names the chain. The wire format and the hash do not change.

This is a consensus change. A node without it rejects a block that carries a
TronLink transaction, so every validator must run this build first.

Tests: the layout of tron_sign_bytes; a signature made by TronWeb 6.5.1 itself
(the library TronLink wraps) verifies, and does not verify under the other
prefix; the transaction cases for chain, key, transaction and an unknown
prefix; two whole-path tests (pool, block, balance) in
tests/wallet_signature.rs.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@MehranMazhar
MehranMazhar merged commit d0c3d0a into main Oct 6, 2026
5 checks passed
@MehranMazhar
MehranMazhar deleted the feat/tronlink-signature branch October 6, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant