From 18739987ee2884e74c0a0fccdd29a7d941ec1281 Mon Sep 17 00:00:00 2001 From: Matus Zamborsky Date: Tue, 14 Aug 2018 15:23:07 +0200 Subject: [PATCH] protob: Add Ontology support (#184) --- protob/Makefile | 2 +- protob/messages-ontology.proto | 198 +++++++++++++++++++++++++++++++++ protob/messages.proto | 12 ++ 3 files changed, 211 insertions(+), 1 deletion(-) create mode 100644 protob/messages-ontology.proto diff --git a/protob/Makefile b/protob/Makefile index 4168b783a..74d2e3339 100644 --- a/protob/Makefile +++ b/protob/Makefile @@ -1,4 +1,4 @@ -check: messages.pb messages-bitcoin.pb messages-bootloader.pb messages-cardano.pb messages-common.pb messages-crypto.pb messages-debug.pb messages-ethereum.pb messages-lisk.pb messages-management.pb messages-monero.pb messages-nem.pb messages-ripple.pb messages-stellar.pb messages-tezos.pb +check: messages.pb messages-bitcoin.pb messages-bootloader.pb messages-cardano.pb messages-common.pb messages-crypto.pb messages-debug.pb messages-ethereum.pb messages-lisk.pb messages-management.pb messages-monero.pb messages-nem.pb messages-ripple.pb messages-stellar.pb messages-tezos.pb messages-ontology.pb %.pb: %.proto protoc -I/usr/include -I. $< -o $@ diff --git a/protob/messages-ontology.proto b/protob/messages-ontology.proto new file mode 100644 index 000000000..338d5ce38 --- /dev/null +++ b/protob/messages-ontology.proto @@ -0,0 +1,198 @@ +syntax = "proto2"; + +// Sugar for easier handling in Java +option java_package = "com.satoshilabs.trezor.lib.protobuf"; +option java_outer_classname = "TrezorMessageOntology"; + +/** +* Ontology Transaction +*/ +message OntologyTransaction { + + /** + * Attribute of Ontology transaction + */ + message OntologyTxAttribute { + optional uint32 usage = 1; + optional bytes data = 2; + } + + optional uint32 version = 1; + optional uint32 type = 2; + optional uint32 nonce = 3; + optional uint64 gas_price = 4; + optional uint64 gas_limit = 5; + optional string payer = 6; + repeated OntologyTxAttribute tx_attributes = 7; +} + +/** + * Request: Ask device for Ontology public key corresponding to address_n path + * @start + * @next OntologyPublicKey +*/ +message OntologyGetPublicKey { + repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node + optional bool show_display = 2; // Optionally show on display before sending the result +} + +/** + * Response: Contains Ontology public key derived from device private seed + * @end +*/ +message OntologyPublicKey { + optional bytes public_key = 1; // Ontology public key +} + +/** + * Request: Ask device for Ontology address corresponding to address_n path + * @start + * @next OntologyAddress + */ +message OntologyGetAddress { + repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node + optional bool show_display = 2; // Optionally show on display before sending the result +} + +/** + * Response: Contains Ontology address derived from device private seed + * @end + */ +message OntologyAddress { + optional string address = 1; // Ontology address +} + + +/** + * Request: Ask device to sign Ontology transfer + * @start + * @next OntologySignedTransfer + */ + message OntologySignTransfer { + repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node + optional OntologyTransaction transaction = 2; + optional OntologyTransfer transfer = 3; + + /** + * Ontology Transfer + */ + message OntologyTransfer { + /** + * Ontology Asset + */ + enum OntologyAsset { + ONT = 1; + ONG = 2; + } + + optional OntologyAsset asset = 1; + optional uint64 amount = 2; + optional string from_address = 3; + optional string to_address = 4; + } +} + +/** +* Response: Contains Ontology transfer signature +* @end +*/ +message OntologySignedTransfer { + optional bytes signature = 1; + optional bytes payload = 2; +} + +/** + * Request: Ask device to sign Ontology ONG withdrawal + * @start + * @next OntologySignedWithdrawOng + */ + message OntologySignWithdrawOng { + repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node + optional OntologyTransaction transaction = 2; + optional OntologyWithdrawOng withdraw_ong = 3; + + /** + * Ontology ONG Withdrawal + */ + message OntologyWithdrawOng { + optional uint64 amount = 1; + optional string from_address = 2; + optional string to_address = 3; + } +} + +/** +* Response: Contains Ontology ONG withdrawal signature +* @end +*/ +message OntologySignedWithdrawOng { + optional bytes signature = 1; + optional bytes payload = 2; +} + +/** + * Request: Ask device to sign Ontology ONT ID registration + * @start + * @next OntologySignedOntIdRegister + */ + message OntologySignOntIdRegister { + repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node + optional OntologyTransaction transaction = 2; + optional OntologyOntIdRegister ont_id_register = 3; + + /** + * Ontology ONT ID registration + */ + message OntologyOntIdRegister { + optional string ont_id = 1; + optional bytes public_key = 2; + } +} + +/** +* Response: Contains Ontology ONT ID registration signature +* @end +*/ +message OntologySignedOntIdRegister { + optional bytes signature = 1; + optional bytes payload = 2; +} + + +/** + * Request: Ask device to sign Ontology ONT ID attributes adding + * @start + * @next OntologySignedOntIdAddAttributes + */ + message OntologySignOntIdAddAttributes { + repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node + optional OntologyTransaction transaction = 2; + optional OntologyOntIdAddAttributes ont_id_add_attributes = 3; + + /** + * Attribute of Ontology ONT ID + */ + message OntologyOntIdAttribute { + optional string key = 1; + optional string type = 2; + optional string value = 3; + } + + /** + * Ontology ONT ID attributes adding + */ + message OntologyOntIdAddAttributes { + optional string ont_id = 1; + optional bytes public_key = 2; + repeated OntologyOntIdAttribute ont_id_attributes = 3; + } +} + +/** +* Response: Contains Ontology ONT ID attributes adding signature +* @end +*/ +message OntologySignedOntIdAddAttributes { + optional bytes signature = 1; + optional bytes payload = 2; +} diff --git a/protob/messages.proto b/protob/messages.proto index ff5171f43..05536de10 100644 --- a/protob/messages.proto +++ b/protob/messages.proto @@ -174,6 +174,18 @@ enum MessageType { MessageType_CardanoTxAck = 309 [(wire_in) = true]; MessageType_CardanoSignedTransaction = 310 [(wire_out) = true]; + // Ontology + MessageType_OntologyGetAddress = 350 [(wire_in) = true]; + MessageType_OntologyAddress = 351 [(wire_out) = true]; + MessageType_OntologyGetPublicKey = 352 [(wire_in) = true]; + MessageType_OntologyPublicKey = 353 [(wire_out) = true]; + MessageType_OntologySignTx = 354 [(wire_in) = true]; + MessageType_OntologySignedTx = 355 [(wire_out) = true]; + MessageType_OntologySignTransfer = 356 [(wire_in) = true]; + MessageType_OntologySignedTransfer = 357 [(wire_out) = true]; + MessageType_OntologySignWithdrawOng = 358 [(wire_in) = true]; + MessageType_OntologySignedWithdrawOng = 359 [(wire_out) = true]; + // Ripple MessageType_RippleGetAddress = 400 [(wire_in) = true]; MessageType_RippleAddress = 401 [(wire_out) = true];