Skip to main content
Zondax Github LinkZondax Github Link
Theme SwitchTheme Switch

Algorand 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
0x8000Success

Command definition

GET_VERSION

Command

FieldTypeContentExpected
CLAbyte (1)Application Identifier0x80
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 (2)Version Major0..65535
MINORbyte (2)Version Minor0..65535
PATCHbyte (2)Version Patch0..65535
LOCKEDbyte (1)Device is locked
SW1-SW2byte (2)Return codesee list of return codes

INS_GET_PUBLIC_KEY

Command

FieldTypeContentExpected
CLAbyte (1)Application Identifier0x80
INSbyte (1)Instruction ID0x03
P1byte (1)Request User confirmationNo = 0
P2byte (1)Parameter 2ignored
LCbyte (1)Bytes in payload(depends)
Payloadbyte (4)Account ID(depends)

The account number is used to derive keys from BIP32 path 44'/283'/<account>'/0/0 (note that the account number is hardened as shown by the ' sign). Account number defaults to 0x0 in the case of APDU with empty payload.

Response

FieldTypeContentNote
PublicKeybyte (65)Public Key
Addressbyte (58)Address
SW1-SW2byte (2)Return codesee list of return codes

INS_SIGN_MSGPACK

Command

FieldTypeContentExpected
CLAbyte (1)Application Identifier0x80
INSbyte (1)Instruction ID0x08
P1byte (1)Request User confirmation(depends)
P2byte (1)Parameter 2(depends)
LCbyte (1)Bytes in payload(depends)
Payloadbyte (var)AccID + MsgPack Chunks(depends)

If one single APDU may contain a whole transaction, P1 and P2 are both 0x00.

New format enhances messaging with an optional account number that must be inserted in the first chunk of the sequence. As an optional payload, bit 0 of field P1 in the first chunk must be set if present in the message.

And as for INS_GET_PUBLIC_KEY instruction, it is a big-endian encoded 32-bit unsigned integer word.

The resulting sequence of chunks is as follows:

First APDU message

CLAINSP1P2LCPayload
0x800x080x010x80N1account + MsgPack chunk #1

...

APDU message i

CLAINSP1P2LCPayload
0x800x080x800x80NiMsgPack chunk #i

...

Last APDU message

CLAINSP1P2LCPayload
0x800x080x800x00NIMsgPack chunk #I

Response

FieldTypeContentNote
Signaturebyte (64)Signed message
SW1-SW2byte (2)Return codesee list of return codes

If one signle APDU is needed for the whole transaction along with the account number, P1 and P2 are 0x01 and 0x00 respectively.

CLAINSP1P2LCPayload
0x800x080x010x00N1account + MsgPack txn

If the account number is not inserted within the message, the former message format is used (P1 in the first chunk is 0x00) and the account number defaults to 0x00 for the transaction signature.

CLAINSP1P2LCPayload
0x800x080x000x00N1MsgPack txn