From ed0813682c5909e201129c5462b4eea0a48947de Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Thu, 24 Oct 2013 19:29:11 +0200 Subject: [PATCH] protobuf files cleanup --- {protobuf => protob}/build.sh | 0 {protobuf => protob}/trezor.proto | 213 +++++++++++++++--------------- 2 files changed, 107 insertions(+), 106 deletions(-) rename {protobuf => protob}/build.sh (100%) rename {protobuf => protob}/trezor.proto (58%) diff --git a/protobuf/build.sh b/protob/build.sh similarity index 100% rename from protobuf/build.sh rename to protob/build.sh diff --git a/protobuf/trezor.proto b/protob/trezor.proto similarity index 58% rename from protobuf/trezor.proto rename to protob/trezor.proto index 089a53a..168d718 100644 --- a/protobuf/trezor.proto +++ b/protob/trezor.proto @@ -1,8 +1,8 @@ /* - This file describes Protocol buffers messages for bitcoin hardware wallet devices. - + Messages for TREZOR communication + Author: Marek Palatinus - + Version: 0.5 */ @@ -12,45 +12,45 @@ import "google/protobuf/descriptor.proto"; Mapping between Trezor wire identifier (int) and protobuf message */ enum MessageType { - MessageType_Initialize = 0; - MessageType_Ping = 1; - MessageType_Success = 2; - MessageType_Failure = 3; - MessageType_ChangePin = 4; - MessageType_WipeDevice = 5; - MessageType_FirmwareErase = 6; - MessageType_FirmwareUpload = 7; - MessageType_GetEntropy = 9; - MessageType_Entropy = 10; - MessageType_GetMasterPublicKey = 11; - MessageType_MasterPublicKey = 12; - MessageType_LoadDevice = 13; - MessageType_ResetDevice = 14; - MessageType_SignTx = 15; - MessageType_SimpleSignTx = 16; - MessageType_Features = 17; - MessageType_PinMatrixRequest = 18; - MessageType_PinMatrixAck = 19; - MessageType_PinMatrixCancel = 20; - MessageType_TxRequest = 21; - MessageType_TxInput = 23; - MessageType_TxOutput = 24; - MessageType_ApplySettings = 25; - MessageType_ButtonRequest = 26; - MessageType_ButtonAck = 27; - MessageType_ButtonCancel = 28; - MessageType_GetAddress = 29; - MessageType_Address = 30; - MessageType_SettingsType = 31; - MessageType_XprvType = 32; - MessageType_CoinType = 33; - MessageType_XpubType = 34; - MessageType_EntropyRequest = 35; - MessageType_EntropyAck = 36; - MessageType_DebugLinkDecision = 100; - MessageType_DebugLinkGetState = 101; - MessageType_DebugLinkState = 102; - MessageType_DebugLinkStop = 103; + MessageType_Initialize = 0; + MessageType_Ping = 1; + MessageType_Success = 2; + MessageType_Failure = 3; + MessageType_ChangePin = 4; + MessageType_WipeDevice = 5; + MessageType_FirmwareErase = 6; + MessageType_FirmwareUpload = 7; + MessageType_GetEntropy = 9; + MessageType_Entropy = 10; + MessageType_GetMasterPublicKey = 11; + MessageType_MasterPublicKey = 12; + MessageType_LoadDevice = 13; + MessageType_ResetDevice = 14; + MessageType_SignTx = 15; + MessageType_SimpleSignTx = 16; + MessageType_Features = 17; + MessageType_PinMatrixRequest = 18; + MessageType_PinMatrixAck = 19; + MessageType_PinMatrixCancel = 20; + MessageType_TxRequest = 21; + MessageType_TxInput = 23; + MessageType_TxOutput = 24; + MessageType_ApplySettings = 25; + MessageType_ButtonRequest = 26; + MessageType_ButtonAck = 27; + MessageType_ButtonCancel = 28; + MessageType_GetAddress = 29; + MessageType_Address = 30; + MessageType_SettingsType = 31; + MessageType_XprvType = 32; + MessageType_CoinType = 33; + MessageType_XpubType = 34; + MessageType_EntropyRequest = 35; + MessageType_EntropyAck = 36; + MessageType_DebugLinkDecision = 100; + MessageType_DebugLinkGetState = 101; + MessageType_DebugLinkState = 102; + MessageType_DebugLinkStop = 103; } // Such option indicates that the message field has binary payload @@ -75,16 +75,16 @@ enum FailureType { Failure_FirmwareError = 99; } -// Specifies which script will be used for given transaction output. +// Specifies which script will be used for given transaction output. enum ScriptType { - PAYTOADDRESS = 0; - PAYTOSCRIPTHASH = 1; -} + PAYTOADDRESS = 0; + PAYTOSCRIPTHASH = 1; +} // Specifies which kind of information is required by transaction signing process enum RequestType { - TXINPUT = 0; - TXOUTPUT = 1; + TXINPUT = 0; + TXOUTPUT = 1; } // Structure for BIP32-encoded node @@ -116,7 +116,7 @@ message CoinType { } message SettingsType { - optional bytes language = 1; // Trezor uses 'english' as default + optional bytes language = 1; // Trezor uses 'english' as default optional CoinType coin = 2; optional bytes label = 3; // Human readable wallet name } @@ -134,15 +134,15 @@ message Initialize { // Response object for Initialize. message Features { - optional bytes vendor = 1; // Name of the manufacturer, e.g. "bitcointrezor.com" - optional uint32 major_version = 2; // Major version of the device, e.g. 1 - optional uint32 minor_version = 3; // Minor version of the device, e.g. 0 - optional uint32 bugfix_version = 4; - optional bool bootloader_mode = 5; - optional SettingsType settings = 6; // User-level settings of the device - optional bytes device_id = 7 [(binary) = true]; // Device's unique identifier - optional bytes mpk_hash = 8 [(binary) = true]; // Hash of master public key (sha256(XpubType.public_key).digest()) - optional bool pin_protection = 9; // True if Trezor is covered by PIN + optional bytes vendor = 1; // Name of the manufacturer, e.g. "bitcointrezor.com" + optional uint32 major_version = 2; // Major version of the device, e.g. 1 + optional uint32 minor_version = 3; // Minor version of the device, e.g. 0 + optional uint32 bugfix_version = 4; + optional bool bootloader_mode = 5; + optional SettingsType settings = 6; // User-level settings of the device + optional bytes device_id = 7 [(binary) = true]; // Device's unique identifier + optional bytes mpk_hash = 8 [(binary) = true]; // Hash of master public key (sha256(XpubType.public_key).digest()) + optional bool pin_protection = 9; // True if Trezor is covered by PIN } // Overwrites only filled fields of the structure @@ -155,25 +155,25 @@ message ApplySettings { // Starts workflow for setting/changing the PIN // Response: ButtonRequest, PinMatrixRequest message ChangePin { - optional bool remove = 1; // Set True if want to remove PIN protection + optional bool remove = 1; // Set True if want to remove PIN protection } // Test if device is live, device will send back the message on success // // Response: None or Success message Ping { - optional bytes message = 1; // Message will be sent back in Success message + optional bytes message = 1; // Message will be sent back in Success message } // Response object defining success of the previous request message Success { - optional bytes message = 1; // May contain human readable description of the action or request-specific payload + optional bytes message = 1; // May contain human readable description of the action or request-specific payload } // Response object defining failure of the previous request message Failure { - optional FailureType code = 1; // May contain computer-readable definition of the error state - optional bytes message = 2; // May contain human-readable message of the error state + optional FailureType code = 1; // May contain computer-readable definition of the error state + optional bytes message = 2; // May contain human-readable message of the error state } // Message can be sent by the *device* as a resopnse to any request. @@ -190,18 +190,18 @@ message ButtonAck { // Computer want to cancel current action (don't wait to HW button press) message ButtonCancel { } - + // Message can be sent by the *device* as a response to any request. // Message asks computer to send back PinMatrixAck with the password encoded in pin matrix scheme. // // Response: PinMatrixAck, PinMatrixCancel message PinMatrixRequest { - optional bytes message = 1; // Human readable message + optional bytes message = 1; // Human readable message } // Message is sent by the computer as a response to PinMatrixRequest previously sent by the device. message PinMatrixAck { - required bytes pin = 1; // User must write down the password for accessing the device. + required bytes pin = 1; // User must write down the password for accessing the device. } // Message is sent as a response to PinMatrixRequest by the computer, asking the device to cancel @@ -214,12 +214,12 @@ message PinMatrixCancel { // // Response: PinMatrixRequest, Entropy, Failure message GetEntropy { - required uint32 size = 1; // Size of randomly generated buffer + required uint32 size = 1; // Size of randomly generated buffer } // Response to GetEntropy request contains random data generated by internal HRNG. message Entropy { - required bytes entropy = 1 [(binary) = true]; // Stream of generated bytes + required bytes entropy = 1 [(binary) = true]; // Stream of generated bytes } // Ask device for it's current master public key. This may be used for generating @@ -232,15 +232,15 @@ message GetMasterPublicKey { // Contains master public key derived from device's seed. message MasterPublicKey { - required XpubType mpk = 1; // BIP32 node public key + chaincode + required XpubType mpk = 1; // BIP32 node public key + chaincode } message GetAddress { - repeated uint32 address_n = 1; // Parameter for address generation algorithm to derive the address from the master public key + repeated uint32 address_n = 1; // Parameter for address generation algorithm to derive the address from the master public key } message Address { - required bytes address = 1; // Bitcoin address in base58 encoding corresponding to GetAddress(n) call + required bytes address = 1; // Bitcoin address in base58 encoding corresponding to GetAddress(n) call } // Request device to wipe all sensitive data and settings. @@ -254,22 +254,23 @@ message WipeDevice { // // Response: Success, ButtonRequest, PinMatrixRequest, Failure message LoadDevice { - optional bytes seed = 1; // Seed encoded as a mnemonic (12 english words) - optional XprvType xprv = 2; - optional bytes pin = 3; // Set PIN protection for important actions + optional bytes seed = 1; // Seed encoded as a mnemonic (12 english words) + optional XprvType xprv = 2; + optional bytes pin = 3; // Set PIN protection for important actions } // Request device to do full-reset, to generate new seed // and ask user for new settings (PIN). // Workflow is splitted into ResetDevice/EntropyRequest to be sure // that entropy provided by device isn't calculated on base of computer provided -// entropy. +// entropy. +// // -// // Response: EntropyRequest, PinMatrixRequest, Failure message ResetDevice { - optional bool display_random = 1; // If set, displays entropy generated by the device used - // for generating the seed *before* asking for additional entropy from computer + optional bool display_random = 1; // If set, displays entropy generated by the device used + // for generating the seed *before* asking + // for additional entropy from computer } // Asks for additional Entropy from host computer @@ -290,15 +291,15 @@ message EntropyAck { // // Response: TxRequest, PinMatrixRequest, Failure message SignTx { - required uint32 outputs_count = 3; // Count of outputs of the transaction - required uint32 inputs_count = 5; // Count of inputs of the transaction + required uint32 outputs_count = 3; // Count of outputs of the transaction + required uint32 inputs_count = 5; // Count of inputs of the transaction } // Request a simplified workflow of signing. // This method doesn't support streaming, // so there may be hardware limits // in number of inputs and outputs. -// +// // This simplified workflow should not be used // in production, it is designed mainly for debug purposes. // @@ -307,42 +308,42 @@ message SignTx { // // Response: Success, PinMatrixRequest, Failure message SimpleSignTx { - repeated TxInput inputs = 1; - repeated TxOutput outputs = 2; + repeated TxInput inputs = 1; + repeated TxOutput outputs = 2; } // Sent by the device as a response for SignTx. Device asks for information for signing transaction. // If request_index is set, device asks for TxInput/TxOutput message (depends on request_type) // with details of index's input. -// If signed_index is set, 'signature' contains signed input of signed_index's input. +// If signed_index is set, 'signature' contains signed input of signed_index's input. message TxRequest { - optional int32 request_index = 1; // If >=0, device expects TxInput/TxOutput message from the computer - optional RequestType request_type = 2; // Ask for TxInput or TxOutput? - optional int32 signed_index = 3; // If >=0, 'signature' contains signed input of this input + optional int32 request_index = 1; // If >=0, device expects TxInput/TxOutput message from the computer + optional RequestType request_type = 2; // Ask for TxInput or TxOutput? + optional int32 signed_index = 3; // If >=0, 'signature' contains signed input of this input optional bytes signature = 4 [(binary) = true]; // If signed_index>=0, represent signature of the signed_index input - optional bytes serialized_tx = 5 [(binary) = true]; // Part of serialized and signed transaction + optional bytes serialized_tx = 5 [(binary) = true]; // Part of serialized and signed transaction } // Transaction onput for SignTx workflow. It is response to TxRequest message sent by device. // // Response: TxRequest, Failure message TxInput { - required uint32 index = 1; // Position of input in proposed transaction - repeated uint32 address_n = 2; // Parameter for address generation algorithm to derive the address from the master public key - required uint64 amount = 3; // Amount to spend in satoshis. The rest will be used for transaction fees - required bytes prev_hash = 4 [(binary) = true]; // Hash of previous transaction output to spend by this input - required uint32 prev_index = 5; // Index of previous output to spend - optional bytes script_sig = 6 [(binary) = true]; // Script signature + required uint32 index = 1; // Position of input in proposed transaction + repeated uint32 address_n = 2; // Parameter for address generation algorithm to derive the address from the master public key + required uint64 amount = 3; // Amount to spend in satoshis. The rest will be used for transaction fees + required bytes prev_hash = 4 [(binary) = true]; // Hash of previous transaction output to spend by this input + required uint32 prev_index = 5; // Index of previous output to spend + optional bytes script_sig = 6 [(binary) = true]; // Script signature } // Transaction output for SignTx workflow. It is response to TxRequest message sent by the device. message TxOutput { - required uint32 index = 1; // Position of output in proposed transaction - required bytes address = 2; // Target bitcoin address in base58 encoding - repeated uint32 address_n = 3; // Has higher priority than "address". If the output is to myself, specify parameter for address generation algorithm. - required uint64 amount = 4; // Amount to send in satoshis - required ScriptType script_type = 5;// Select output script type - repeated bytes script_args = 6 [(binary) = true]; // Provide additional parameters for the script (its script-depended) + required uint32 index = 1; // Position of output in proposed transaction + required bytes address = 2; // Target bitcoin address in base58 encoding + repeated uint32 address_n = 3; // Has higher priority than "address". If the output is to myself, specify parameter for address generation algorithm. + required uint64 amount = 4; // Amount to send in satoshis + required ScriptType script_type = 5; // Select output script type + repeated bytes script_args = 6 [(binary) = true]; // Provide additional parameters for the script (its script-depended) } // **************************************************************************** @@ -354,7 +355,7 @@ message FirmwareErase { } message FirmwareUpload { - required bytes payload = 1 [(binary) = true]; // Firmware to flash into device + required bytes payload = 1 [(binary) = true]; // Firmware to flash into device } // **************************************************************************** @@ -367,7 +368,7 @@ message FirmwareUpload { // // Response: Success message DebugLinkDecision { - required bool yes_no = 1; // True for "confirm", False for "cancel" + required bool yes_no = 1; // True for "confirm", False for "cancel" } // When sent over debug link connection, computer asks for some internal information of the device. @@ -383,10 +384,10 @@ message DebugLinkGetState { // Response object reflecting device's current state. It can be received only over debug link connection. message DebugLinkState { - optional bytes layout = 1 [(binary) = true]; // Raw buffer of display - optional bytes pin = 2; // Current PIN, blank if PIN is not set/enabled - optional bytes matrix = 3; // Current PIN matrix - optional bytes seed = 4; // Current seed (in mnemonic format) + optional bytes layout = 1 [(binary) = true]; // Raw buffer of display + optional bytes pin = 2; // Current PIN, blank if PIN is not set/enabled + optional bytes matrix = 3; // Current PIN matrix + optional bytes seed = 4; // Current seed (in mnemonic format) // optional bytes state = 5 [(binary) = true]; }