github.com/luckypickle/go-ethereum-vet@v1.14.2/accounts/usbwallet/internal/trezor/messages.proto (about)

     1  // This file originates from the SatoshiLabs Trezor `common` repository at:
     2  //   https://github.com/trezor/trezor-common/blob/master/protob/messages.proto
     3  // dated 28.07.2017, commit dd8ec3231fb5f7992360aff9bdfe30bb58130f4b.
     4  
     5  syntax = "proto2";
     6  
     7  /**
     8   * Messages for TREZOR communication
     9   */
    10  
    11  // Sugar for easier handling in Java
    12  option java_package = "com.satoshilabs.trezor.lib.protobuf";
    13  option java_outer_classname = "TrezorMessage";
    14  
    15  import "types.proto";
    16  
    17  /**
    18   * Mapping between Trezor wire identifier (uint) and a protobuf message
    19   */
    20  enum MessageType {
    21  	MessageType_Initialize = 0 [(wire_in) = true];
    22  	MessageType_Ping = 1 [(wire_in) = true];
    23  	MessageType_Success = 2 [(wire_out) = true];
    24  	MessageType_Failure = 3 [(wire_out) = true];
    25  	MessageType_ChangePin = 4 [(wire_in) = true];
    26  	MessageType_WipeDevice = 5 [(wire_in) = true];
    27  	MessageType_FirmwareErase = 6 [(wire_in) = true, (wire_bootloader) = true];
    28  	MessageType_FirmwareUpload = 7 [(wire_in) = true, (wire_bootloader) = true];
    29  	MessageType_FirmwareRequest = 8 [(wire_out) = true, (wire_bootloader) = true];
    30  	MessageType_GetEntropy = 9 [(wire_in) = true];
    31  	MessageType_Entropy = 10 [(wire_out) = true];
    32  	MessageType_GetPublicKey = 11 [(wire_in) = true];
    33  	MessageType_PublicKey = 12 [(wire_out) = true];
    34  	MessageType_LoadDevice = 13 [(wire_in) = true];
    35  	MessageType_ResetDevice = 14 [(wire_in) = true];
    36  	MessageType_SignTx = 15 [(wire_in) = true];
    37  	MessageType_SimpleSignTx = 16 [(wire_in) = true, deprecated = true];
    38  	MessageType_Features = 17 [(wire_out) = true];
    39  	MessageType_PinMatrixRequest = 18 [(wire_out) = true];
    40  	MessageType_PinMatrixAck = 19 [(wire_in) = true, (wire_tiny) = true];
    41  	MessageType_Cancel = 20 [(wire_in) = true];
    42  	MessageType_TxRequest = 21 [(wire_out) = true];
    43  	MessageType_TxAck = 22 [(wire_in) = true];
    44  	MessageType_CipherKeyValue = 23 [(wire_in) = true];
    45  	MessageType_ClearSession = 24 [(wire_in) = true];
    46  	MessageType_ApplySettings = 25 [(wire_in) = true];
    47  	MessageType_ButtonRequest = 26 [(wire_out) = true];
    48  	MessageType_ButtonAck = 27 [(wire_in) = true, (wire_tiny) = true];
    49  	MessageType_ApplyFlags = 28 [(wire_in) = true];
    50  	MessageType_GetAddress = 29 [(wire_in) = true];
    51  	MessageType_Address = 30 [(wire_out) = true];
    52  	MessageType_SelfTest = 32 [(wire_in) = true, (wire_bootloader) = true];
    53  	MessageType_BackupDevice = 34 [(wire_in) = true];
    54  	MessageType_EntropyRequest = 35 [(wire_out) = true];
    55  	MessageType_EntropyAck = 36 [(wire_in) = true];
    56  	MessageType_SignMessage = 38 [(wire_in) = true];
    57  	MessageType_VerifyMessage = 39 [(wire_in) = true];
    58  	MessageType_MessageSignature = 40 [(wire_out) = true];
    59  	MessageType_PassphraseRequest = 41 [(wire_out) = true];
    60  	MessageType_PassphraseAck = 42 [(wire_in) = true, (wire_tiny) = true];
    61  	MessageType_EstimateTxSize = 43 [(wire_in) = true, deprecated = true];
    62  	MessageType_TxSize = 44 [(wire_out) = true, deprecated = true];
    63  	MessageType_RecoveryDevice = 45 [(wire_in) = true];
    64  	MessageType_WordRequest = 46 [(wire_out) = true];
    65  	MessageType_WordAck = 47 [(wire_in) = true];
    66  	MessageType_CipheredKeyValue = 48 [(wire_out) = true];
    67  	MessageType_EncryptMessage = 49 [(wire_in) = true, deprecated = true];
    68  	MessageType_EncryptedMessage = 50 [(wire_out) = true, deprecated = true];
    69  	MessageType_DecryptMessage = 51 [(wire_in) = true, deprecated = true];
    70  	MessageType_DecryptedMessage = 52 [(wire_out) = true, deprecated = true];
    71  	MessageType_SignIdentity = 53 [(wire_in) = true];
    72  	MessageType_SignedIdentity = 54 [(wire_out) = true];
    73  	MessageType_GetFeatures = 55 [(wire_in) = true];
    74  	MessageType_EthereumGetAddress = 56 [(wire_in) = true];
    75  	MessageType_EthereumAddress = 57 [(wire_out) = true];
    76  	MessageType_EthereumSignTx = 58 [(wire_in) = true];
    77  	MessageType_EthereumTxRequest = 59 [(wire_out) = true];
    78  	MessageType_EthereumTxAck = 60 [(wire_in) = true];
    79  	MessageType_GetECDHSessionKey = 61 [(wire_in) = true];
    80  	MessageType_ECDHSessionKey = 62 [(wire_out) = true];
    81  	MessageType_SetU2FCounter = 63 [(wire_in) = true];
    82  	MessageType_EthereumSignMessage = 64 [(wire_in) = true];
    83  	MessageType_EthereumVerifyMessage = 65 [(wire_in) = true];
    84  	MessageType_EthereumMessageSignature = 66 [(wire_out) = true];
    85  	MessageType_DebugLinkDecision = 100 [(wire_debug_in) = true, (wire_tiny) = true];
    86  	MessageType_DebugLinkGetState = 101 [(wire_debug_in) = true];
    87  	MessageType_DebugLinkState = 102 [(wire_debug_out) = true];
    88  	MessageType_DebugLinkStop = 103 [(wire_debug_in) = true];
    89  	MessageType_DebugLinkLog = 104 [(wire_debug_out) = true];
    90  	MessageType_DebugLinkMemoryRead = 110 [(wire_debug_in) = true];
    91  	MessageType_DebugLinkMemory = 111 [(wire_debug_out) = true];
    92  	MessageType_DebugLinkMemoryWrite = 112 [(wire_debug_in) = true];
    93  	MessageType_DebugLinkFlashErase = 113 [(wire_debug_in) = true];
    94  }
    95  
    96  ////////////////////
    97  // Basic messages //
    98  ////////////////////
    99  
   100  /**
   101   * Request: Reset device to default state and ask for device details
   102   * @next Features
   103   */
   104  message Initialize {
   105  }
   106  
   107  /**
   108   * Request: Ask for device details (no device reset)
   109   * @next Features
   110   */
   111  message GetFeatures {
   112  }
   113  
   114  /**
   115   * Response: Reports various information about the device
   116   * @prev Initialize
   117   * @prev GetFeatures
   118   */
   119  message Features {
   120  	optional string vendor = 1;			// name of the manufacturer, e.g. "bitcointrezor.com"
   121  	optional uint32 major_version = 2;		// major version of the device, e.g. 1
   122  	optional uint32 minor_version = 3;		// minor version of the device, e.g. 0
   123  	optional uint32 patch_version = 4;		// patch version of the device, e.g. 0
   124  	optional bool bootloader_mode = 5;		// is device in bootloader mode?
   125  	optional string device_id = 6;			// device's unique identifier
   126  	optional bool pin_protection = 7;		// is device protected by PIN?
   127  	optional bool passphrase_protection = 8;	// is node/mnemonic encrypted using passphrase?
   128  	optional string language = 9;			// device language
   129  	optional string label = 10;			// device description label
   130  	repeated CoinType coins = 11;			// supported coins
   131  	optional bool initialized = 12;			// does device contain seed?
   132  	optional bytes revision = 13;			// SCM revision of firmware
   133  	optional bytes bootloader_hash = 14;		// hash of the bootloader
   134  	optional bool imported = 15;			// was storage imported from an external source?
   135  	optional bool pin_cached = 16;			// is PIN already cached in session?
   136  	optional bool passphrase_cached = 17;		// is passphrase already cached in session?
   137  	optional bool firmware_present = 18;		// is valid firmware loaded?
   138  	optional bool needs_backup = 19;		// does storage need backup? (equals to Storage.needs_backup)
   139  	optional uint32 flags = 20;			// device flags (equals to Storage.flags)
   140  }
   141  
   142  /**
   143   * Request: clear session (removes cached PIN, passphrase, etc).
   144   * @next Success
   145   */
   146  message ClearSession {
   147  }
   148  
   149  /**
   150   * Request: change language and/or label of the device
   151   * @next Success
   152   * @next Failure
   153   * @next ButtonRequest
   154   * @next PinMatrixRequest
   155   */
   156  message ApplySettings {
   157  	optional string language = 1;
   158  	optional string label = 2;
   159  	optional bool use_passphrase = 3;
   160  	optional bytes homescreen = 4;
   161  }
   162  
   163  /**
   164   * Request: set flags of the device
   165   * @next Success
   166   * @next Failure
   167   */
   168  message ApplyFlags {
   169  	optional uint32 flags = 1;	// bitmask, can only set bits, not unset
   170  }
   171  
   172  /**
   173   * Request: Starts workflow for setting/changing/removing the PIN
   174   * @next ButtonRequest
   175   * @next PinMatrixRequest
   176   */
   177  message ChangePin {
   178  	optional bool remove = 1;	// is PIN removal requested?
   179  }
   180  
   181  /**
   182   * Request: Test if the device is alive, device sends back the message in Success response
   183   * @next Success
   184   */
   185  message Ping {
   186  	optional string message = 1;			// message to send back in Success message
   187  	optional bool button_protection = 2;		// ask for button press
   188  	optional bool pin_protection = 3;		// ask for PIN if set in device
   189  	optional bool passphrase_protection = 4;	// ask for passphrase if set in device
   190  }
   191  
   192  /**
   193   * Response: Success of the previous request
   194   */
   195  message Success {
   196  	optional string message = 1;	// human readable description of action or request-specific payload
   197  }
   198  
   199  /**
   200   * Response: Failure of the previous request
   201   */
   202  message Failure {
   203  	optional FailureType code = 1;	// computer-readable definition of the error state
   204  	optional string message = 2;	// human-readable message of the error state
   205  }
   206  
   207  /**
   208   * Response: Device is waiting for HW button press.
   209   * @next ButtonAck
   210   * @next Cancel
   211   */
   212  message ButtonRequest {
   213  	optional ButtonRequestType code = 1;
   214  	optional string data = 2;
   215  }
   216  
   217  /**
   218   * Request: Computer agrees to wait for HW button press
   219   * @prev ButtonRequest
   220   */
   221  message ButtonAck {
   222  }
   223  
   224  /**
   225   * Response: Device is asking computer to show PIN matrix and awaits PIN encoded using this matrix scheme
   226   * @next PinMatrixAck
   227   * @next Cancel
   228   */
   229  message PinMatrixRequest {
   230  	optional PinMatrixRequestType type = 1;
   231  }
   232  
   233  /**
   234   * Request: Computer responds with encoded PIN
   235   * @prev PinMatrixRequest
   236   */
   237  message PinMatrixAck {
   238  	required string pin = 1;		// matrix encoded PIN entered by user
   239  }
   240  
   241  /**
   242   * Request: Abort last operation that required user interaction
   243   * @prev ButtonRequest
   244   * @prev PinMatrixRequest
   245   * @prev PassphraseRequest
   246   */
   247  message Cancel {
   248  }
   249  
   250  /**
   251   * Response: Device awaits encryption passphrase
   252   * @next PassphraseAck
   253   * @next Cancel
   254   */
   255  message PassphraseRequest {
   256  }
   257  
   258  /**
   259   * Request: Send passphrase back
   260   * @prev PassphraseRequest
   261   */
   262  message PassphraseAck {
   263  	required string passphrase = 1;
   264  }
   265  
   266  /**
   267   * Request: Request a sample of random data generated by hardware RNG. May be used for testing.
   268   * @next ButtonRequest
   269   * @next Entropy
   270   * @next Failure
   271   */
   272  message GetEntropy {
   273  	required uint32 size = 1;		// size of requested entropy
   274  }
   275  
   276  /**
   277   * Response: Reply with random data generated by internal RNG
   278   * @prev GetEntropy
   279   */
   280  message Entropy {
   281  	required bytes entropy = 1;		// stream of random generated bytes
   282  }
   283  
   284  /**
   285   * Request: Ask device for public key corresponding to address_n path
   286   * @next PassphraseRequest
   287   * @next PublicKey
   288   * @next Failure
   289   */
   290  message GetPublicKey {
   291  	repeated uint32 address_n = 1;		// BIP-32 path to derive the key from master node
   292  	optional string ecdsa_curve_name = 2;	// ECDSA curve name to use
   293  	optional bool show_display = 3;		// optionally show on display before sending the result
   294  	optional string coin_name = 4 [default='Bitcoin'];
   295  }
   296  
   297  /**
   298   * Response: Contains public key derived from device private seed
   299   * @prev GetPublicKey
   300   */
   301  message PublicKey {
   302  	required HDNodeType node = 1;		// BIP32 public node
   303  	optional string xpub = 2;		// serialized form of public node
   304  }
   305  
   306  /**
   307   * Request: Ask device for address corresponding to address_n path
   308   * @next PassphraseRequest
   309   * @next Address
   310   * @next Failure
   311   */
   312  message GetAddress {
   313  	repeated uint32 address_n = 1;						// BIP-32 path to derive the key from master node
   314  	optional string coin_name = 2 [default='Bitcoin'];
   315  	optional bool show_display = 3			;			// optionally show on display before sending the result
   316  	optional MultisigRedeemScriptType multisig = 4;				// filled if we are showing a multisig address
   317  	optional InputScriptType script_type = 5 [default=SPENDADDRESS];	// used to distinguish between various address formats (non-segwit, segwit, etc.)
   318  }
   319  
   320  /**
   321   * Request: Ask device for Ethereum address corresponding to address_n path
   322   * @next PassphraseRequest
   323   * @next EthereumAddress
   324   * @next Failure
   325   */
   326  message EthereumGetAddress {
   327  	repeated uint32 address_n = 1;			// BIP-32 path to derive the key from master node
   328  	optional bool show_display = 2;			// optionally show on display before sending the result
   329  }
   330  
   331  /**
   332   * Response: Contains address derived from device private seed
   333   * @prev GetAddress
   334   */
   335  message Address {
   336  	required string address = 1;		// Coin address in Base58 encoding
   337  }
   338  
   339  /**
   340   * Response: Contains an Ethereum address derived from device private seed
   341   * @prev EthereumGetAddress
   342   */
   343  message EthereumAddress {
   344  	required bytes address = 1;		// Coin address as an Ethereum 160 bit hash
   345  }
   346  
   347  /**
   348   * Request: Request device to wipe all sensitive data and settings
   349   * @next ButtonRequest
   350   */
   351  message WipeDevice {
   352  }
   353  
   354  /**
   355   * Request: Load seed and related internal settings from the computer
   356   * @next ButtonRequest
   357   * @next Success
   358   * @next Failure
   359   */
   360  message LoadDevice {
   361  	optional string mnemonic = 1;				// seed encoded as BIP-39 mnemonic (12, 18 or 24 words)
   362  	optional HDNodeType node = 2;				// BIP-32 node
   363  	optional string pin = 3;				// set PIN protection
   364  	optional bool passphrase_protection = 4;		// enable master node encryption using passphrase
   365  	optional string language = 5 [default='english'];	// device language
   366  	optional string label = 6;				// device label
   367  	optional bool skip_checksum = 7;			// do not test mnemonic for valid BIP-39 checksum
   368  	optional uint32 u2f_counter = 8;			// U2F counter
   369  }
   370  
   371  /**
   372   * Request: Ask device to do initialization involving user interaction
   373   * @next EntropyRequest
   374   * @next Failure
   375   */
   376  message ResetDevice {
   377  	optional bool display_random = 1;			// display entropy generated by the device before asking for additional entropy
   378  	optional uint32 strength = 2 [default=256];		// strength of seed in bits
   379  	optional bool passphrase_protection = 3;		// enable master node encryption using passphrase
   380  	optional bool pin_protection = 4;			// enable PIN protection
   381  	optional string language = 5 [default='english'];	// device language
   382  	optional string label = 6;				// device label
   383  	optional uint32 u2f_counter = 7;			// U2F counter
   384  	optional bool skip_backup = 8;				// postpone seed backup to BackupDevice workflow
   385  }
   386  
   387  /**
   388   * Request: Perform backup of the device seed if not backed up using ResetDevice
   389   * @next ButtonRequest
   390   */
   391  message BackupDevice {
   392  }
   393  
   394  /**
   395   * Response: Ask for additional entropy from host computer
   396   * @prev ResetDevice
   397   * @next EntropyAck
   398   */
   399  message EntropyRequest {
   400  }
   401  
   402  /**
   403   * Request: Provide additional entropy for seed generation function
   404   * @prev EntropyRequest
   405   * @next ButtonRequest
   406   */
   407  message EntropyAck {
   408  	optional bytes entropy = 1;				// 256 bits (32 bytes) of random data
   409  }
   410  
   411  /**
   412   * Request: Start recovery workflow asking user for specific words of mnemonic
   413   * Used to recovery device safely even on untrusted computer.
   414   * @next WordRequest
   415   */
   416  message RecoveryDevice {
   417  	optional uint32 word_count = 1;				// number of words in BIP-39 mnemonic
   418  	optional bool passphrase_protection = 2;		// enable master node encryption using passphrase
   419  	optional bool pin_protection = 3;			// enable PIN protection
   420  	optional string language = 4 [default='english'];	// device language
   421  	optional string label = 5;				// device label
   422  	optional bool enforce_wordlist = 6;			// enforce BIP-39 wordlist during the process
   423  	// 7 reserved for unused recovery method
   424  	optional uint32 type = 8;				// supported recovery type (see RecoveryType)
   425  	optional uint32 u2f_counter = 9;			// U2F counter
   426  	optional bool dry_run = 10;				// perform dry-run recovery workflow (for safe mnemonic validation)
   427  }
   428  
   429  /**
   430   * Response: Device is waiting for user to enter word of the mnemonic
   431   * Its position is shown only on device's internal display.
   432   * @prev RecoveryDevice
   433   * @prev WordAck
   434   */
   435  message WordRequest {
   436  	optional WordRequestType type = 1;
   437  }
   438  
   439  /**
   440   * Request: Computer replies with word from the mnemonic
   441   * @prev WordRequest
   442   * @next WordRequest
   443   * @next Success
   444   * @next Failure
   445   */
   446  message WordAck {
   447  	required string word = 1;				// one word of mnemonic on asked position
   448  }
   449  
   450  //////////////////////////////
   451  // Message signing messages //
   452  //////////////////////////////
   453  
   454  /**
   455   * Request: Ask device to sign message
   456   * @next MessageSignature
   457   * @next Failure
   458   */
   459  message SignMessage {
   460  	repeated uint32 address_n = 1;						// BIP-32 path to derive the key from master node
   461  	required bytes message = 2;						// message to be signed
   462  	optional string coin_name = 3 [default='Bitcoin'];			// coin to use for signing
   463  	optional InputScriptType script_type = 4 [default=SPENDADDRESS];	// used to distinguish between various address formats (non-segwit, segwit, etc.)
   464  }
   465  
   466  /**
   467   * Request: Ask device to verify message
   468   * @next Success
   469   * @next Failure
   470   */
   471  message VerifyMessage {
   472  	optional string address = 1;				// address to verify
   473  	optional bytes signature = 2;				// signature to verify
   474  	optional bytes message = 3;				// message to verify
   475  	optional string coin_name = 4 [default='Bitcoin'];	// coin to use for verifying
   476  }
   477  
   478  /**
   479   * Response: Signed message
   480   * @prev SignMessage
   481   */
   482  message MessageSignature {
   483  	optional string address = 1;				// address used to sign the message
   484  	optional bytes signature = 2;				// signature of the message
   485  }
   486  
   487  ///////////////////////////
   488  // Encryption/decryption //
   489  ///////////////////////////
   490  
   491  /**
   492   * Request: Ask device to encrypt message
   493   * @next EncryptedMessage
   494   * @next Failure
   495   */
   496  message EncryptMessage {
   497  	optional bytes pubkey = 1;				// public key
   498  	optional bytes message = 2;				// message to encrypt
   499  	optional bool display_only = 3;				// show just on display? (don't send back via wire)
   500  	repeated uint32 address_n = 4;				// BIP-32 path to derive the signing key from master node
   501  	optional string coin_name = 5 [default='Bitcoin'];	// coin to use for signing
   502  }
   503  
   504  /**
   505   * Response: Encrypted message
   506   * @prev EncryptMessage
   507   */
   508  message EncryptedMessage {
   509  	optional bytes nonce = 1;				// nonce used during encryption
   510  	optional bytes message = 2;				// encrypted message
   511  	optional bytes hmac = 3;				// message hmac
   512  }
   513  
   514  /**
   515   * Request: Ask device to decrypt message
   516   * @next Success
   517   * @next Failure
   518   */
   519  message DecryptMessage {
   520  	repeated uint32 address_n = 1;				// BIP-32 path to derive the decryption key from master node
   521  	optional bytes nonce = 2;				// nonce used during encryption
   522  	optional bytes message = 3;				// message to decrypt
   523  	optional bytes hmac = 4;				// message hmac
   524  }
   525  
   526  /**
   527   * Response: Decrypted message
   528   * @prev DecryptedMessage
   529   */
   530  message DecryptedMessage {
   531  	optional bytes message = 1;				// decrypted message
   532  	optional string address = 2;				// address used to sign the message (if used)
   533  }
   534  
   535  /**
   536   * Request: Ask device to encrypt or decrypt value of given key
   537   * @next CipheredKeyValue
   538   * @next Failure
   539   */
   540  message CipherKeyValue {
   541  	repeated uint32 address_n = 1;		// BIP-32 path to derive the key from master node
   542  	optional string key = 2;		// key component of key:value
   543  	optional bytes value = 3;		// value component of key:value
   544  	optional bool encrypt = 4;		// are we encrypting (True) or decrypting (False)?
   545  	optional bool ask_on_encrypt = 5;	// should we ask on encrypt operation?
   546  	optional bool ask_on_decrypt = 6;	// should we ask on decrypt operation?
   547  	optional bytes iv = 7;			// initialization vector (will be computed if not set)
   548  }
   549  
   550  /**
   551   * Response: Return ciphered/deciphered value
   552   * @prev CipherKeyValue
   553   */
   554  message CipheredKeyValue {
   555  	optional bytes value = 1;		// ciphered/deciphered value
   556  }
   557  
   558  //////////////////////////////////
   559  // Transaction signing messages //
   560  //////////////////////////////////
   561  
   562  /**
   563   * Request: Estimated size of the transaction
   564   * This behaves exactly like SignTx, which means that it can ask using TxRequest
   565   * This call is non-blocking (except possible PassphraseRequest to unlock the seed)
   566   * @next TxSize
   567   * @next Failure
   568   */
   569  message EstimateTxSize {
   570  	required uint32 outputs_count = 1;			// number of transaction outputs
   571  	required uint32 inputs_count = 2;			// number of transaction inputs
   572  	optional string coin_name = 3 [default='Bitcoin'];	// coin to use
   573  }
   574  
   575  /**
   576   * Response: Estimated size of the transaction
   577   * @prev EstimateTxSize
   578   */
   579  message TxSize {
   580  	optional uint32 tx_size = 1;				// estimated size of transaction in bytes
   581  }
   582  
   583  /**
   584   * Request: Ask device to sign transaction
   585   * @next PassphraseRequest
   586   * @next PinMatrixRequest
   587   * @next TxRequest
   588   * @next Failure
   589   */
   590  message SignTx {
   591  	required uint32 outputs_count = 1;			// number of transaction outputs
   592  	required uint32 inputs_count = 2;			// number of transaction inputs
   593  	optional string coin_name = 3 [default='Bitcoin'];	// coin to use
   594  	optional uint32 version = 4 [default=1];		// transaction version
   595  	optional uint32 lock_time = 5 [default=0];		// transaction lock_time
   596  }
   597  
   598  /**
   599   * Request: Simplified transaction signing
   600   * This method doesn't support streaming, so there are hardware limits in number of inputs and outputs.
   601   * In case of success, the result is returned using TxRequest message.
   602   * @next PassphraseRequest
   603   * @next PinMatrixRequest
   604   * @next TxRequest
   605   * @next Failure
   606   */
   607  message SimpleSignTx {
   608  	repeated TxInputType inputs = 1;			// transaction inputs
   609  	repeated TxOutputType outputs = 2;			// transaction outputs
   610  	repeated TransactionType transactions = 3;		// transactions whose outputs are used to build current inputs
   611  	optional string coin_name = 4 [default='Bitcoin'];	// coin to use
   612  	optional uint32 version = 5 [default=1];		// transaction version
   613  	optional uint32 lock_time = 6 [default=0];		// transaction lock_time
   614  }
   615  
   616  /**
   617   * Response: Device asks for information for signing transaction or returns the last result
   618   * If request_index is set, device awaits TxAck message (with fields filled in according to request_type)
   619   * If signature_index is set, 'signature' contains signed input of signature_index's input
   620   * @prev SignTx
   621   * @prev SimpleSignTx
   622   * @prev TxAck
   623   */
   624  message TxRequest {
   625  	optional RequestType request_type = 1;			// what should be filled in TxAck message?
   626  	optional TxRequestDetailsType details = 2;		// request for tx details
   627  	optional TxRequestSerializedType serialized = 3;	// serialized data and request for next
   628  }
   629  
   630  /**
   631   * Request: Reported transaction data
   632   * @prev TxRequest
   633   * @next TxRequest
   634   */
   635  message TxAck {
   636  	optional TransactionType tx = 1;
   637  }
   638  
   639  /**
   640   * Request: Ask device to sign transaction
   641   * All fields are optional from the protocol's point of view. Each field defaults to value `0` if missing.
   642   * Note: the first at most 1024 bytes of data MUST be transmitted as part of this message.
   643   * @next PassphraseRequest
   644   * @next PinMatrixRequest
   645   * @next EthereumTxRequest
   646   * @next Failure
   647   */
   648  message EthereumSignTx {
   649  	repeated uint32 address_n = 1;			// BIP-32 path to derive the key from master node
   650  	optional bytes nonce = 2;			// <=256 bit unsigned big endian
   651  	optional bytes gas_price = 3;			// <=256 bit unsigned big endian (in wei)
   652  	optional bytes gas_limit = 4;			// <=256 bit unsigned big endian
   653  	optional bytes to = 5;				// 160 bit address hash
   654  	optional bytes value = 6;			// <=256 bit unsigned big endian (in wei)
   655  	optional bytes data_initial_chunk = 7;		// The initial data chunk (<= 1024 bytes)
   656  	optional uint32 data_length = 8;		// Length of transaction payload
   657  	optional uint32 chain_id = 9;			// Chain Id for EIP 155
   658  }
   659  
   660  /**
   661   * Response: Device asks for more data from transaction payload, or returns the signature.
   662   * If data_length is set, device awaits that many more bytes of payload.
   663   * Otherwise, the signature_* fields contain the computed transaction signature. All three fields will be present.
   664   * @prev EthereumSignTx
   665   * @next EthereumTxAck
   666   */
   667  message EthereumTxRequest {
   668  	optional uint32 data_length = 1;		// Number of bytes being requested (<= 1024)
   669  	optional uint32 signature_v = 2;		// Computed signature (recovery parameter, limited to 27 or 28)
   670  	optional bytes signature_r = 3;			// Computed signature R component (256 bit)
   671  	optional bytes signature_s = 4;			// Computed signature S component (256 bit)
   672  }
   673  
   674  /**
   675   * Request: Transaction payload data.
   676   * @prev EthereumTxRequest
   677   * @next EthereumTxRequest
   678   */
   679  message EthereumTxAck {
   680  	optional bytes data_chunk = 1;			// Bytes from transaction payload (<= 1024 bytes)
   681  }
   682  
   683  ////////////////////////////////////////
   684  // Ethereum: Message signing messages //
   685  ////////////////////////////////////////
   686  
   687  /**
   688   * Request: Ask device to sign message
   689   * @next EthereumMessageSignature
   690   * @next Failure
   691   */
   692  message EthereumSignMessage {
   693  	repeated uint32 address_n = 1;				// BIP-32 path to derive the key from master node
   694  	required bytes message = 2;				// message to be signed
   695  }
   696  
   697  /**
   698   * Request: Ask device to verify message
   699   * @next Success
   700   * @next Failure
   701   */
   702  message EthereumVerifyMessage {
   703  	optional bytes address = 1;				// address to verify
   704  	optional bytes signature = 2;				// signature to verify
   705  	optional bytes message = 3;				// message to verify
   706  }
   707  
   708  /**
   709   * Response: Signed message
   710   * @prev EthereumSignMessage
   711   */
   712  message EthereumMessageSignature {
   713  	optional bytes address = 1;				// address used to sign the message
   714  	optional bytes signature = 2;				// signature of the message
   715  }
   716  
   717  ///////////////////////
   718  // Identity messages //
   719  ///////////////////////
   720  
   721  /**
   722   * Request: Ask device to sign identity
   723   * @next SignedIdentity
   724   * @next Failure
   725   */
   726  message SignIdentity {
   727  	optional IdentityType identity = 1;		// identity
   728  	optional bytes challenge_hidden = 2;		// non-visible challenge
   729  	optional string challenge_visual = 3;		// challenge shown on display (e.g. date+time)
   730  	optional string ecdsa_curve_name = 4;		// ECDSA curve name to use
   731  }
   732  
   733  /**
   734   * Response: Device provides signed identity
   735   * @prev SignIdentity
   736   */
   737  message SignedIdentity {
   738  	optional string address = 1;			// identity address
   739  	optional bytes public_key = 2;			// identity public key
   740  	optional bytes signature = 3;			// signature of the identity data
   741  }
   742  
   743  ///////////////////
   744  // ECDH messages //
   745  ///////////////////
   746  
   747  /**
   748   * Request: Ask device to generate ECDH session key
   749   * @next ECDHSessionKey
   750   * @next Failure
   751   */
   752  message GetECDHSessionKey {
   753  	optional IdentityType identity = 1;		// identity
   754  	optional bytes peer_public_key = 2;		// peer's public key
   755  	optional string ecdsa_curve_name = 3;		// ECDSA curve name to use
   756  }
   757  
   758  /**
   759   * Response: Device provides ECDH session key
   760   * @prev GetECDHSessionKey
   761   */
   762  message ECDHSessionKey {
   763  	optional bytes session_key = 1;			// ECDH session key
   764  }
   765  
   766  ///////////////////
   767  // U2F messages //
   768  ///////////////////
   769  
   770  /**
   771   * Request: Set U2F counter
   772   * @next Success
   773   */
   774  message SetU2FCounter {
   775  	optional uint32 u2f_counter = 1;		// counter
   776  }
   777  
   778  /////////////////////////
   779  // Bootloader messages //
   780  /////////////////////////
   781  
   782  /**
   783   * Request: Ask device to erase its firmware (so it can be replaced via FirmwareUpload)
   784   * @next Success
   785   * @next FirmwareRequest
   786   * @next Failure
   787   */
   788  message FirmwareErase {
   789  	optional uint32 length = 1;			// length of new firmware
   790  }
   791  
   792  /**
   793   * Response: Ask for firmware chunk
   794   * @next FirmwareUpload
   795   */
   796  message FirmwareRequest {
   797  	optional uint32 offset = 1;			// offset of requested firmware chunk
   798  	optional uint32 length = 2;			// length of requested firmware chunk
   799  }
   800  
   801  /**
   802   * Request: Send firmware in binary form to the device
   803   * @next Success
   804   * @next Failure
   805   */
   806  message FirmwareUpload {
   807  	required bytes payload = 1;			// firmware to be loaded into device
   808  	optional bytes hash = 2;			// hash of the payload
   809  }
   810  
   811  
   812  /**
   813   * Request: Perform a device self-test
   814   * @next Success
   815   * @next Failure
   816   */
   817  message SelfTest {
   818  	optional bytes payload = 1;			// payload to be used in self-test
   819  }
   820  
   821  /////////////////////////////////////////////////////////////
   822  // Debug messages (only available if DebugLink is enabled) //
   823  /////////////////////////////////////////////////////////////
   824  
   825  /**
   826   * Request: "Press" the button on the device
   827   * @next Success
   828   */
   829  message DebugLinkDecision {
   830  	required bool yes_no = 1;			// true for "Confirm", false for "Cancel"
   831  }
   832  
   833  /**
   834   * Request: Computer asks for device state
   835   * @next DebugLinkState
   836   */
   837  message DebugLinkGetState {
   838  }
   839  
   840  /**
   841   * Response: Device current state
   842   * @prev DebugLinkGetState
   843   */
   844  message DebugLinkState {
   845  	optional bytes layout = 1;			// raw buffer of display
   846  	optional string pin = 2;			// current PIN, blank if PIN is not set/enabled
   847  	optional string matrix = 3;			// current PIN matrix
   848  	optional string mnemonic = 4;			// current BIP-39 mnemonic
   849  	optional HDNodeType node = 5;			// current BIP-32 node
   850  	optional bool passphrase_protection = 6;	// is node/mnemonic encrypted using passphrase?
   851  	optional string reset_word = 7;			// word on device display during ResetDevice workflow
   852  	optional bytes reset_entropy = 8;		// current entropy during ResetDevice workflow
   853  	optional string recovery_fake_word = 9;		// (fake) word on display during RecoveryDevice workflow
   854  	optional uint32 recovery_word_pos = 10;		// index of mnemonic word the device is expecting during RecoveryDevice workflow
   855  }
   856  
   857  /**
   858   * Request: Ask device to restart
   859   */
   860  message DebugLinkStop {
   861  }
   862  
   863  /**
   864   * Response: Device wants host to log event
   865   */
   866  message DebugLinkLog {
   867  	optional uint32 level = 1;
   868  	optional string bucket = 2;
   869  	optional string text = 3;
   870  }
   871  
   872  /**
   873   * Request: Read memory from device
   874   * @next DebugLinkMemory
   875   */
   876  message DebugLinkMemoryRead {
   877  	optional uint32 address = 1;
   878  	optional uint32 length = 2;
   879  }
   880  
   881  /**
   882   * Response: Device sends memory back
   883   * @prev DebugLinkMemoryRead
   884   */
   885  message DebugLinkMemory {
   886  	optional bytes memory = 1;
   887  }
   888  
   889  /**
   890   * Request: Write memory to device.
   891   * WARNING: Writing to the wrong location can irreparably break the device.
   892   */
   893  message DebugLinkMemoryWrite {
   894  	optional uint32 address = 1;
   895  	optional bytes memory = 2;
   896  	optional bool flash = 3;
   897  }
   898  
   899  /**
   900   * Request: Erase block of flash on device
   901   * WARNING: Writing to the wrong location can irreparably break the device.
   902   */
   903  message DebugLinkFlashErase {
   904  	optional uint32 sector = 1;
   905  }