Skip to main content
Zondax Github LinkZondax Github Link

Filecoin App

General structure​

The general structure of commands and responses is as follows:

Commands​

FieldTypeContentNote
CLAbyte (1)Application Identifier0x06
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​

GET_VERSION​

Command​

FieldTypeContentExpected
CLAbyte (1)Application Identifier0x06
INSbyte (1)Instruction ID0x00
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
SW1-SW2byte (2)Return codesee list of return codes

INS_GET_ADDR_SECP256K1​

Command​

FieldTypeContentExpected
CLAbyte (1)Application Identifier0x06
INSbyte (1)Instruction ID0x01
P1byte (1)Request User confirmationNo = 0 / Yes = 1
P2byte (1)Parameter 2ignored
Lbyte (1)Bytes in payload(depends)
Path[0]byte (4)Derivation Path Data0x8000002c (44')
Path[1]byte (4)Derivation Path Data0x800001cd (461')
Path[2]byte (4)Derivation Path Data?
Path[3]byte (4)Derivation Path Data?
Path[4]byte (4)Derivation Path Data?

Response​

FieldTypeContentNote
PKbyte (65)Public Key
ADDR_B_LENbyte (1)ADDR_B LengthSpecs
ADDR_Bbyte (??)Address as Bytes
ADDR_S_LENbyte (1)ADDR_S LenSpecs
ADDR_Sbyte (??)Address as String
SW1-SW2byte (2)Return codesee list of return codes

INS_SIGN_SECP256K1​

Command​

FieldTypeContentExpected
CLAbyte (1)Application Identifier0x06
INSbyte (1)Instruction ID0x02
P1byte (1)Payload desc0 = init
1 = add
2 = last
P2byte (1)----not used
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
Path[0]byte (4)Derivation Path Data0x8000002c (44')
Path[1]byte (4)Derivation Path Data0x800001cd (461')
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..CBOR data to sign

Response​

FieldTypeContentNote
secp256k1 Rbyte (32)Signature
secp256k1 Sbyte (32)Signature
secp256k1 Vbyte (1)Signature
SIGbyte (variable)SignatureDER format
SW1-SW2byte (2)Return codesee list of return codes

INS_SIGN_RAW_BYTES​

Command​

FieldTypeContentExpected
CLAbyte (1)Application Identifier0x06
INSbyte (1)Instruction ID0x07
P1byte (1)Payload desc0 = init
1 = add
2 = last
P2byte (1)----not used
Lbyte (1)Bytes in payload(depends)

The first packet/chunk includes only the derivation path

All other packets/chunks contain raw data chunks

First Packet

FieldTypeContentExpected
Path[0]byte (4)Derivation Path Data0x8000002c (44')
Path[1]byte (4)Derivation Path Data0x800001cd (461')
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
Data sizebyte (4)Size of msg to sign?
Databytes...Raw data

Response​

FieldTypeContentNote
secp256k1 Rbyte (32)Signature
secp256k1 Sbyte (32)Signature
secp256k1 Vbyte (1)Signature
SIGbyte (variable)SignatureDER format
SW1-SW2byte (2)Return codesee list of return codes

INS_SIGN_PERSONAL_MESSAGE​

Command​

FieldTypeContentExpected
CLAbyte (1)Application Identifier0x06
INSbyte (1)Instruction ID0x08
P1byte (1)Payload desc0 = init
1 = add
2 = last
P2byte (1)----not used
Lbyte (1)Bytes in payload(depends)

The first packet/chunk includes only the derivation path

All other packets/chunks contain message data chunks

First Packet

FieldTypeContentExpected
Path[0]byte (4)Derivation Path Data0x8000002c (44')
Path[1]byte (4)Derivation Path Data0x800001cd (461')
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
Data sizebyte (4)Size of msg to sign?
Databytes...Personal Message

Response​

FieldTypeContentNote
secp256k1 Vbyte (1)Signature
secp256k1 Rbyte (32)Signature
secp256k1 Sbyte (32)Signature
SW1-SW2byte (2)Return codesee list of return codes

ETH INSTRUCTIONS​

For eth instructions the derivation path length can vary between 3 and 5 elements.

INS_GET_ADDR_ETH​

Command​

FieldTypeContentExpected
CLAbyte (1)Application Identifier0xE0
INSbyte (1)Instruction ID0x02
P1byte (1)Request User confirmationNo = 0 / Yes = 1
P2byte (1)Chain codeno chain code - 0x0 / chain code - 0x01
Lbyte (1)Bytes in payload(depends)
Path[0]byte (4)Derivation Path Data0x8000002c (44')
Path[1]byte (4)Derivation Path Data0x8000003c (60')
Path[2]byte (4)Derivation Path Data?
Path[3]byte (4)Derivation Path Data?
Path[4]byte (4)Derivation Path Data?

Response​

FieldTypeContentNote
PK LENbytePublic Key Len
PKbyte (??)Public Key
ADDR LENbyteAddress Len
ADDRbyte (??)addressHex representation of eth address
SW1-SW2byte (2)Return codesee list of return codes

INS_SIGN_ETH​

Command​

FieldTypeContentExpected
CLAbyte (1)Application Identifier0xE0
INSbyte (1)Instruction ID0x04
P1byte (1)Payload desc0 = init
1 = add
2 = last
P2byte (1)----not used
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
Path[0]byte (4)Derivation Path Data0x8000002c (44')
Path[1]byte (4)Derivation Path Data0x8000003c (60')
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
Messagebytes...Message to Sign

Response​

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

INS_SIGN_PERSONAL_MESSAGE​

Command​

FieldTypeContentExpected
CLAbyte (1)Application Identifier0xE0
INSbyte (1)Instruction ID0x08
P1byte (1)Payload desc0x0 = first
0x80 = more
P2byte (1)----not used
Lbyte (1)Bytes in the payload(depends)

The first packet/chunk includes the derivation path but it can also include some bytes of the message to be signed.

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

First Packet​
FieldTypeContentExpected
Path[0]byte (4)Derivation Path Data0x8000002c (44')
Path[1]byte (4)Derivation Path Data0x8000003c (60')
Path[2]byte (4)Derivation Path Data?
Path[3]byte (4)Derivation Path Data?
Path[4]byte (4)Derivation Path Data?
Msg sizebyte (4)Size of msg to sign?
Msgbytes...Msg to Sign
Other Chunks/Packets​
FieldTypeContentExpected
Msgbytes...Msg to Sign

Response​

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