core+tests: remove payload from ontolgoy signed_tx

core: refactor writing native_call with length

core: removed hex encoded string branch from native_call calculation

common: nested OntologyTransaction into OntologySignTx

core: fix ontology layout formatting

python: change the way ontology message signing works

python: add expected fields to ontology

core+python+common: remove type field from OntologyTransaction

core: inline write_push_bytes
ontology
ciny 4 years ago
parent 23df799e77
commit 0e63efa1e2

@ -5,26 +5,6 @@ package hw.trezor.messages.ontology;
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
@ -122,6 +102,26 @@ message OntologySignTx{
optional string value = 3;
}
}
/**
* Ontology Transaction
* @embed
*/
message OntologyTransaction {
optional uint32 version = 1;
optional uint32 nonce = 2;
optional uint64 gas_price = 3;
optional uint64 gas_limit = 4;
optional string payer = 5;
repeated OntologyTxAttribute tx_attributes = 6;
/**
* Attribute of Ontology transaction
*/
message OntologyTxAttribute {
optional uint32 usage = 1;
optional bytes data = 2;
}
}
}
/**
@ -130,5 +130,4 @@ message OntologySignTx{
*/
message OntologySignedTx {
optional bytes signature = 1;
optional bytes payload = 2;
}

@ -7,3 +7,4 @@ ONG_CONTRACT = (
ONTID_CONTRACT = (
b"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03"
)
TRANSACTION_TYPE = 0xD1

@ -11,21 +11,21 @@ from apps.common.confirm import require_confirm
async def require_confirm_transfer_ont(ctx, dest, value):
text = Text("Confirm sending", ui.ICON_SEND, icon_color=ui.GREEN)
text.bold(format_amount(value, 0) + "ONT")
text.bold(format_amount(value, 0) + " ONT")
text.mono(*split_address("To: " + dest))
return await require_confirm(ctx, text, ButtonRequestType.SignTx)
async def require_confirm_transfer_ong(ctx, dest, value):
text = Text("Confirm sending", ui.ICON_SEND, icon_color=ui.GREEN)
text.bold(format_amount(value, 9) + "ONG")
text.bold(format_amount(value, 9) + " ONG")
text.mono(*split_address("To: " + dest))
return await require_confirm(ctx, text, ButtonRequestType.SignTx)
async def require_confirm_withdraw_ong(ctx, value):
text = Text("Confirm withdraw of ", ui.ICON_SEND, icon_color=ui.GREEN)
text.bold(format_amount(value, 9) + "ONG")
text.bold(format_amount(value, 9) + " ONG")
return await require_confirm(ctx, text, ButtonRequestType.SignTx)

@ -38,7 +38,8 @@ def write_push_int(ret: bytearray, param: int) -> None:
# number encoded as 8 bytes
num = bytearray()
writer.write_uint64(num, param)
write_push_bytes(ret, bytes(num))
writer.write_byte(ret, 8)
writer.write_uint64(ret, param)
def write_push_bool(ret: bytearray, param: bool) -> None:

@ -36,10 +36,7 @@ def _write_native_code_script(ret: bytearray, arr: list) -> None:
Writes native code script from supplied data
"""
for val in reversed(arr):
if isinstance(val, str):
builder.write_push_bytes(ret, unhexlify(val))
elif isinstance(val, (bytes, bytearray)):
if isinstance(val, (bytes, bytearray)):
builder.write_push_bytes(ret, val)
elif isinstance(val, bool):

@ -13,14 +13,14 @@ from .sc.native_builder import ParamStruct, build_native_call
def serialize_tx(tx: OntologyTransaction, payload: bytes, hw) -> None:
writer.write_byte(hw, tx.version)
writer.write_byte(hw, tx.type)
writer.write_byte(hw, Const.TRANSACTION_TYPE)
writer.write_uint32(hw, tx.nonce)
writer.write_uint64(hw, tx.gas_price)
writer.write_uint64(hw, tx.gas_limit)
payer = get_bytes_from_address(tx.payer)
writer.write_bytes(hw, payer)
writer.write_bytes(hw, payload)
writer.write_bytes_with_length(hw, payload)
attributes = tx.tx_attributes
writer.write_varint(hw, len(attributes))
@ -44,10 +44,7 @@ def serialize_transfer(transfer: OntologyTransfer) -> bytes:
struct = ParamStruct([from_address, to_address, amount])
native_call = build_native_call("transfer", [[struct]], contract)
# 9 is the maximum possible length of the uvarint prefix
ret = bytearray()
writer.write_bytes_with_length(ret, native_call)
return bytes(ret)
return native_call
def serialize_withdraw_ong(withdraw_ong: OntologyWithdrawOng) -> bytes:
@ -58,9 +55,7 @@ def serialize_withdraw_ong(withdraw_ong: OntologyWithdrawOng) -> bytes:
struct = ParamStruct([from_address, Const.ONT_CONTRACT, to_address, amount])
native_call = build_native_call("transferFrom", [struct], Const.ONG_CONTRACT)
ret = bytearray()
writer.write_bytes_with_length(ret, native_call)
return bytes(ret)
return native_call
def serialize_ont_id_register(register: OntologyOntIdRegister) -> bytes:
@ -71,9 +66,7 @@ def serialize_ont_id_register(register: OntologyOntIdRegister) -> bytes:
"regIDWithPublicKey", [struct], Const.ONTID_CONTRACT
)
ret = bytearray()
writer.write_bytes_with_length(ret, native_call)
return bytes(ret)
return native_call
def serialize_ont_id_add_attributes(add: OntologyOntIdAddAttributes) -> bytes:
@ -92,9 +85,7 @@ def serialize_ont_id_add_attributes(add: OntologyOntIdAddAttributes) -> bytes:
struct = ParamStruct(arguments)
native_call = build_native_call("addAttributes", [struct], Const.ONTID_CONTRACT)
ret = bytearray()
writer.write_bytes_with_length(ret, native_call)
return bytes(ret)
return native_call
def _serialize_tx_attribute(ret: bytearray, attribute: OntologyTxAttribute) -> None:

@ -1,4 +1,3 @@
from trezor import wire
from trezor.crypto.curve import nist256p1
from trezor.crypto.hashlib import sha256
from trezor.messages import OntologyAsset
@ -50,17 +49,14 @@ async def sign(raw_data: bytes, private_key: bytes) -> bytes:
async def sign_transfer(ctx, msg: OntologySignTx, keychain) -> OntologySignedTx:
if msg.transaction.type == 0xD1:
if msg.transfer.asset == OntologyAsset.ONT:
await require_confirm_transfer_ont(
ctx, msg.transfer.to_address, msg.transfer.amount
)
if msg.transfer.asset == OntologyAsset.ONG:
await require_confirm_transfer_ong(
ctx, msg.transfer.to_address, msg.transfer.amount
)
else:
raise wire.DataError("Invalid transaction type")
if msg.transfer.asset == OntologyAsset.ONT:
await require_confirm_transfer_ont(
ctx, msg.transfer.to_address, msg.transfer.amount
)
if msg.transfer.asset == OntologyAsset.ONG:
await require_confirm_transfer_ong(
ctx, msg.transfer.to_address, msg.transfer.amount
)
node = keychain.derive(msg.address_n, CURVE)
hw = HashWriter(sha256())
@ -68,14 +64,11 @@ async def sign_transfer(ctx, msg: OntologySignTx, keychain) -> OntologySignedTx:
serialize_tx(msg.transaction, serialized_payload, hw)
signature = await sign(hw.get_digest(), node.private_key())
return OntologySignedTx(signature=signature, payload=serialized_payload)
return OntologySignedTx(signature=signature)
async def sign_withdraw_ong(ctx, msg: OntologySignTx, keychain) -> OntologySignedTx:
if msg.transaction.type == 0xD1:
await require_confirm_withdraw_ong(ctx, msg.withdraw_ong.amount)
else:
raise wire.DataError("Invalid transaction type")
await require_confirm_withdraw_ong(ctx, msg.withdraw_ong.amount)
node = keychain.derive(msg.address_n, CURVE)
hw = HashWriter(sha256())
@ -83,16 +76,13 @@ async def sign_withdraw_ong(ctx, msg: OntologySignTx, keychain) -> OntologySigne
serialize_tx(msg.transaction, serialized_payload, hw)
signature = await sign(hw.get_digest(), node.private_key())
return OntologySignedTx(signature=signature, payload=serialized_payload)
return OntologySignedTx(signature=signature)
async def sign_ont_id_register(ctx, msg: OntologySignTx, keychain) -> OntologySignedTx:
if msg.transaction.type == 0xD1:
await require_confirm_ont_id_register(
ctx, msg.ont_id_register.ont_id, msg.ont_id_register.public_key
)
else:
raise wire.DataError("Invalid transaction type")
await require_confirm_ont_id_register(
ctx, msg.ont_id_register.ont_id, msg.ont_id_register.public_key
)
node = keychain.derive(msg.address_n, CURVE)
hw = HashWriter(sha256())
@ -100,21 +90,18 @@ async def sign_ont_id_register(ctx, msg: OntologySignTx, keychain) -> OntologySi
serialize_tx(msg.transaction, serialized_payload, hw)
signature = await sign(hw.get_digest(), node.private_key())
return OntologySignedTx(signature=signature, payload=serialized_payload)
return OntologySignedTx(signature=signature)
async def sign_ont_id_add_attributes(
ctx, msg: OntologySignTx, keychain
) -> OntologySignedTx:
if msg.transaction.type == 0xD1:
await require_confirm_ont_id_add_attributes(
ctx,
msg.ont_id_add_attributes.ont_id,
msg.ont_id_add_attributes.public_key,
msg.ont_id_add_attributes.ont_id_attributes,
)
else:
raise wire.DataError("Invalid transaction type")
await require_confirm_ont_id_add_attributes(
ctx,
msg.ont_id_add_attributes.ont_id,
msg.ont_id_add_attributes.public_key,
msg.ont_id_add_attributes.ont_id_attributes,
)
node = keychain.derive(msg.address_n, CURVE)
hw = HashWriter(sha256())
@ -122,4 +109,4 @@ async def sign_ont_id_add_attributes(
serialize_tx(msg.transaction, serialized_payload, hw)
signature = await sign(hw.get_digest(), node.private_key())
return OntologySignedTx(signature=signature, payload=serialized_payload)
return OntologySignedTx(signature=signature)

@ -16,14 +16,11 @@ class OntologySignedTx(p.MessageType):
def __init__(
self,
signature: bytes = None,
payload: bytes = None,
) -> None:
self.signature = signature
self.payload = payload
@classmethod
def get_fields(cls) -> Dict:
return {
1: ('signature', p.BytesType, 0),
2: ('payload', p.BytesType, 0),
}

@ -17,7 +17,6 @@ class OntologyTransaction(p.MessageType):
def __init__(
self,
version: int = None,
type: int = None,
nonce: int = None,
gas_price: int = None,
gas_limit: int = None,
@ -25,7 +24,6 @@ class OntologyTransaction(p.MessageType):
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
@ -36,10 +34,9 @@ class OntologyTransaction(p.MessageType):
def get_fields(cls) -> Dict:
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),
2: ('nonce', p.UVarintType, 0),
3: ('gas_price', p.UVarintType, 0),
4: ('gas_limit', p.UVarintType, 0),
5: ('payer', p.UnicodeType, 0),
6: ('tx_attributes', OntologyTxAttribute, p.FLAG_REPEATED),
}

@ -50,144 +50,54 @@ def get_public_key(connect, address, show_display):
return result.public_key.hex()
@cli.command(help="Sign Ontology transfer.")
@cli.command(help="Sign Ontology transaction.")
@click.option("-n", "--address", required=True, help=PATH_HELP)
@click.option(
"-t",
"-x",
"--transaction",
type=click.File("r"),
default="-",
help="Transaction in JSON format",
)
@click.option(
"-r",
"--transfer",
type=click.File("r"),
default="-",
help="Transfer in JSON format",
)
@click.pass_obj
def sign_transfer(connect, address, transaction, transfer):
client = connect()
address_n = tools.parse_path(address)
transaction = protobuf.dict_to_proto(
messages.OntologyTransaction, json.load(transaction)
)
transfer = protobuf.dict_to_proto(messages.OntologyTransfer, json.load(transfer))
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=PATH_HELP)
@click.option(
"-t",
"--transaction",
type=click.File("r"),
default="-",
help="Transaction in JSON format",
)
@click.option(
"-w",
"--withdraw_ong",
type=click.File("r"),
default="-",
help="Withdrawal in JSON format",
)
@click.pass_obj
def sign_withdraw_ong(connect, address, transaction, withdraw_ong):
client = connect()
address_n = tools.parse_path(address)
transaction = protobuf.dict_to_proto(
messages.OntologyTransaction, json.load(transaction)
)
withdraw_ong = protobuf.dict_to_proto(
messages.OntologyWithdrawOng, json.load(withdraw_ong)
)
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=PATH_HELP)
@click.option(
"-t",
"--transaction",
type=click.File("r"),
default="-",
required=True,
help="Transaction in JSON format",
)
@click.option(
"-r",
"--register",
type=click.File("r"),
default="-",
help="Register in JSON format",
"-t", "--transfer", type=click.File("r"), help="Transfer in JSON format",
)
@click.argument("transaction")
@click.argument("ont_id_register")
@click.pass_obj
def sign_ont_id_register(connect, address, transaction, register):
client = connect()
address_n = tools.parse_path(address)
transaction = protobuf.dict_to_proto(
messages.OntologyTransaction, json.load(transaction)
)
ont_id_register = protobuf.dict_to_proto(
messages.OntologyOntIdRegister, json.load(register)
)
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",
"-w", "--withdraw_ong", type=click.File("r"), help="Withdrawal in JSON format",
)
@click.option(
"-t",
"--transaction",
type=click.File("r"),
required=True,
default="-",
help="Transaction in JSON format",
"-r", "--register", type=click.File("r"), help="Register in JSON format",
)
@click.option(
"-a",
"--add_attribute",
type=click.File("r"),
required=True,
default="-",
help="Add attributes in JSON format",
"-a", "--attributes", type=click.File("r"), help="Add attributes in JSON format",
)
@click.pass_obj
def sign_ont_id_add_attributes(connect, address, transaction, add_attribute):
def sign_transaction(
connect, address, transaction, transfer, withdraw_ong, register, attributes
):
client = connect()
address_n = tools.parse_path(address)
transaction = protobuf.dict_to_proto(
messages.OntologyTransaction, json.load(transaction)
)
ont_id_add_attributes = protobuf.dict_to_proto(
messages.OntologyOntIdAddAttributes, json.load(add_attribute)
)
result = ontology.sign_add_attr(
client, address_n, transaction, ont_id_add_attributes
)
output = {"payload": result.payload.hex(), "signature": result.signature.hex()}
return output
if transfer is not None:
msg = protobuf.dict_to_proto(messages.OntologyTransfer, json.load(transfer))
elif withdraw_ong is not None:
msg = protobuf.dict_to_proto(
messages.OntologyWithdrawOng, json.load(withdraw_ong)
)
elif register is not None:
msg = protobuf.dict_to_proto(
messages.OntologyOntIdRegister, json.load(register)
)
elif attributes is not None:
msg = protobuf.dict_to_proto(
messages.OntologyOntIdAddAttributes, json.load(attributes)
)
else:
raise RuntimeError(
"No transaction operation specified, use one of -t, -w, -r or -a options"
)
return ontology.sign(client, address_n, transaction, msg).hex()

@ -16,14 +16,11 @@ class OntologySignedTx(p.MessageType):
def __init__(
self,
signature: bytes = None,
payload: bytes = None,
) -> None:
self.signature = signature
self.payload = payload
@classmethod
def get_fields(cls) -> Dict:
return {
1: ('signature', p.BytesType, 0),
2: ('payload', p.BytesType, 0),
}

@ -17,7 +17,6 @@ class OntologyTransaction(p.MessageType):
def __init__(
self,
version: int = None,
type: int = None,
nonce: int = None,
gas_price: int = None,
gas_limit: int = None,
@ -25,7 +24,6 @@ class OntologyTransaction(p.MessageType):
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
@ -36,10 +34,9 @@ class OntologyTransaction(p.MessageType):
def get_fields(cls) -> Dict:
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),
2: ('nonce', p.UVarintType, 0),
3: ('gas_price', p.UVarintType, 0),
4: ('gas_limit', p.UVarintType, 0),
5: ('payer', p.UnicodeType, 0),
6: ('tx_attributes', OntologyTxAttribute, p.FLAG_REPEATED),
}

@ -29,38 +29,34 @@ def get_address(client, address_n, show_display=False):
)
@expect(messages.OntologyPublicKey)
@expect(messages.OntologyPublicKey, field="public_key")
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.OntologySignedTx)
def sign_transfer(client, address_n, t, tr):
return client.call(
messages.OntologySignTx(address_n=address_n, transaction=t, transfer=tr)
)
@expect(messages.OntologySignedTx)
def sign_withdrawal(client, address_n, t, w):
return client.call(
messages.OntologySignTx(address_n=address_n, transaction=t, withdraw_ong=w)
)
@expect(messages.OntologySignedTx)
def sign_register(client, address_n, t, r):
return client.call(
messages.OntologySignTx(address_n=address_n, transaction=t, ont_id_register=r)
)
@expect(messages.OntologySignedTx)
def sign_add_attr(client, address_n, t, a):
return client.call(
messages.OntologySignTx(
address_n=address_n, transaction=t, ont_id_add_attributes=a
@expect(messages.OntologySignedTx, field="signature")
def sign(client, address_n, t, msg):
if isinstance(msg, messages.OntologyTransfer):
return client.call(
messages.OntologySignTx(address_n=address_n, transaction=t, transfer=msg)
)
elif isinstance(msg, messages.OntologyWithdrawOng):
return client.call(
messages.OntologySignTx(
address_n=address_n, transaction=t, withdraw_ong=msg
)
)
elif isinstance(msg, messages.OntologyOntIdRegister):
return client.call(
messages.OntologySignTx(
address_n=address_n, transaction=t, ont_id_register=msg
)
)
elif isinstance(msg, messages.OntologyOntIdAddAttributes):
return client.call(
messages.OntologySignTx(
address_n=address_n, transaction=t, ont_id_add_attributes=msg
)
)
)

@ -35,7 +35,6 @@ def test_ontology_sign_ont_id_add_attributes(client):
transaction = messages.OntologyTransaction(
version=0x00,
nonce=0x7F7F1CEB,
type=0xD1,
gas_price=500,
gas_limit=30000,
payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc",
@ -54,16 +53,11 @@ def test_ontology_sign_ont_id_add_attributes(client):
],
)
signature = ontology.sign_add_attr(
signature = ontology.sign(
client, parse_path("m/44'/1024'/0'/0/0"), transaction, ont_id_add_attributes
)
assert (
signature.payload.hex()
== "bd00c66b2a6469643a6f6e743a4147566e344e5a4e455137526177485444786a61546a5a33523868387131617139686a7cc8516a7cc80966697273744e616d656a7cc8046a736f6e6a7cc80d4a6f686e2053686570706172646a7cc82103a8269b0dad311d98195e76729bc57003348a315fd17b6bf4f90ba8b86735fa336a7cc86c0d616464417474726962757465731400000000000000000000000000000000000000030068164f6e746f6c6f67792e4e61746976652e496e766f6b65"
)
assert (
signature.signature.hex()
signature.hex()
== "01c256dc16d88685fd6652d69b808059f7ed30edadb0ccfe51802702b94b65500922f9ea80e0fd7b77b5c51515e3bc43a495b3e98fb3adb82a0ab5dd47169fcf4e"
)

@ -34,7 +34,6 @@ def test_ontology_sign_ont_id_register(client):
transaction = messages.OntologyTransaction(
version=0x00,
nonce=0x7F7F1CEB,
type=0xD1,
gas_price=500,
gas_limit=30000,
payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc",
@ -48,15 +47,11 @@ def test_ontology_sign_ont_id_register(client):
),
)
signature = ontology.sign_add_attr(
signature = ontology.sign(
client, parse_path("m/44'/1024'/0'/0/0"), transaction, ont_id_register
)
assert (
signature.payload.hex()
== "9800c66b2a6469643a6f6e743a4147566e344e5a4e455137526177485444786a61546a5a33523868387131617139686a7cc82103a8269b0dad311d98195e76729bc57003348a315fd17b6bf4f90ba8b86735fa336a7cc86c127265674944576974685075626c69634b65791400000000000000000000000000000000000000030068164f6e746f6c6f67792e4e61746976652e496e766f6b65"
)
assert (
signature.signature.hex()
signature.hex()
== "015d6abe231352d1ab32f0b0de0222cfb9a7a13f467a2bf8a369b61aa1f933dc3a6a2ba7831c8a15984fe0958d24cbca05d8e0736510c1734d773145ce3eac9e9b"
)

@ -32,7 +32,6 @@ def test_ontology_sign_transfer_ont(client):
transaction = messages.OntologyTransaction(
version=0x00,
nonce=0x7F7F1CEB,
type=0xD1,
gas_price=500,
gas_limit=30000,
payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc",
@ -46,15 +45,11 @@ def test_ontology_sign_transfer_ont(client):
to_address="AcyLq3tokVpkMBMLALVMWRdVJ83TTgBUwU",
)
signature = ontology.sign_transfer(
signature = ontology.sign(
client, parse_path("m/44'/1024'/0'/0/0"), transaction, transfer
)
assert (
signature.payload.hex()
== "7900c66b140b045b101bc9fabaf181e251a38e76b73962111b6a7cc814e885e849e7f545ea84e8c555b86c70e4f751c4ec6a7cc80864000000000000006a7cc86c51c1087472616e736665721400000000000000000000000000000000000000010068164f6e746f6c6f67792e4e61746976652e496e766f6b65"
)
assert (
signature.signature.hex()
signature.hex()
== "0102f9b0c43b2ed35aa89b0927a60e692cb8a74280c2da819a909150c8b3fd2b0b401806c97797fcc4b93d34f210ad01740cfd13b720a389a80f384c1f94fb749e"
)
@ -69,7 +64,6 @@ def test_ontology_sign_transfer_ong(client):
transaction = messages.OntologyTransaction(
version=0x00,
nonce=0x7F7F1CEB,
type=0xD1,
gas_price=500,
gas_limit=30000,
payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc",
@ -83,10 +77,10 @@ def test_ontology_sign_transfer_ong(client):
to_address="AcyLq3tokVpkMBMLALVMWRdVJ83TTgBUwU",
)
signature = ontology.sign_transfer(
signature = ontology.sign(
client, parse_path("m/44'/888'/0'/0/0"), transaction, transfer
)
assert (
signature.signature.hex()
signature.hex()
== "017da1b8268e1272d7471eef58fa0884108073c09d5efdae0143da5d281019682e5a1562f1d76484eb0379e3febe7025a958bb14855107b9ad26daec2fee0119f4"
)

@ -30,7 +30,6 @@ def test_ontology_sign_withdraw_ong(client):
transaction = messages.OntologyTransaction(
version=0x00,
nonce=0x7F7F1CEB,
type=0xD1,
gas_price=500,
gas_limit=30000,
payer="AGn8JFPGM5S4jkWhTC89Xtz1Y76sPz29Rc",
@ -43,14 +42,10 @@ def test_ontology_sign_withdraw_ong(client):
to_address="AcyLq3tokVpkMBMLALVMWRdVJ83TTgBUwU",
)
signature = ontology.sign_withdrawal(
signature = ontology.sign(
client, parse_path("m/44'/1024'/0'/0/0"), transaction, withdraw_ong
)
assert (
signature.payload.hex()
== "9300c66b140b045b101bc9fabaf181e251a38e76b73962111b6a7cc81400000000000000000000000000000000000000016a7cc814e885e849e7f545ea84e8c555b86c70e4f751c4ec6a7cc808001bb700000000006a7cc86c0c7472616e7366657246726f6d1400000000000000000000000000000000000000020068164f6e746f6c6f67792e4e61746976652e496e766f6b65"
)
assert (
signature.signature.hex()
signature.hex()
== "01a44355ac4549a021ecc571eb85ffb6ae4ff50cffc416ec55df40cad538fa55c64386167df2fb6b3fa9e698ebe265088839667b88da7e599ce7df679b0d5dfe60"
)

Loading…
Cancel
Save