common+python: Revert Ontology support

This reverts commit 402e72e36e.
This reverts commit 21326d3a41.
This reverts commit 18739987ee.
pull/179/head
Tomas Susanka 5 years ago committed by Pavol Rusnak
parent 562206d220
commit cc5c8ae7e0
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -1,4 +1,4 @@
check: messages.pb messages-binance.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 messages-tron.pb messages-eos.pb
check: messages.pb messages-binance.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-tron.pb messages-eos.pb
%.pb: %.proto
protoc -I/usr/include -I. $< -o $@

@ -1,189 +0,0 @@
syntax = "proto2";
// Sugar for easier handling in Java
option java_package = "com.satoshilabs.trezor.lib.protobuf";
option java_outer_classname = "TrezorMessageOntology";
/**
* Ontology Transaction
* @embed
*/
message OntologyTransaction {
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;
/**
* Attribute of Ontology transaction
*/
message OntologyTxAttribute {
optional uint32 usage = 1;
optional bytes data = 2;
}
}
/**
* 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 {
optional OntologyAsset asset = 1;
optional uint64 amount = 2;
optional string from_address = 3;
optional string to_address = 4;
/**
* Ontology Asset
*/
enum OntologyAsset {
ONT = 1;
ONG = 2;
}
}
}
/**
* 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;
/**
* Ontology ONT ID attributes adding
*/
message OntologyOntIdAddAttributes {
optional string ont_id = 1;
optional bytes public_key = 2;
repeated OntologyOntIdAttribute ont_id_attributes = 3;
/**
* Attribute of Ontology ONT ID
*/
message OntologyOntIdAttribute {
optional string key = 1;
optional string type = 2;
optional string value = 3;
}
}
}
/**
* Response: Contains Ontology ONT ID attributes adding signature
* @end
*/
message OntologySignedOntIdAddAttributes {
optional bytes signature = 1;
optional bytes payload = 2;
}

