mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-29 10:58:21 +00:00
tests: Add device test for a CoinJoin transaction which does not give the user's outputs a gain in anonymity.
This commit is contained in:
parent
07d9b780a6
commit
3cbfb98f38
@ -279,6 +279,94 @@ def test_unfair_fee(client):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_no_anonymity(client):
|
||||||
|
# Test CoinJoin transaction giving the user's outputs no gain in anonymity.
|
||||||
|
|
||||||
|
with client:
|
||||||
|
btc.authorize_coinjoin(
|
||||||
|
client,
|
||||||
|
coordinator="www.example.com",
|
||||||
|
max_total_fee=5005,
|
||||||
|
fee_per_anonymity=5000000, # 0.005 %
|
||||||
|
n=parse_path("m/84'/1'/0'"),
|
||||||
|
coin_name="Testnet",
|
||||||
|
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||||
|
)
|
||||||
|
|
||||||
|
inp1 = messages.TxInputType(
|
||||||
|
# seed "alcohol woman abuse must during monitor noble actual mixed trade anger aisle"
|
||||||
|
# 84'/1'/0'/0/0
|
||||||
|
# tb1qnspxpr2xj9s2jt6qlhuvdnxw6q55jvygcf89r2
|
||||||
|
amount=100000,
|
||||||
|
prev_hash=TXHASH_e5b7e2,
|
||||||
|
prev_index=0,
|
||||||
|
script_type=messages.InputScriptType.EXTERNAL,
|
||||||
|
ownership_proof=bytearray.fromhex(
|
||||||
|
"534c001900016b2055d8190244b2ed2d46513c40658a574d3bc2deb6969c0535bb818b44d2c40002483045022100d4ad0374c922848c71d913fba59c81b9075e0d33e884d953f0c4b4806b8ffd0c022024740e6717a2b6a5aa03148c3a28b02c713b4e30fc8aeae67fa69eb20e8ddcd9012103505f0d82bbdd251511591b34f36ad5eea37d3220c2b81a1189084431ddb3aa3d"
|
||||||
|
),
|
||||||
|
)
|
||||||
|
inp2 = messages.TxInputType(
|
||||||
|
address_n=parse_path("84'/1'/0'/1/0"),
|
||||||
|
amount=7289000,
|
||||||
|
prev_hash=TXHASH_65b811,
|
||||||
|
prev_index=1,
|
||||||
|
script_type=messages.InputScriptType.SPENDWITNESS,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Other's coinjoined output.
|
||||||
|
out1 = messages.TxOutputType(
|
||||||
|
address="tb1qk7j3ahs2v6hrv4v282cf0tvxh0vqq7rpt3zcml",
|
||||||
|
amount=30000,
|
||||||
|
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
||||||
|
)
|
||||||
|
# Other's coinjoined output.
|
||||||
|
out2 = messages.TxOutputType(
|
||||||
|
address="tb1q9cqhdr9ydetjzrct6tyeuccws9505hl96azwxk",
|
||||||
|
amount=30000,
|
||||||
|
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
||||||
|
)
|
||||||
|
# Our coinjoined output.
|
||||||
|
out3 = messages.TxOutputType(
|
||||||
|
address_n=parse_path("84'/1'/0'/1/1"),
|
||||||
|
amount=50000,
|
||||||
|
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
||||||
|
)
|
||||||
|
# Our coinjoined output.
|
||||||
|
out4 = messages.TxOutputType(
|
||||||
|
address_n=parse_path("84'/1'/0'/1/2"),
|
||||||
|
amount=50000,
|
||||||
|
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
||||||
|
)
|
||||||
|
# Our change output.
|
||||||
|
out5 = messages.TxOutputType(
|
||||||
|
address_n=parse_path("84'/1'/0'/1/2"),
|
||||||
|
amount=7289000 - 50000 - 50000 - 10 - 5000,
|
||||||
|
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
||||||
|
)
|
||||||
|
# Other's change output.
|
||||||
|
out6 = messages.TxOutputType(
|
||||||
|
address="tb1q9cqhdr9ydetjzrct6tyeuccws9505hl96azwxk",
|
||||||
|
amount=100000 - 30000 - 30000 - 6 - 5000,
|
||||||
|
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
||||||
|
)
|
||||||
|
# Coordinator's output.
|
||||||
|
out7 = messages.TxOutputType(
|
||||||
|
address="mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q",
|
||||||
|
amount=16,
|
||||||
|
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
||||||
|
)
|
||||||
|
|
||||||
|
with pytest.raises(TrezorFailure, match="No anonymity gain"):
|
||||||
|
btc.sign_tx(
|
||||||
|
client,
|
||||||
|
"Testnet",
|
||||||
|
[inp1, inp2],
|
||||||
|
[out1, out2, out3, out4, out5, out6, out7],
|
||||||
|
prev_txes=TX_CACHE_TESTNET,
|
||||||
|
preauthorized=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_wrong_coordinator(client):
|
def test_wrong_coordinator(client):
|
||||||
# Ensure that a preauthorized GetOwnershipProof fails if the commitment_data doesn't match the coordinator.
|
# Ensure that a preauthorized GetOwnershipProof fails if the commitment_data doesn't match the coordinator.
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
"test_msg_applysettings.py-test_apply_settings_passphrase": "5c1ed9a0be3d14475102d447da0b5d51bbb6dfaaeceff5ea9179064609db7870",
|
"test_msg_applysettings.py-test_apply_settings_passphrase": "5c1ed9a0be3d14475102d447da0b5d51bbb6dfaaeceff5ea9179064609db7870",
|
||||||
"test_msg_applysettings.py-test_apply_settings_passphrase_on_device": "3e6527e227bdde54f51bc9c417b176d0d87fdb6c40c4761368f50eb201b4beed",
|
"test_msg_applysettings.py-test_apply_settings_passphrase_on_device": "3e6527e227bdde54f51bc9c417b176d0d87fdb6c40c4761368f50eb201b4beed",
|
||||||
"test_msg_applysettings.py-test_safety_checks": "19bd500c3b791d51bbd1140085f306a838194593697529263f362acb0b1ab445",
|
"test_msg_applysettings.py-test_safety_checks": "19bd500c3b791d51bbd1140085f306a838194593697529263f362acb0b1ab445",
|
||||||
|
"test_msg_authorize_coinjoin.py::test_no_anonymity": "fd09da284b650e893990b95047b63a35b6b695fc5301d595f17a6d2cf9d90bcb",
|
||||||
"test_msg_authorize_coinjoin.py::test_sign_tx": "2838d4062333c241b6bbef7e680ec8a5764fe7bcaa41419e4141e146d3586a5d",
|
"test_msg_authorize_coinjoin.py::test_sign_tx": "2838d4062333c241b6bbef7e680ec8a5764fe7bcaa41419e4141e146d3586a5d",
|
||||||
"test_msg_authorize_coinjoin.py::test_unfair_fee": "62314e936de46a6caaf02c8eb20f6f471be6e79ca0c5450cad6f67f9cb823f2b",
|
"test_msg_authorize_coinjoin.py::test_unfair_fee": "62314e936de46a6caaf02c8eb20f6f471be6e79ca0c5450cad6f67f9cb823f2b",
|
||||||
"test_msg_authorize_coinjoin.py::test_wrong_coordinator": "d8a608beb6165f5667cc44dcff6bdc17ebb4638ddd3bd09e7f0e1e75d1e21135",
|
"test_msg_authorize_coinjoin.py::test_wrong_coordinator": "d8a608beb6165f5667cc44dcff6bdc17ebb4638ddd3bd09e7f0e1e75d1e21135",
|
||||||
|
Loading…
Reference in New Issue
Block a user