Skip to main content

Tezos App

General structure

The general structure of commands and responses is as follows:

Commands

FieldTypeContentNote
CLAbyte (1)Application Identifier0x80
INSbyte (1)Instruction ID
P1byte (1)Parameter 1
P2byte (1)Parameter 2
Lbyte (1)Bytes in payload
PAYLOADbyte (L)Payload

Response

FieldTypeContentNote
ANSWERbyte (?)Answerdepends on the command
SW1-SW2byte (2)Return codesee list of return codes

Return codes

Return codeDescription
0x6400Execution Error
0x6982Empty buffer
0x6983Output buffer too small
0x6986Command not allowed
0x6D00INS not supported
0x6E00CLA not supported
0x6F00Unknown
0x9000Success

Command definition

GetVersion

Command

FieldTypeContentExpected
CLAbyte (1)Application Identifier0x80
INSbyte (1)Instruction ID0x10
P1byte (1)Parameter 1ignored
P2byte (1)Parameter 2ignored
Lbyte (1)Bytes in payload0

Response

FieldTypeContentNote
TESTbyte (1)Test Mode0xFF means test mode is enabled
MAJORbyte (1)Version Major
MINORbyte (1)Version Minor
PATCHbyte (1)Version Patch
LOCKEDbyte (1)Device is locked
TARGET IDbyte (4)Target ID
SW1-SW2byte (2)Return codesee list of return codes

INS_GET_ADDR

Command

FieldTypeContentExpected
CLAbyte (1)Application Identifier0x80
INSbyte (1)Instruction ID0x11
P1byte (1)Request User confirmationNo = 0
P2byte (1)Curve identifier0 = Ed25519
1 = Secp256K1
2 = Secp256R1
3 = Ed25519 BIP32
Lbyte (1)Bytes in payload(depends)
PathNbyte (1)Number of path components? (typically 4)
Path[0]byte (4)Derivation Path Data0x8000002c
Path[1]byte (4)Derivation Path Data0x800006c1
Path[2]byte (4)Derivation Path Data?
Path[3]byte (4)Derivation Path Data?
Path[4]byte (4)Derivation Path Data?

Response

FieldTypeContentNote
PK_LENbyte (1)Bytes in PKEY
PKEYbyte (??)Public key bytes
ADDR_HUMANbyte (??)Address as Stringencoded with base58
SW1-SW2byte (2)Return codesee list of return codes

INS_SIGN

Command

FieldTypeContentExpected
CLAbyte (1)Application Identifier0x80
INSbyte (1)Instruction ID0x12
P1byte (1)Payload desc0 = init
1 = add
2 = last
P2byte (1)Curve identifier0 = Ed25519
1 = Secp256K1
2 = Secp256R1
3 = Ed25519 BIP32
Lbyte (1)Bytes in payload(depends)

The first packet/chunk includes only the derivation path

All other packets/chunks contain data chunks that are described below

First Packet

FieldTypeContentExpected
PathNbyte (1)Number of path components? (typically 4)
Path[0]byte (4)Derivation Path Data0x8000002c
Path[1]byte (4)Derivation Path Data0x800006c1
Path[2]byte (4)Derivation Path Data?
Path[3]byte (4)Derivation Path Data?
Path[4]byte (4)Derivation Path Data?

Other Chunks/Packets

FieldTypeContentExpected
Databytes...Message

Data is defined as:

FieldTypeContentExpected
Messagebytes..Data to sign

Response

FieldTypeContentNote
SIG_HASHbyte (32)Signed hashBlake2 hash used as signature message
SIGbyte (variable)Signaturesignature
SW1-SW2byte (2)Return codesee list of return codes

INS_AUTHORIZE_BAKING

Command