@ -178,20 +178,6 @@ enum MessageType {
MessageType_CardanoTxAck = 309 [(wire_in) = true];
MessageType_CardanoSignedTx = 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_OntologySignTransfer = 354 [(wire_in) = true];
MessageType_OntologySignedTransfer = 355 [(wire_out) = true];
MessageType_OntologySignWithdrawOng = 356 [(wire_in) = true];
MessageType_OntologySignedWithdrawOng = 357 [(wire_out) = true];
MessageType_OntologySignOntIdRegister = 358 [(wire_in) = true];
MessageType_OntologySignedOntIdRegister = 359 [(wire_out) = true];
MessageType_OntologySignOntIdAddAttributes = 360 [(wire_in) = true];
MessageType_OntologySignedOntIdAddAttributes = 361 [(wire_out) = true];
// Ripple
MessageType_RippleGetAddress = 400 [(wire_in) = true];
MessageType_RippleAddress = 401 [(wire_out) = true];

@ -123,18 +123,6 @@ CardanoGetAddress = 307
CardanoAddress = 308
CardanoTxAck = 309
CardanoSignedTx = 310
OntologyGetAddress = 350
OntologyAddress = 351
OntologyGetPublicKey = 352
OntologyPublicKey = 353
OntologySignTransfer = 354
OntologySignedTransfer = 355
OntologySignWithdrawOng = 356
OntologySignedWithdrawOng = 357
OntologySignOntIdRegister = 358
OntologySignedOntIdRegister = 359
OntologySignOntIdAddAttributes = 360
OntologySignedOntIdAddAttributes = 361
RippleGetAddress = 400
RippleAddress = 401
RippleSignTx = 402

@ -47,7 +47,6 @@ from trezorlib import (
misc,
monero,
nem,
ontology,
protobuf,
ripple,
stellar,
@ -1833,197 +1832,6 @@ def tezos_sign_tx(connect, address, file):
return tezos.sign_tx(client, address_n, msg)
#
# Ontology functions
#
@cli.command(help="Get Ontology address for specified path.")
@click.option(
"-n", "--address", required=True, help="BIP-32 path, e.g. m/44'/888'/0'/0/0"
)
@click.option("-d", "--show-display", is_flag=True)
@click.pass_obj
def ontology_get_address(connect, address, show_display):
client = connect()
address_n = tools.parse_path(address)
return ontology.get_address(client, address_n, show_display)
@cli.command(help="Get Ontology public key for specified path.")
@click.option(
"-n", "--address", required=True, help="BIP-32 path, e.g. m/44'/888'/0'/0/0"
)
@click.option("-d", "--show-display", is_flag=True)
@click.pass_obj
def ontology_get_public_key(connect, address, show_display):
client = connect()
address_n = tools.parse_path(address)
result = ontology.get_public_key(client, address_n, show_display)
return result.public_key.hex()
@cli.command(help="Sign Ontology transfer.")
@click.option(
"-n",
"--address",
required=True,
help="BIP-32 path to signing key, e.g. m/44'/888'/0'/0/0",
)
@click.option(
"-tx",
"--transaction",
type=click.File("r"),
default="-",
help="Transaction in JSON format",
)
@click.option(
"-tr",
"--transfer",
type=click.File("r"),
default="-",
help="Transfer in JSON format",
)
@click.pass_obj
def ontology_sign_transfer(connect, address, transaction_f, transfer_f):
client = connect()
address_n = tools.parse_path(address)
transaction = protobuf.dict_to_proto(
proto.OntologyTransaction, json.load(transaction_f)
)
transfer = protobuf.dict_to_proto(proto.OntologyTransfer, json.load(transfer_f))
result = ontology.sign_transfer(client, address_n, transaction, transfer)
output = {"payload": result.payload.hex(), "signature": result.signature.hex()}
return output
@cli.command(help="Sign Ontology withdraw Ong.")
@click.option(
"-n",
"--address",
required=True,
help="BIP-32 path to signing key, e.g. m/44'/888'/0'/0/0",
)
@click.option(
"-tx",
"--transaction",
type=click.File("r"),
default="-",
help="Transaction in JSON format",
)
@click.option(
"-wi",
"--withdraw_ong",
type=click.File("r"),
default="-",
help="Withdrawal in JSON format",
)
@click.pass_obj
def ontology_sign_withdraw_ong(connect, address, transaction_f, withdraw_ong_f):
client = connect()
address_n = tools.parse_path(address)
transaction = protobuf.dict_to_proto(
proto.OntologyTransaction, json.load(transaction_f)
)
withdraw_ong = protobuf.dict_to_proto(
proto.OntologyWithdrawOng, json.load(withdraw_ong_f)
)
result = ontology.sign_withdrawal(client, address_n, transaction, withdraw_ong)
output = {"payload": result.payload.hex(), "signature": result.signature.hex()}
return output
@cli.command(help="Sign Ontology ONT ID Registration.")
@click.option(
"-n",
"--address",
required=True,
help="BIP-32 path to signing key, e.g. m/44'/888'/0'/0/0",
)
@click.option(
"-tx",
"--transaction",
type=click.File("r"),
default="-",
help="Transaction in JSON format",
)
@click.option(
"-re",
"--register",
type=click.File("r"),
default="-",
help="Register in JSON format",
)
@click.argument("transaction")
@click.argument("ont_id_register")
@click.pass_obj
def ontology_sign_ont_id_register(connect, address, transaction_f, ont_id_register_f):
client = connect()
address_n = tools.parse_path(address)
transaction = protobuf.dict_to_proto(
proto.OntologyTransaction, json.load(transaction_f)
)
ont_id_register = protobuf.dict_to_proto(
proto.OntologyOntIdRegister, json.load(ont_id_register_f)
)
result = ontology.sign_register(client, address_n, transaction, ont_id_register)
output = {"payload": result.payload.hex(), "signature": result.signature.hex()}
return output
@cli.command(help="Sign Ontology ONT ID Attributes adding.")
@click.option(
"-n",
"--address",
required=True,
help="BIP-32 path to signing key, e.g. m/44'/888'/0'/0/0",
)
@click.option(
"-tx",
"--transaction",
type=click.File("r"),
default="-",
help="Transaction in JSON format",
)
@click.option(
"-aa",
"--add_attr",
type=click.File("r"),
default="-",
help="Add attributes in JSON format",
)
@click.pass_obj
def ontology_sign_ont_id_add_attributes(
connect, address, transaction_f, ont_id_add_attributes_f
):
client = connect()
address_n = tools.parse_path(address)
transaction = protobuf.dict_to_proto(
proto.OntologyTransaction, json.load(transaction_f)
)
ont_id_add_attributes = protobuf.dict_to_proto(
proto.OntologyOntIdAddAttributes, json.load(ont_id_add_attributes_f)
)
result = ontology.sign_add_attr(
client, address_n, transaction, ont_id_add_attributes
)
output = {"payload": result.payload.hex(), "signature": result.signature.hex()}
return output
#
# Main
#

@ -123,18 +123,6 @@ CardanoGetAddress = 307
CardanoAddress = 308
CardanoTxAck = 309
CardanoSignedTx = 310
OntologyGetAddress = 350
OntologyAddress = 351
OntologyGetPublicKey = 352
OntologyPublicKey = 353
OntologySignTransfer = 354
OntologySignedTransfer = 355
OntologySignWithdrawOng = 356
OntologySignedWithdrawOng = 357
OntologySignOntIdRegister = 358
OntologySignedOntIdRegister = 359
OntologySignOntIdAddAttributes = 360
OntologySignedOntIdAddAttributes = 361
RippleGetAddress = 400
RippleAddress = 401
RippleSignTx = 402

@ -1,19 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
class OntologyAddress(p.MessageType):
MESSAGE_WIRE_TYPE = 351
def __init__(
self,
address: str = None,
) -> None:
self.address = address
@classmethod
def get_fields(cls):
return {
1: ('address', p.UnicodeType, 0),
}

@ -1,4 +0,0 @@
# Automatically generated by pb2py
# fmt: off
ONT = 1
ONG = 2

@ -1,28 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
if __debug__:
try:
from typing import List
except ImportError:
List = None # type: ignore
class OntologyGetAddress(p.MessageType):
MESSAGE_WIRE_TYPE = 350
def __init__(
self,
address_n: List[int] = None,
show_display: bool = None,
) -> None:
self.address_n = address_n if address_n is not None else []
self.show_display = show_display
@classmethod
def get_fields(cls):
return {
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
2: ('show_display', p.BoolType, 0),
}

@ -1,28 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
if __debug__:
try:
from typing import List
except ImportError:
List = None # type: ignore
class OntologyGetPublicKey(p.MessageType):
MESSAGE_WIRE_TYPE = 352
def __init__(
self,
address_n: List[int] = None,
show_display: bool = None,
) -> None:
self.address_n = address_n if address_n is not None else []
self.show_display = show_display
@classmethod
def get_fields(cls):
return {
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
2: ('show_display', p.BoolType, 0),
}

@ -1,32 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
from .OntologyOntIdAttribute import OntologyOntIdAttribute
if __debug__:
try:
from typing import List
except ImportError:
List = None # type: ignore
class OntologyOntIdAddAttributes(p.MessageType):
def __init__(
self,
ont_id: str = None,
public_key: bytes = None,
ont_id_attributes: List[OntologyOntIdAttribute] = None,
) -> None:
self.ont_id = ont_id
self.public_key = public_key
self.ont_id_attributes = ont_id_attributes if ont_id_attributes is not None else []
@classmethod
def get_fields(cls):
return {
1: ('ont_id', p.UnicodeType, 0),
2: ('public_key', p.BytesType, 0),
3: ('ont_id_attributes', OntologyOntIdAttribute, p.FLAG_REPEATED),
}

@ -1,24 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
class OntologyOntIdAttribute(p.MessageType):
def __init__(
self,
key: str = None,
type: str = None,
value: str = None,
) -> None:
self.key = key
self.type = type
self.value = value
@classmethod
def get_fields(cls):
return {
1: ('key', p.UnicodeType, 0),
2: ('type', p.UnicodeType, 0),
3: ('value', p.UnicodeType, 0),
}

@ -1,21 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
class OntologyOntIdRegister(p.MessageType):
def __init__(
self,
ont_id: str = None,
public_key: bytes = None,
) -> None:
self.ont_id = ont_id
self.public_key = public_key
@classmethod
def get_fields(cls):
return {
1: ('ont_id', p.UnicodeType, 0),
2: ('public_key', p.BytesType, 0),
}

@ -1,19 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
class OntologyPublicKey(p.MessageType):
MESSAGE_WIRE_TYPE = 353
def __init__(
self,
public_key: bytes = None,
) -> None:
self.public_key = public_key
@classmethod
def get_fields(cls):
return {
1: ('public_key', p.BytesType, 0),
}

@ -1,34 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
from .OntologyOntIdAddAttributes import OntologyOntIdAddAttributes
from .OntologyTransaction import OntologyTransaction
if __debug__:
try:
from typing import List
except ImportError:
List = None # type: ignore
class OntologySignOntIdAddAttributes(p.MessageType):
MESSAGE_WIRE_TYPE = 360
def __init__(
self,
address_n: List[int] = None,
transaction: OntologyTransaction = None,
ont_id_add_attributes: OntologyOntIdAddAttributes = None,
) -> None:
self.address_n = address_n if address_n is not None else []
self.transaction = transaction
self.ont_id_add_attributes = ont_id_add_attributes
@classmethod
def get_fields(cls):
return {
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
2: ('transaction', OntologyTransaction, 0),
3: ('ont_id_add_attributes', OntologyOntIdAddAttributes, 0),
}

@ -1,34 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
from .OntologyOntIdRegister import OntologyOntIdRegister
from .OntologyTransaction import OntologyTransaction
if __debug__:
try:
from typing import List
except ImportError:
List = None # type: ignore
class OntologySignOntIdRegister(p.MessageType):
MESSAGE_WIRE_TYPE = 358
def __init__(
self,
address_n: List[int] = None,
transaction: OntologyTransaction = None,
ont_id_register: OntologyOntIdRegister = None,
) -> None:
self.address_n = address_n if address_n is not None else []
self.transaction = transaction
self.ont_id_register = ont_id_register
@classmethod
def get_fields(cls):
return {
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
2: ('transaction', OntologyTransaction, 0),
3: ('ont_id_register', OntologyOntIdRegister, 0),
}

@ -1,34 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
from .OntologyTransaction import OntologyTransaction
from .OntologyTransfer import OntologyTransfer
if __debug__:
try:
from typing import List
except ImportError:
List = None # type: ignore
class OntologySignTransfer(p.MessageType):
MESSAGE_WIRE_TYPE = 354
def __init__(
self,
address_n: List[int] = None,
transaction: OntologyTransaction = None,
transfer: OntologyTransfer = None,
) -> None:
self.address_n = address_n if address_n is not None else []
self.transaction = transaction
self.transfer = transfer
@classmethod
def get_fields(cls):
return {
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
2: ('transaction', OntologyTransaction, 0),
3: ('transfer', OntologyTransfer, 0),
}

@ -1,34 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
from .OntologyTransaction import OntologyTransaction
from .OntologyWithdrawOng import OntologyWithdrawOng
if __debug__:
try:
from typing import List
except ImportError:
List = None # type: ignore
class OntologySignWithdrawOng(p.MessageType):
MESSAGE_WIRE_TYPE = 356
def __init__(
self,
address_n: List[int] = None,
transaction: OntologyTransaction = None,
withdraw_ong: OntologyWithdrawOng = None,
) -> None:
self.address_n = address_n if address_n is not None else []
self.transaction = transaction
self.withdraw_ong = withdraw_ong
@classmethod
def get_fields(cls):
return {
1: ('address_n', p.UVarintType, p.FLAG_REPEATED),
2: ('transaction', OntologyTransaction, 0),
3: ('withdraw_ong', OntologyWithdrawOng, 0),
}

@ -1,22 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
class OntologySignedOntIdAddAttributes(p.MessageType):
MESSAGE_WIRE_TYPE = 361
def __init__(
self,
signature: bytes = None,
payload: bytes = None,
) -> None:
self.signature = signature
self.payload = payload
@classmethod
def get_fields(cls):
return {
1: ('signature', p.BytesType, 0),
2: ('payload', p.BytesType, 0),
}

@ -1,22 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
class OntologySignedOntIdRegister(p.MessageType):
MESSAGE_WIRE_TYPE = 359
def __init__(
self,
signature: bytes = None,
payload: bytes = None,
) -> None:
self.signature = signature
self.payload = payload
@classmethod
def get_fields(cls):
return {
1: ('signature', p.BytesType, 0),
2: ('payload', p.BytesType, 0),
}

@ -1,22 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
class OntologySignedTransfer(p.MessageType):
MESSAGE_WIRE_TYPE = 355
def __init__(
self,
signature: bytes = None,
payload: bytes = None,
) -> None:
self.signature = signature
self.payload = payload
@classmethod
def get_fields(cls):
return {
1: ('signature', p.BytesType, 0),
2: ('payload', p.BytesType, 0),
}

@ -1,22 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
class OntologySignedWithdrawOng(p.MessageType):
MESSAGE_WIRE_TYPE = 357
def __init__(
self,
signature: bytes = None,
payload: bytes = None,
) -> None:
self.signature = signature
self.payload = payload
@classmethod
def get_fields(cls):
return {
1: ('signature', p.BytesType, 0),
2: ('payload', p.BytesType, 0),
}

@ -1,44 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
from .OntologyTxAttribute import OntologyTxAttribute
if __debug__:
try:
from typing import List
except ImportError:
List = None # type: ignore
class OntologyTransaction(p.MessageType):
def __init__(
self,
version: int = None,
type: int = None,
nonce: int = None,
gas_price: int = None,
gas_limit: int = None,
payer: str = None,
tx_attributes: List[OntologyTxAttribute] = None,
) -> None:
self.version = version
self.type = type
self.nonce = nonce
self.gas_price = gas_price
self.gas_limit = gas_limit
self.payer = payer
self.tx_attributes = tx_attributes if tx_attributes is not None else []
@classmethod
def get_fields(cls):
return {
1: ('version', p.UVarintType, 0),
2: ('type', p.UVarintType, 0),
3: ('nonce', p.UVarintType, 0),
4: ('gas_price', p.UVarintType, 0),
5: ('gas_limit', p.UVarintType, 0),
6: ('payer', p.UnicodeType, 0),
7: ('tx_attributes', OntologyTxAttribute, p.FLAG_REPEATED),
}

@ -1,27 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
class OntologyTransfer(p.MessageType):
def __init__(
self,
asset: int = None,
amount: int = None,
from_address: str = None,
to_address: str = None,
) -> None:
self.asset = asset
self.amount = amount
self.from_address = from_address
self.to_address = to_address
@classmethod
def get_fields(cls):
return {
1: ('asset', p.UVarintType, 0),
2: ('amount', p.UVarintType, 0),
3: ('from_address', p.UnicodeType, 0),
4: ('to_address', p.UnicodeType, 0),
}

@ -1,21 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
class OntologyTxAttribute(p.MessageType):
def __init__(
self,
usage: int = None,
data: bytes = None,
) -> None:
self.usage = usage
self.data = data
@classmethod
def get_fields(cls):
return {
1: ('usage', p.UVarintType, 0),
2: ('data', p.BytesType, 0),
}

@ -1,24 +0,0 @@
# Automatically generated by pb2py
# fmt: off
from .. import protobuf as p
class OntologyWithdrawOng(p.MessageType):
def __init__(
self,
amount: int = None,
from_address: str = None,
to_address: str = None,
) -> None:
self.amount = amount
self.from_address = from_address
self.to_address = to_address
@classmethod
def get_fields(cls):
return {
1: ('amount', p.UVarintType, 0),
2: ('from_address', p.UnicodeType, 0),
3: ('to_address', p.UnicodeType, 0),
}

@ -186,25 +186,6 @@ from .NEMSignTx import NEMSignTx
from .NEMSignedTx import NEMSignedTx
from .NEMTransactionCommon import NEMTransactionCommon
from .NEMTransfer import NEMTransfer
from .OntologyAddress import OntologyAddress
from .OntologyGetAddress import OntologyGetAddress
from .OntologyGetPublicKey import OntologyGetPublicKey
from .OntologyOntIdAddAttributes import OntologyOntIdAddAttributes
from .OntologyOntIdAttribute import OntologyOntIdAttribute
from .OntologyOntIdRegister import OntologyOntIdRegister
from .OntologyPublicKey import OntologyPublicKey
from .OntologySignOntIdAddAttributes import OntologySignOntIdAddAttributes
from .OntologySignOntIdRegister import OntologySignOntIdRegister
from .OntologySignTransfer import OntologySignTransfer
from .OntologySignWithdrawOng import OntologySignWithdrawOng
from .OntologySignedOntIdAddAttributes import OntologySignedOntIdAddAttributes
from .OntologySignedOntIdRegister import OntologySignedOntIdRegister
from .OntologySignedTransfer import OntologySignedTransfer
from .OntologySignedWithdrawOng import OntologySignedWithdrawOng
from .OntologyTransaction import OntologyTransaction
from .OntologyTransfer import OntologyTransfer
from .OntologyTxAttribute import OntologyTxAttribute
from .OntologyWithdrawOng import OntologyWithdrawOng
from .PassphraseAck import PassphraseAck
from .PassphraseRequest import PassphraseRequest
from .PassphraseStateAck import PassphraseStateAck
@ -305,7 +286,6 @@ from . import NEMImportanceTransferMode
from . import NEMModificationType
from . import NEMMosaicLevy
from . import NEMSupplyChangeType
from . import OntologyAsset
from . import OutputScriptType
from . import PassphraseSourceType
from . import PinMatrixRequestType

@ -1,70 +0,0 @@
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2018 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
from . import messages
from .tools import expect
#
# Ontology functions
#
@expect(messages.OntologyAddress, field="address")
def get_address(client, address_n, show_display=False):
return client.call(
messages.OntologyGetAddress(address_n=address_n, show_display=show_display)
)
@expect(messages.OntologyPublicKey)
def get_public_key(client, address_n, show_display=False):
return client.call(
messages.OntologyGetPublicKey(address_n=address_n, show_display=show_display)
)
@expect(messages.OntologySignedTransfer)
def sign_transfer(client, address_n, t, tr):
return client.call(
messages.OntologySignTransfer(address_n=address_n, transaction=t, transfer=tr)
)
@expect(messages.OntologySignedWithdrawOng)
def sign_withdrawal(client, address_n, t, w):
return client.call(
messages.OntologySignWithdrawOng(
address_n=address_n, transaction=t, withdraw_ong=w
)
)
@expect(messages.OntologySignedOntIdRegister)
def sign_register(client, address_n, t, r):
return client.call(
messages.OntologySignOntIdRegister(
address_n=address_n, transaction=t, ont_id_register=r
)
)
@expect(messages.OntologySignedOntIdAddAttributes)
def sign_add_attr(client, address_n, t, a):
return client.call(
messages.OntologySignOntIdAddAttributes(
address_n=address_n, transaction=t, ont_id_add_attributes=a
)
)

@ -1,42 +0,0 @@
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2018 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
import pytest
from trezorlib import ontology
from trezorlib.tools import parse_path
from .common import TrezorTest
@pytest.mark.ontology
@pytest.mark.skip_t1
class TestMsgOntologyGetaddress(TrezorTest):
def test_ontology_get_ont_address(self):
self.setup_mnemonic_nopin_nopassphrase()
assert (
ontology.get_address(self.client, parse_path("m/44'/1024'/0'/0/0"))
== "ANzeepWmi9hoLBA3UiwVhUm7Eku196VUHk"
)
def test_ontology_get_neo_address(self):
self.setup_mnemonic_nopin_nopassphrase()
assert (
ontology.get_address(self.client, parse_path("m/44'/888'/0'/0/0"))
== "AZEMburLePcdfqBFnVfdbsXKiBSnmtgFZr"
)

@ -1,97 +0,0 @@
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2018 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
import time
import pytest
from trezorlib import messages, ontology
from trezorlib.messages import ButtonRequestType as B
from trezorlib.tools import parse_path
from .common import TrezorTest
@pytest.mark.ontology
@pytest.mark.skip_t1
class TestMsgOntologySignOntIdAddAttributes(TrezorTest):
def test_ontology_sign_ont_id_add_attributes(self):
self.setup_mnemonic_nopin_nopassphrase()
transaction = messages.OntologyTransaction(
version=0x00,
nonce=0x7F7F1CEB,
type=0xD1,
gas_price=500,
gas_limit=30000,
payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc",
tx_attributes=[],
)
ont_id_add_attributes = messages.OntologyOntIdAddAttributes(
ont_id="did:ont:AGVn4NZNEQ7RawHTDxjaTjZ3R8h8q1aq9h",
public_key=bytes.fromhex(
"03a8269b0dad311d98195e76729bc57003348a315fd17b6bf4f90ba8b86735fa33"
),
ont_id_attributes=[
messages.OntologyOntIdAttribute(
key="firstName", type="json", value="John Sheppard"
)
],
)
# not using ontology.sign_add_attr() because of swiping
signature = self._ontology_sign(
2, parse_path("m/44'/1024'/0'/0/0"), transaction, ont_id_add_attributes
)
assert (
signature.payload.hex()
== "bd00c66b2a6469643a6f6e743a4147566e344e5a4e455137526177485444786a61546a5a33523868387131617139686a7cc8516a7cc80966697273744e616d656a7cc8046a736f6e6a7cc80d4a6f686e2053686570706172646a7cc82103a8269b0dad311d98195e76729bc57003348a315fd17b6bf4f90ba8b86735fa336a7cc86c0d616464417474726962757465731400000000000000000000000000000000000000030068164f6e746f6c6f67792e4e61746976652e496e766f6b65"
)
assert (
signature.signature.hex()
== "01c256dc16d88685fd6652d69b808059f7ed30edadb0ccfe51802702b94b65500922f9ea80e0fd7b77b5c51515e3bc43a495b3e98fb3adb82a0ab5dd47169fcf4e"
)
def _ontology_sign(
self, num_of_swipes, address_n, transaction, ont_id_add_attributes
):
def input_flow():
# Sign Tx
btn_code = yield
assert btn_code == B.SignTx
# Swipe and confirm
time.sleep(1)
for _ in range(num_of_swipes):
self.client.debug.swipe_down()
time.sleep(1)
# Confirm Action
self.client.debug.press_yes()
with self.client:
self.client.set_input_flow(input_flow)
self.client.set_expected_responses(
[
messages.ButtonRequest(code=B.SignTx),
messages.OntologySignedOntIdAddAttributes(),
]
)
return ontology.sign_add_attr(
self.client, address_n, transaction, ont_id_add_attributes
)

@ -1,89 +0,0 @@
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2018 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
import time
import pytest
from trezorlib import messages, ontology
from trezorlib.messages import ButtonRequestType as B
from trezorlib.tools import parse_path
from .common import TrezorTest
@pytest.mark.ontology
@pytest.mark.skip_t1
class TestMsgOntologySignOntIdRegister(TrezorTest):
def test_ontology_sign_ont_id_register(self):
self.setup_mnemonic_nopin_nopassphrase()
transaction = messages.OntologyTransaction(
version=0x00,
nonce=0x7F7F1CEB,
type=0xD1,
gas_price=500,
gas_limit=30000,
payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc",
tx_attributes=[],
)
ont_id_register = messages.OntologyOntIdRegister(
ont_id="did:ont:AGVn4NZNEQ7RawHTDxjaTjZ3R8h8q1aq9h",
public_key=bytes.fromhex(
"03a8269b0dad311d98195e76729bc57003348a315fd17b6bf4f90ba8b86735fa33"
),
)
# not using ontology.sign_register() because of swiping
signature = self._ontology_sign(
1, parse_path("m/44'/1024'/0'/0/0"), transaction, ont_id_register
)
assert (
signature.payload.hex()
== "9800c66b2a6469643a6f6e743a4147566e344e5a4e455137526177485444786a61546a5a33523868387131617139686a7cc82103a8269b0dad311d98195e76729bc57003348a315fd17b6bf4f90ba8b86735fa336a7cc86c127265674944576974685075626c69634b65791400000000000000000000000000000000000000030068164f6e746f6c6f67792e4e61746976652e496e766f6b65"
)
assert (
signature.signature.hex()
== "015d6abe231352d1ab32f0b0de0222cfb9a7a13f467a2bf8a369b61aa1f933dc3a6a2ba7831c8a15984fe0958d24cbca05d8e0736510c1734d773145ce3eac9e9b"
)
def _ontology_sign(self, num_of_swipes, address_n, transaction, ont_id_register):
def input_flow():
# Sign Tx
btn_code = yield
assert btn_code == B.SignTx
# Swipe and confirm
time.sleep(1)
for _ in range(num_of_swipes):
self.client.debug.swipe_down()
time.sleep(1)
# Confirm Action
self.client.debug.press_yes()
with self.client:
self.client.set_expected_responses(
[
messages.ButtonRequest(code=B.SignTx),
messages.OntologySignedOntIdRegister(),
]
)
self.client.set_input_flow(input_flow)
return ontology.sign_register(
self.client, address_n, transaction, ont_id_register
)

@ -1,86 +0,0 @@
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2018 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
import pytest
from trezorlib import messages, ontology
from trezorlib.tools import parse_path
from .common import TrezorTest
@pytest.mark.ontology
@pytest.mark.skip_t1
class TestMsgOntologySigntx(TrezorTest):
def test_ontology_sign_transfer_ont(self):
self.setup_mnemonic_nopin_nopassphrase()
transaction = messages.OntologyTransaction(
version=0x00,
nonce=0x7F7F1CEB,
type=0xD1,
gas_price=500,
gas_limit=30000,
payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc",
tx_attributes=[],
)
transfer = messages.OntologyTransfer(
asset=1,
amount=100,
from_address="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc",
to_address="AcyLq3tokVpkMBMLALVMWRdVJ83TTgBUwU",
)
signature = ontology.sign_transfer(
self.client, parse_path("m/44'/1024'/0'/0/0"), transaction, transfer
)
assert (
signature.payload.hex()
== "7900c66b140b045b101bc9fabaf181e251a38e76b73962111b6a7cc814e885e849e7f545ea84e8c555b86c70e4f751c4ec6a7cc80864000000000000006a7cc86c51c1087472616e736665721400000000000000000000000000000000000000010068164f6e746f6c6f67792e4e61746976652e496e766f6b65"
)
assert (
signature.signature.hex()
== "0102f9b0c43b2ed35aa89b0927a60e692cb8a74280c2da819a909150c8b3fd2b0b401806c97797fcc4b93d34f210ad01740cfd13b720a389a80f384c1f94fb749e"
)
def test_ontology_sign_transfer_ong(self):
self.setup_mnemonic_nopin_nopassphrase()
transaction = messages.OntologyTransaction(
version=0x00,
nonce=0x7F7F1CEB,
type=0xD1,
gas_price=500,
gas_limit=30000,
payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc",
tx_attributes=[],
)
transfer = messages.OntologyTransfer(
asset=2,
amount=12000000,
from_address="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc",
to_address="AcyLq3tokVpkMBMLALVMWRdVJ83TTgBUwU",
)
signature = ontology.sign_transfer(
self.client, parse_path("m/44'/1024'/0'/0/0"), transaction, transfer
)
assert (
signature.signature.hex()
== "01ad88061a6cf5f4960cf9d311adb6dec4925d368b0fa9b7f56269f2a4078bea2367469af50c70260142d2ce3cc2d1e7fd0b2923df659c994412ff18f138438e9d"
)

@ -1,57 +0,0 @@
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2018 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
import pytest
from trezorlib import messages, ontology
from trezorlib.tools import parse_path
from .common import TrezorTest
@pytest.mark.ontology
@pytest.mark.skip_t1
class TestMsgOntologySignWithdraw(TrezorTest):
def test_ontology_sign_withdraw_ong(self):
self.setup_mnemonic_nopin_nopassphrase()
transaction = messages.OntologyTransaction(
version=0x00,
nonce=0x7F7F1CEB,
type=0xD1,
gas_price=500,
gas_limit=30000,
payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc",
tx_attributes=[],
)
withdraw_ong = messages.OntologyWithdrawOng(
amount=12000000,
from_address="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc",
to_address="AcyLq3tokVpkMBMLALVMWRdVJ83TTgBUwU",
)
signature = ontology.sign_withdrawal(
self.client, parse_path("m/44'/1024'/0'/0/0"), transaction, withdraw_ong
)
assert (
signature.payload.hex()
== "9300c66b140b045b101bc9fabaf181e251a38e76b73962111b6a7cc81400000000000000000000000000000000000000016a7cc814e885e849e7f545ea84e8c555b86c70e4f751c4ec6a7cc808001bb700000000006a7cc86c0c7472616e7366657246726f6d1400000000000000000000000000000000000000020068164f6e746f6c6f67792e4e61746976652e496e766f6b65"
)
assert (
signature.signature.hex()
== "01a44355ac4549a021ecc571eb85ffb6ae4ff50cffc416ec55df40cad538fa55c64386167df2fb6b3fa9e698ebe265088839667b88da7e599ce7df679b0d5dfe60"
)
Loading…
Cancel
Save