Skip to content

Instantly share code, notes, and snippets.

@krigga
Created June 14, 2023 20:35
Show Gist options
  • Save krigga/5b3041b3139c42f02b5b7f8a171922b2 to your computer and use it in GitHub Desktop.
Save krigga/5b3041b3139c42f02b5b7f8a171922b2 to your computer and use it in GitHub Desktop.
TON Ledger app communication protocol changes
  • The SIGN_MSG command (INS 0x07) was completely removed. There isn't a standard for this in TON and therefore it was deemed of little use.
  • Address display flags for the GET_PUBLIC_KEY (INS 0x05) command were changed. The non-bounceable flag was removed and other flags were right-shifted by 1 bit, so it was 0x01 - unbounceable, 0x02 - testnet, 0x04 - masterchain, and now it's 0x01 - testnet, 0x02 - masterchain.
  • The SIGN_TX command (INS 0x06) no longer uses P1, and it must be set to 0. Instead, all auxiliary information is carried by P2. Flag 0x01 in P2 means that it's the first chunk, and 0x02 means that there are more chunks coming, so the first chunk containing the BIP32 path must have P2 = 0x03 (first & more, more is mandatory since BIP32 must not be the only info for the SIGN_TX), the following chunks must have P2 = 0x02 (more), except for the last one, which must have P2 = 0x00 (if there is only one chunk after the BIP32 one, that second chunk must have P2 = 0x00). The chunk structure need not be changed, only the P1 and P2.
  • A new command, GET_ADDRESS_PROOF (INS 0x08) was added, and is meant to generate address proof in TON Connect 2.0 compliant format. Here's its spec: https://github.com/ton-blockchain/ledger-app-ton/blob/develop/doc/COMMANDS.md#get_address_proof
  • A new error status word (SW) was added, SW_REQUEST_TOO_LONG (0xB00B)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment