From 576d431058328a61c896e8bc3a09294c72692551 Mon Sep 17 00:00:00 2001 From: matejcik Date: Thu, 14 Jan 2021 12:05:03 +0100 Subject: [PATCH] feat(common): set more fields as required (#1406) --- common/protob/messages-binance.proto | 8 +-- common/protob/messages-bitcoin.proto | 8 +-- common/protob/messages-common.proto | 2 +- common/protob/messages-crypto.proto | 2 +- common/protob/messages-eos.proto | 12 ++--- common/protob/messages-ethereum.proto | 8 +-- common/protob/messages-lisk.proto | 20 ++++---- common/protob/messages-management.proto | 8 +-- common/protob/messages-nem.proto | 6 +-- common/protob/messages-ripple.proto | 10 ++-- common/protob/messages-stellar.proto | 8 +-- common/protob/messages-tezos.proto | 68 ++++++++++++------------- 12 files changed, 80 insertions(+), 80 deletions(-) diff --git a/common/protob/messages-binance.proto b/common/protob/messages-binance.proto index 0483e548a..d02076ff8 100644 --- a/common/protob/messages-binance.proto +++ b/common/protob/messages-binance.proto @@ -21,7 +21,7 @@ message BinanceGetAddress { * @end */ message BinanceAddress { - optional string address = 1; // prefixed bech32 Binance address + required string address = 1; // prefixed bech32 Binance address } /** @@ -39,7 +39,7 @@ message BinanceGetPublicKey { * @end */ message BinancePublicKey { - optional bytes public_key = 1; + required bytes public_key = 1; } /** @@ -141,7 +141,7 @@ message BinanceCancelMsg { * @end */ message BinanceSignedTx { - optional bytes signature = 1; - optional bytes public_key = 2; + required bytes signature = 1; + required bytes public_key = 2; } diff --git a/common/protob/messages-bitcoin.proto b/common/protob/messages-bitcoin.proto index 73021fb30..2bc64026c 100644 --- a/common/protob/messages-bitcoin.proto +++ b/common/protob/messages-bitcoin.proto @@ -80,8 +80,8 @@ message GetPublicKey { * @end */ message PublicKey { - optional common.HDNodeType node = 1; // BIP32 public node - optional string xpub = 2; // serialized form of public node + required common.HDNodeType node = 1; // BIP32 public node + required string xpub = 2; // serialized form of public node optional uint32 root_fingerprint = 3; // master root node fingerprint } @@ -147,8 +147,8 @@ message SignMessage { * @end */ message MessageSignature { - optional string address = 1; // address used to sign the message - optional bytes signature = 2; // signature of the message + required string address = 1; // address used to sign the message + required bytes signature = 2; // signature of the message } /** diff --git a/common/protob/messages-common.proto b/common/protob/messages-common.proto index 7f1fdc43a..2790cf2bc 100644 --- a/common/protob/messages-common.proto +++ b/common/protob/messages-common.proto @@ -10,7 +10,7 @@ option java_outer_classname = "TrezorMessageCommon"; * @end */ message Success { - optional string message = 1; // human readable description of action or request-specific payload + optional string message = 1 [default=""]; // human readable description of action or request-specific payload } /** diff --git a/common/protob/messages-crypto.proto b/common/protob/messages-crypto.proto index 911b8b7db..55a0df479 100644 --- a/common/protob/messages-crypto.proto +++ b/common/protob/messages-crypto.proto @@ -123,5 +123,5 @@ message CosiSign { * @end */ message CosiSignature { - optional bytes signature = 1; // Signature + required bytes signature = 1; // Signature } diff --git a/common/protob/messages-eos.proto b/common/protob/messages-eos.proto index 445098085..1e455164b 100644 --- a/common/protob/messages-eos.proto +++ b/common/protob/messages-eos.proto @@ -21,8 +21,8 @@ message EosGetPublicKey { * @end */ message EosPublicKey { - optional string wif_public_key = 1; // EOS pub key in Base58 encoding - optional bytes raw_public_key = 2; // Raw public key + required string wif_public_key = 1; // EOS pub key in Base58 encoding + required bytes raw_public_key = 2; // Raw public key } /** @@ -101,10 +101,10 @@ message EosTxActionAck { * Structure representing auth key */ message EosAuthorizationKey { - optional uint32 type = 1; + required uint32 type = 1; optional bytes key = 2; // Explicit public key bytes; when present, address_n must be empty repeated uint32 address_n = 3; // BIP-32 path to derive key; when filled out, key must not be present - optional uint32 weight = 4; + required uint32 weight = 4; } /** @@ -266,7 +266,7 @@ message EosTxActionAck { * Structure representing actions not implemented above. */ message EosActionUnknown { - optional uint32 data_size = 1; + required uint32 data_size = 1; optional bytes data_chunk = 2; } } @@ -277,5 +277,5 @@ message EosTxActionAck { * @end */ message EosSignedTx { - optional string signature = 1; // Computed signature + required string signature = 1; // Computed signature } diff --git a/common/protob/messages-ethereum.proto b/common/protob/messages-ethereum.proto index 2a62ce114..9fab13c2c 100644 --- a/common/protob/messages-ethereum.proto +++ b/common/protob/messages-ethereum.proto @@ -24,8 +24,8 @@ message EthereumGetPublicKey { * @end */ message EthereumPublicKey { - optional hw.trezor.messages.common.HDNodeType node = 1; // BIP32 public node - optional string xpub = 2; // serialized form of public node + required hw.trezor.messages.common.HDNodeType node = 1; // BIP32 public node + required string xpub = 2; // serialized form of public node } /** @@ -107,8 +107,8 @@ message EthereumSignMessage { * @end */ message EthereumMessageSignature { - optional bytes signature = 2; // signature of the message - optional string address = 3; // address used to sign the message + required bytes signature = 2; // signature of the message + required string address = 3; // address used to sign the message } /** diff --git a/common/protob/messages-lisk.proto b/common/protob/messages-lisk.proto index b91cd9950..ee7d78083 100644 --- a/common/protob/messages-lisk.proto +++ b/common/protob/messages-lisk.proto @@ -21,7 +21,7 @@ message LiskGetAddress { * @end */ message LiskAddress { - optional string address = 1; // Lisk address + required string address = 1; // Lisk address } /** @@ -39,7 +39,7 @@ message LiskGetPublicKey { * @end */ message LiskPublicKey { - optional bytes public_key = 1; // Lisk public key + required bytes public_key = 1; // Lisk public key } /** @@ -50,7 +50,7 @@ message LiskPublicKey { */ message LiskSignTx { repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node - optional LiskTransactionCommon transaction = 2; // Lisk transaction structure + required LiskTransactionCommon transaction = 2; // Lisk transaction structure /** * Structure representing the common part for Lisk transactions */ @@ -115,7 +115,7 @@ message LiskSignTx { * @end */ message LiskSignedTx { - optional bytes signature = 1; + required bytes signature = 1; } /** @@ -126,7 +126,7 @@ message LiskSignedTx { */ message LiskSignMessage { repeated uint32 address_n = 1; - optional bytes message = 2; + required bytes message = 2; } /** @@ -134,8 +134,8 @@ message LiskSignMessage { * @end */ message LiskMessageSignature { - optional bytes public_key = 1; - optional bytes signature = 2; + required bytes public_key = 1; + required bytes signature = 2; } /** @@ -145,7 +145,7 @@ message LiskMessageSignature { * @next Failure */ message LiskVerifyMessage { - optional bytes public_key = 1; - optional bytes signature = 2; - optional bytes message = 3; + required bytes public_key = 1; + required bytes signature = 2; + required bytes message = 3; } diff --git a/common/protob/messages-management.proto b/common/protob/messages-management.proto index b9f8a61fd..790f400d2 100644 --- a/common/protob/messages-management.proto +++ b/common/protob/messages-management.proto @@ -46,9 +46,9 @@ message GetFeatures { */ message Features { optional string vendor = 1; // name of the manufacturer, e.g. "trezor.io" - optional uint32 major_version = 2; // major version of the firmware/bootloader, e.g. 1 - optional uint32 minor_version = 3; // minor version of the firmware/bootloader, e.g. 0 - optional uint32 patch_version = 4; // patch version of the firmware/bootloader, e.g. 0 + required uint32 major_version = 2; // major version of the firmware/bootloader, e.g. 1 + required uint32 minor_version = 3; // minor version of the firmware/bootloader, e.g. 0 + required uint32 patch_version = 4; // patch version of the firmware/bootloader, e.g. 0 optional bool bootloader_mode = 5; // is device in bootloader mode? optional string device_id = 6; // device's unique identifier optional bool pin_protection = 7; // is device protected by PIN? @@ -196,7 +196,7 @@ message SdProtect { * @next Success */ message Ping { - optional string message = 1; // message to send back in Success message + optional string message = 1 [default=""]; // message to send back in Success message optional bool button_protection = 2; // ask for button press } diff --git a/common/protob/messages-nem.proto b/common/protob/messages-nem.proto index 295f9dcdb..e65f2c965 100644 --- a/common/protob/messages-nem.proto +++ b/common/protob/messages-nem.proto @@ -172,8 +172,8 @@ message NEMSignTx { * @end */ message NEMSignedTx { - optional bytes data = 1; // Transaction data - optional bytes signature = 2; // Signature for the transaction + required bytes data = 1; // Transaction data + required bytes signature = 2; // Signature for the transaction } /** @@ -194,5 +194,5 @@ message NEMDecryptMessage { * @end */ message NEMDecryptedMessage { - optional bytes payload = 1; // Actual message data (unencrypted) + required bytes payload = 1; // Actual message data (unencrypted) } diff --git a/common/protob/messages-ripple.proto b/common/protob/messages-ripple.proto index 5edc2babb..5bb661785 100644 --- a/common/protob/messages-ripple.proto +++ b/common/protob/messages-ripple.proto @@ -20,7 +20,7 @@ message RippleGetAddress { * @end */ message RippleAddress { - optional string address = 1; // Address in Ripple format (base58 of a pubkey with checksum) + required string address = 1; // Address in Ripple format (base58 of a pubkey with checksum) } /** @@ -43,8 +43,8 @@ message RippleSignTx { * - see https://developers.ripple.com/payment.html */ message RipplePayment { - optional uint64 amount = 1; // only XRP is supported at the moment so this an integer - optional string destination = 2; // destination account address + required uint64 amount = 1; // only XRP is supported at the moment so this an integer + required string destination = 2; // destination account address optional uint32 destination_tag = 3; // destination tag to identify payments } } @@ -54,6 +54,6 @@ message RippleSignTx { * @end */ message RippleSignedTx { - optional bytes signature = 1; - optional bytes serialized_tx = 2; + required bytes signature = 1; + required bytes serialized_tx = 2; } diff --git a/common/protob/messages-stellar.proto b/common/protob/messages-stellar.proto index c8229c7c0..8587b9e0b 100644 --- a/common/protob/messages-stellar.proto +++ b/common/protob/messages-stellar.proto @@ -10,7 +10,7 @@ option java_outer_classname = "TrezorMessageStellar"; * @embed */ message StellarAssetType { - optional uint32 type = 1; // 0 = native asset (XLM), 1 = alphanum 4, 2 = alphanum 12 + required uint32 type = 1; // 0 = native asset (XLM), 1 = alphanum 4, 2 = alphanum 12 optional string code = 2; // for non-native assets, string describing the code optional string issuer = 3; // issuing address } @@ -30,7 +30,7 @@ message StellarGetAddress { * @end */ message StellarAddress { - optional string address = 1; // Address in Stellar format (base32 of a pubkey with checksum) + required string address = 1; // Address in Stellar format (base32 of a pubkey with checksum) } /** @@ -217,6 +217,6 @@ message StellarBumpSequenceOp { * @end */ message StellarSignedTx { - optional bytes public_key = 1; // public key for the private key used to sign data - optional bytes signature = 2; // signature suitable for sending to the Stellar network + required bytes public_key = 1; // public key for the private key used to sign data + required bytes signature = 2; // signature suitable for sending to the Stellar network } diff --git a/common/protob/messages-tezos.proto b/common/protob/messages-tezos.proto index 474f18628..51e29151f 100644 --- a/common/protob/messages-tezos.proto +++ b/common/protob/messages-tezos.proto @@ -21,7 +21,7 @@ message TezosGetAddress { * @end */ message TezosAddress { - optional string address = 1; // Coin address in Base58 encoding + required string address = 1; // Coin address in Base58 encoding } /** @@ -39,7 +39,7 @@ message TezosGetPublicKey { * @end */ message TezosPublicKey { - optional string public_key = 1; // b58 encoded Tezos public key with prefix + required string public_key = 1; // b58 encoded Tezos public key with prefix } /** @@ -49,7 +49,7 @@ message TezosPublicKey { */ message TezosSignTx { repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node - optional bytes branch = 2; + required bytes branch = 2; optional TezosRevealOp reveal = 3; // Tezos reveal operation (may be bundled with other op) optional TezosTransactionOp transaction = 4; // Tezos transaction operation @@ -61,8 +61,8 @@ message TezosSignTx { * Tezos contract ID */ message TezosContractID { - optional TezosContractType tag = 1; - optional bytes hash = 2; // Implicit = 21B, originated = 20B + 1B padding + required TezosContractType tag = 1; + required bytes hash = 2; // Implicit = 21B, originated = 20B + 1B padding /* * Type of Tezos Contract type */ @@ -75,24 +75,24 @@ message TezosSignTx { * Structure representing information for reveal */ message TezosRevealOp { - optional bytes source = 7; - optional uint64 fee = 2; - optional uint64 counter = 3; - optional uint64 gas_limit = 4; - optional uint64 storage_limit = 5; - optional bytes public_key = 6; + required bytes source = 7; + required uint64 fee = 2; + required uint64 counter = 3; + required uint64 gas_limit = 4; + required uint64 storage_limit = 5; + required bytes public_key = 6; } /** * Structure representing information for transaction */ message TezosTransactionOp { - optional bytes source = 9; - optional uint64 fee = 2; - optional uint64 counter = 3; - optional uint64 gas_limit = 4; - optional uint64 storage_limit = 5; - optional uint64 amount = 6; - optional TezosContractID destination = 7; + required bytes source = 9; + required uint64 fee = 2; + required uint64 counter = 3; + required uint64 gas_limit = 4; + required uint64 storage_limit = 5; + required uint64 amount = 6; + required TezosContractID destination = 7; optional bytes parameters = 8; optional TezosParametersManager parameters_manager = 10; @@ -111,28 +111,28 @@ message TezosSignTx { * Structure representing information for origination */ message TezosOriginationOp { - optional bytes source = 12; - optional uint64 fee = 2; - optional uint64 counter = 3; - optional uint64 gas_limit = 4; - optional uint64 storage_limit = 5; + required bytes source = 12; + required uint64 fee = 2; + required uint64 counter = 3; + required uint64 gas_limit = 4; + required uint64 storage_limit = 5; optional bytes manager_pubkey = 6; - optional uint64 balance = 7; + required uint64 balance = 7; optional bool spendable = 8; optional bool delegatable = 9; optional bytes delegate = 10; - optional bytes script = 11; + required bytes script = 11; } /** * Structure representing information for delegation */ message TezosDelegationOp { - optional bytes source = 7; - optional uint64 fee = 2; - optional uint64 counter = 3; - optional uint64 gas_limit = 4; - optional uint64 storage_limit = 5; - optional bytes delegate = 6; + required bytes source = 7; + required uint64 fee = 2; + required uint64 counter = 3; + required uint64 gas_limit = 4; + required uint64 storage_limit = 5; + required bytes delegate = 6; } /** * Structure representing information for proposal @@ -164,7 +164,7 @@ message TezosSignTx { * @end */ message TezosSignedTx { - optional string signature = 1; // Tezos b58 encoded transaction signature with prefix - optional bytes sig_op_contents = 2; // operation_bytes + signed operation_bytes - optional string operation_hash = 3; // b58 encoded hashed operation contents with prefix + required string signature = 1; // Tezos b58 encoded transaction signature with prefix + required bytes sig_op_contents = 2; // operation_bytes + signed operation_bytes + required string operation_hash = 3; // b58 encoded hashed operation contents with prefix }