From 6eb330345ec15bd06aaa77681150eacf937dafbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Du=C5=A1an=20Plav=C3=A1k?= Date: Wed, 4 Jul 2018 13:52:08 +0200 Subject: [PATCH] Add Cardano currency support (#148) --- protob/messages.proto | 125 ++++++++++++++++++++++++++++++++++++++++++ protob/types.proto | 21 +++++++ 2 files changed, 146 insertions(+) diff --git a/protob/messages.proto b/protob/messages.proto index 48afb6ea5..458c411e9 100644 --- a/protob/messages.proto +++ b/protob/messages.proto @@ -100,6 +100,21 @@ enum MessageType { MessageType_DebugLinkMemoryWrite = 112 [(wire_debug_in) = true]; MessageType_DebugLinkFlashErase = 113 [(wire_debug_in) = true]; + + // Cardano + MessageType_CardanoSignMessage = 300 [(wire_in) = true]; + MessageType_CardanoMessageSignature = 301 [(wire_out) = true]; + MessageType_CardanoVerifyMessage = 302 [(wire_in) = true]; + MessageType_CardanoSignTransaction = 303 [(wire_in) = true]; + MessageType_CardanoTxRequest = 304 [(wire_out) = true]; + MessageType_CardanoGetPublicKey = 305 [(wire_in) = true]; + MessageType_CardanoPublicKey = 306 [(wire_out) = true]; + MessageType_CardanoGetAddress = 307 [(wire_in) = true]; + MessageType_CardanoAddress = 308 [(wire_out) = true]; + MessageType_CardanoTxAck = 309 [(wire_in) = true]; + MessageType_CardanoSignedTransaction = 310 [(wire_out) = true]; + + // Lisk MessageType_LiskGetAddress = 114 [(wire_in) = true]; MessageType_LiskAddress = 115 [(wire_out) = true]; @@ -1437,3 +1452,113 @@ message DebugLinkMemoryWrite { message DebugLinkFlashErase { optional uint32 sector = 1; } + +/** + * Request: Ask device for Cardano address + * @next CardanoAddress + * @next Failure + */ + message CardanoGetAddress { + repeated uint32 address_n = 1; // BIP-32-style path to derive the key from master node + optional bool show_display = 2; // optionally prompt for confirmation on trezor display +} + +/** + * Request: Ask device for Cardano address + * @next CardanoAddress + * @next Failure + */ + message CardanoAddress { + optional string address = 1; // Base58 cardano address +} + +/** + * Request: Ask device to sign Cardano message + * @next CardanoMessageSignature + * @next Failure + */ +message CardanoSignMessage { + repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node + optional bytes message = 2; // message to be signed +} + +/** + * Request: Ask device for public key corresponding to address_n path + * @next CardanoPublicKey + * @next Failure + */ + message CardanoGetPublicKey { + repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node +} + +/** + * Response: Contains public key derived from device private seed + * @prev CardanoGetPublicKey + */ + message CardanoPublicKey { + optional string xpub = 1; // Xpub key + optional HDNodeType node = 2; // BIP-32 public node + optional string root_hd_passphrase = 3; // Hd passphrase for root in hex format +} + +/** + * Request: Ask device to verify Cardano message + * @next Success + * @next Failure + */ +message CardanoVerifyMessage { + optional bytes public_key = 1; // Public key which was used to sign message + optional bytes signature = 2; // signature to verify + optional bytes message = 3; // message to verify +} + +/** + * Response: Signed Cardano message + * @prev CardanoSignMessage + */ +message CardanoMessageSignature { + optional bytes public_key = 1; // public key which was used to sign mesage + optional bytes signature = 2; // signature of the message +} + +/** + * Request: Ask device to sign Cardano transaction + * @next CardanoSignedTransaction + * @next CardanoTxRequest + * @next Failure + */ +message CardanoSignTransaction { + repeated CardanoTxInputType inputs = 1; // inputs to be used in transaction + repeated CardanoTxOutputType outputs = 2; // outputs to be used in transaction + optional uint32 transactions_count = 3; // transactions count +} + +/** + * Response: Serialised signed cardano transaction if tx_index is not specified. + * If tx_index is specified, trezor will wait for transaction + * @prev CardanoSignTransaction + * @next CardanoTxAck + */ +message CardanoTxRequest { + optional uint32 tx_index = 1; // index of requested transaction + optional bytes tx_hash = 2; // hash of the signed transaction + optional bytes tx_body = 3; // serialised body of the signed transaction +} + +/** + * Response: Serialised signed cardano transaction + * @prev CardanoSignTransaction + */ +message CardanoSignedTransaction { + optional bytes tx_hash = 1; // hash of the signed transaction + optional bytes tx_body = 2; // serialised body of the signed transaction +} + +/** + * Request: Reported transaction data + * @prev CardanoTxRequest + * @next CardanoTxRequest + */ + message CardanoTxAck { + optional bytes transaction = 1; +} diff --git a/protob/types.proto b/protob/types.proto index 00d6a7f1f..cd820fce3 100644 --- a/protob/types.proto +++ b/protob/types.proto @@ -511,3 +511,24 @@ message LiskMultisignatureType { optional uint32 life_time = 2; repeated string keys_group = 3; } + +/** + * Structure representing cardano transaction input + * @used_in CardanoSignTransacion + */ +message CardanoTxInputType { + repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node + optional bytes prev_hash = 2; // hash of previous transaction output to spend by this input + optional uint32 prev_index = 3; // index of previous output to spend + optional uint32 type = 4; // input type, defaults to 0 +} + +/** + * Structure representing cardano transaction output + * @used_in CardanoSignTransacion + */ +message CardanoTxOutputType { + optional string address = 1; // target coin address in Base58 encoding + repeated uint32 address_n = 2; // BIP-32 path to derive the key from master node; has higher priority than "address" + optional uint64 amount = 3; // amount to spend +}