FieldTypeContentExpected
CLAbyte (1)Application Identifier0x80
INSbyte (1)Instruction ID0xA1
P1byte (1)Request User confirmationYes = 1, mandatory
P2byte (1)Curve identifier0 = Ed25519
1 = Secp256K1
2 = Secp256R1
3 = Ed25519 BIP32
Lbyte (1)Bytes in payload(depends)
PathNbyte (1)Number of path components? (typically 4)
Path[0]byte (4)Derivation Path Data0x8000002c
Path[1]byte (4)Derivation Path Data0x800006c1
Path[2]byte (4)Derivation Path Data?
Path[3]byte (4)Derivation Path Data?
Path[4]byte (4)Derivation Path Data?

Response

FieldTypeContentNote
PK_LENbyte (1)Bytes in PKEY
PKEYbyte (??)Public key bytes
SW1-SW2byte (2)Return codesee list of return codes

INS_DEAUTHORIZE_BAKING

Command

FieldTypeContentExpected
CLAbyte (1)Application Identifier0x80
INSbyte (1)Instruction ID0xAC
P1byte (1)Request User confirmationYes = 1, mandatory
P2byte (1)ignored
Lbyte (1)Bytes in payload0

Response

FieldTypeContentNote
SW1-SW2byte (2)Return codesee list of return codes

INS_QUERY_AUTH_KEY

Command

FieldTypeContentExpected
CLAbyte (1)Application Identifier0x80
INSbyte (1)Instruction ID0xA7
P1byte (1)Request User confirmationNo = 0
P2byte (1)ignored
Lbyte (1)Bytes in payload0

Response

FieldTypeContentNote
PathNbyte (1)Number of path components? (typically 4)
Path[0]byte (4)Derivation Path Data0x8000002c
Path[1]byte (4)Derivation Path Data0x800006c1
Path[2]byte (4)Derivation Path Data?
Path[3]byte (4)Derivation Path Data?
Path[4]byte (4)Derivation Path Data?
SW1-SW2byte (2)Return codesee list of return codes

INS_QUERY_AUTH_KEY_WITH_CURVE

Command

FieldTypeContentExpected
CLAbyte (1)Application Identifier0x80
INSbyte (1)Instruction ID0xAD
P1byte (1)Request User confirmationNo = 0
P2byte (1)ignored
Lbyte (1)Bytes in payload0

Response

FieldTypeContentNote
Curvebyte (1)0 = Ed25519
1 = Secp256K1
2 = Secp256R1
3 = Ed25519 BIP32
PathNbyte (1)Number of path components? (typically 4)
Path[0]byte (4)Derivation Path Data0x8000002c
Path[1]byte (4)Derivation Path Data0x800006c1
Path[2]byte (4)Derivation Path Data?
Path[3]byte (4)Derivation Path Data?
Path[4]byte (4)Derivation Path Data?
SW1-SW2byte (2)Return codesee list of return codes

INS_BAKER_SIGN

Same as INS_SIGN, except the INS field is 0xAF.

The difference lies in the interpretation of the message from the other chunks/packets.

Legacy app

CLA is 0x80

https://github.com/obsidiansystems/ledger-app-tezos/blob/58797b2f9606c5a30dd1ccc9e5b9962e45e10356/src/main.c#L10-L36 https://github.com/obsidiansystems/ledger-app-tezos

// Instruction codes

CommandINS
INS_VERSION0x00
INS_AUTHORIZE_BAKING0x01
INS_GET_PUBLIC_KEY0x02
INS_PROMPT_PUBLIC_KEY0x03
INS_SIGN0x04
INS_SIGN_UNSAFE0x05// Data that is already hashed.
INS_RESET0x06
INS_QUERY_AUTH_KEY0x07
INS_QUERY_MAIN_HWM0x08
INS_GIT0x09
INS_SETUP0x0A
INS_QUERY_ALL_HWM0x0B
INS_DEAUTHORIZE0x0C
INS_QUERY_AUTH_KEY_WITH_CURVE0x0D
INS_HMAC0x0E
INS_SIGN_WITH_HASH0x0F