This application describes the APDU messages interface to communicate with the CPChain application.
The application covers the following functionalities :
-
Retrieve a public CPChain address given a BIP 32 path
-
Sign a basic CPChain transaction given a BIP 32 path
-
Sign a message given given a BIP 32 path
The application interface can be accessed over HID
This command returns the public key and CPChain address for the given BIP 32 path.
The address can be optionally checked on the device before being returned.
Command
CLA |
INS |
P1 |
P2 |
Lc |
Le |
E0 |
02 |
00 : return address 01 : display address and confirm before returning |
00 : do not return the chain code 01 : return the chain code |
variable |
variable |
Input data
Description |
Length |
Number of BIP 32 derivations to perform (max 10) |
1 |
First derivation index (big endian) |
4 |
… |
4 |
Last derivation index (big endian) |
4 |
Output data
Description |
Length |
Public Key length |
1 |
Uncompressed Public Key |
var |
CPChain address length |
1 |
CPChain address |
var |
Chain code if requested |
32 |
This command signs a CPChain transaction after having the user validate the following parameters
-
Gas price
-
Gas limit
-
Recipient address
-
Value
The input data is the RLP encoded transaction, without v/r/s present, streamed to the device in 255 bytes maximum data chunks.
Command
CLA |
INS |
P1 |
P2 |
Lc |
Le |
E0 |
04 |
00 : first transaction data block 80 : subsequent transaction data block |
00 |
variable |
variable |
Input data (first transaction data block)
Description |
Length |
Number of BIP 32 derivations to perform (max 10) |
1 |
First derivation index (big endian) |
4 |
… |
4 |
Last derivation index (big endian) |
4 |
RLP transaction chunk |
variable |
Input data (other transaction data block)
Description |
Length |
RLP transaction chunk |
variable |
Output data
Description |
Length |
v |
1 |
r |
32 |
s |
32 |
This command signs a CPChain message following the personal_sign specification after having the user validate the SHA-256 hash of the message being signed.
The input data is the message to sign, streamed to the device in 255 bytes maximum data chunks
Command
CLA |
INS |
P1 |
P2 |
Lc |
Le |
E0 |
08 |
00 : first message data block 80 : subsequent message data block |
00 |
variable |
variable |
Input data (first message data block)
Description |
Length |
Number of BIP 32 derivations to perform (max 10) |
1 |
First derivation index (big endian) |
4 |
… |
4 |
Last derivation index (big endian) |
4 |
Message length |
4 |
Message chunk |
variable |
Input data (other transaction data block)
Description |
Length |
Message chunk |
variable |
Output data
Description |
Length |
v |
1 |
r |
32 |
s |
32 |
Ledger APDUs requests and responses are encapsulated using a flexible protocol allowing to fragment large payloads over different underlying transport mechanisms.
The common transport header is defined as follows :
Description |
Length |
Communication channel ID (big endian) |
2 |
Command tag |
1 |
Packet sequence index (big endian) |
2 |
Payload |
var |
The Communication channel ID allows commands multiplexing over the same physical link. It is not used for the time being, and should be set to 0101 to avoid compatibility issues with implementations ignoring a leading 00 byte.
The Command tag describes the message content. Use TAG_APDU (0x05) for standard APDU payloads, or TAG_PING (0x02) for a simple link test.
The Packet sequence index describes the current sequence for fragmented payloads. The first fragment index is 0x00.
APDU Command payloads are encoded as follows :
Description |
Length |
APDU length (big endian) |
2 |
APDU CLA |
1 |
APDU INS |
1 |
APDU P1 |
1 |
APDU P2 |
1 |
APDU length |
1 |
Optional APDU data |
var |
APDU payload is encoded according to the APDU case
Case Number |
Lc |
Le |
Case description |
1 |
0 |
0 |
No data in either direction - L is set to 00 |
2 |
0 |
!0 |
Input Data present, no Output Data - L is set to Lc |
3 |
!0 |
0 |
Output Data present, no Input Data - L is set to Le |
4 |
!0 |
!0 |
Both Input and Output Data are present - L is set to Lc |
APDU Response payloads are encoded as follows :
Description |
Length |
APDU response length (big endian) |
2 |
APDU response data and Status Word |
var |
The following standard Status Words are returned for all APDUs - some specific Status Words can be used for specific commands and are mentioned in the command description.
Status Words
SW |
Description |
6700 |
Incorrect length |
6982 |
Security status not satisfied (Canceled by user) |
6A80 |
Invalid data |
6B00 |
Incorrect parameter P1 or P2 |
6Fxx |
Technical problem (Internal error, please report) |
9000 |
Normal ending of the command |