From 826ade2a8d6b4707b62b6e66126e92038834a904 Mon Sep 17 00:00:00 2001 From: David Misiak Date: Tue, 21 Feb 2023 19:26:25 +0100 Subject: [PATCH] chore(cardano): rename voting public key to vote public key --- common/protob/messages-cardano.proto | 6 ++-- .../fixtures/cardano/sign_tx.failed.json | 10 +++---- common/tests/fixtures/cardano/sign_tx.json | 16 +++++------ .../cardano/sign_tx.show_details.json | 6 ++-- core/src/apps/cardano/auxiliary_data.py | 28 +++++++++---------- core/src/apps/cardano/layout.py | 6 ++-- core/src/trezor/messages.py | 8 +++--- python/src/trezorlib/cardano.py | 8 +++--- python/src/trezorlib/messages.py | 12 ++++---- 9 files changed, 50 insertions(+), 50 deletions(-) diff --git a/common/protob/messages-cardano.proto b/common/protob/messages-cardano.proto index e1346c30c..9be21e0bf 100644 --- a/common/protob/messages-cardano.proto +++ b/common/protob/messages-cardano.proto @@ -361,7 +361,7 @@ message CardanoTxWithdrawal { * @embed */ message CardanoCVoteRegistrationDelegation { - required bytes voting_public_key = 1; + required bytes vote_public_key = 1; required uint32 weight = 2; } @@ -369,12 +369,12 @@ message CardanoCVoteRegistrationDelegation { * @embed */ message CardanoCVoteRegistrationParametersType { - optional bytes voting_public_key = 1; // mutually exclusive with delegations + optional bytes vote_public_key = 1; // mutually exclusive with delegations repeated uint32 staking_path = 2; optional CardanoAddressParametersType payment_address_parameters = 3; // mutually exclusive with payment_address required uint64 nonce = 4; optional CardanoCVoteRegistrationFormat format = 5 [default=CIP15]; - repeated CardanoCVoteRegistrationDelegation delegations = 6; // mutually exclusive with voting_public_key; max 32 delegations + repeated CardanoCVoteRegistrationDelegation delegations = 6; // mutually exclusive with vote_public_key; max 32 delegations optional uint64 voting_purpose = 7; optional string payment_address = 8; // mutually exclusive with payment_address_parameters } diff --git a/common/tests/fixtures/cardano/sign_tx.failed.json b/common/tests/fixtures/cardano/sign_tx.failed.json index 7762fdb99..89d52d692 100644 --- a/common/tests/fixtures/cardano/sign_tx.failed.json +++ b/common/tests/fixtures/cardano/sign_tx.failed.json @@ -1310,7 +1310,7 @@ "withdrawals": [], "auxiliary_data": { "cvote_registration_parameters": { - "voting_public_key": "3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7", + "vote_public_key": "3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7", "staking_path": "m/1852'/1815'/0'/2/0", "nonce": 22634813, "payment_address_parameters": { @@ -1360,7 +1360,7 @@ "auxiliary_data": { "hash": "ea4c91860dd5ec5449f8f985d227946ff39086b17f10b5afb93d12ee87050b6a", "cvote_registration_parameters": { - "voting_public_key": "38DA0B509D45BF6C87BD55594B92F97081D3923B8C1334B9B8D0BF13FC1C12D0", + "vote_public_key": "38DA0B509D45BF6C87BD55594B92F97081D3923B8C1334B9B8D0BF13FC1C12D0", "staking_path": "m/1852'/1815'/0'/2/0", "payment_address_parameters": { "addressType": 0, @@ -1399,7 +1399,7 @@ } }, { - "description": "transaction with both voting public key and delegations in cvote registration", + "description": "transaction with both vote public key and delegations in cvote registration", "parameters": { "protocol_magic": 764824073, "network_id": 1, @@ -1410,7 +1410,7 @@ "withdrawals": [], "auxiliary_data": { "cvote_registration_parameters": { - "voting_public_key": "38DA0B509D45BF6C87BD55594B92F97081D3923B8C1334B9B8D0BF13FC1C12D0", + "vote_public_key": "38DA0B509D45BF6C87BD55594B92F97081D3923B8C1334B9B8D0BF13FC1C12D0", "staking_path": "m/1852'/1815'/0'/2/0", "payment_address_parameters": { "addressType": 0, @@ -1421,7 +1421,7 @@ "format": 1, "delegations": [ { - "voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", + "vote_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "weight": 1 } ] diff --git a/common/tests/fixtures/cardano/sign_tx.json b/common/tests/fixtures/cardano/sign_tx.json index d1f59af4e..26cfa63af 100644 --- a/common/tests/fixtures/cardano/sign_tx.json +++ b/common/tests/fixtures/cardano/sign_tx.json @@ -1013,7 +1013,7 @@ "withdrawals": [], "auxiliary_data": { "cvote_registration_parameters": { - "voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", + "vote_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "staking_path": "m/1852'/1815'/0'/2/0", "payment_address_parameters": { "addressType": 0, @@ -1086,11 +1086,11 @@ "format": 1, "delegations": [ { - "voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", + "vote_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "weight": 1 }, { - "voting_public_key": "2af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", + "vote_public_key": "2af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "weight": 2 } ] @@ -1159,7 +1159,7 @@ "format": 1, "delegations": [ { - "voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", + "vote_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "weight": 1 } ], @@ -1224,7 +1224,7 @@ "format": 1, "delegations": [ { - "voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", + "vote_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "weight": 1 } ], @@ -1293,7 +1293,7 @@ "format": 1, "delegations": [ { - "voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", + "vote_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "weight": 1 } ] @@ -1357,7 +1357,7 @@ "format": 1, "delegations": [ { - "voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", + "vote_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "weight": 1 } ], @@ -1943,7 +1943,7 @@ "format": 1, "delegations": [ { - "voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", + "vote_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "weight": 1 } ], diff --git a/common/tests/fixtures/cardano/sign_tx.show_details.json b/common/tests/fixtures/cardano/sign_tx.show_details.json index 8720e598b..7d89e6ced 100644 --- a/common/tests/fixtures/cardano/sign_tx.show_details.json +++ b/common/tests/fixtures/cardano/sign_tx.show_details.json @@ -457,7 +457,7 @@ } }, { - "description": "transaction with CIP36 registration and voting purpose not specified", + "description": "transaction with CIP36 registration and vote purpose not specified", "parameters": { "protocol_magic": 764824073, "network_id": 1, @@ -478,11 +478,11 @@ "format": 1, "delegations": [ { - "voting_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", + "vote_public_key": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "weight": 1 }, { - "voting_public_key": "2af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", + "vote_public_key": "2af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", "weight": 2 } ] diff --git a/core/src/apps/cardano/auxiliary_data.py b/core/src/apps/cardano/auxiliary_data.py index 4440daeeb..050bc5dad 100644 --- a/core/src/apps/cardano/auxiliary_data.py +++ b/core/src/apps/cardano/auxiliary_data.py @@ -63,15 +63,15 @@ def _validate_cvote_registration_parameters( protocol_magic: int, network_id: int, ) -> None: - voting_key_fields_provided = 0 - if parameters.voting_public_key is not None: - voting_key_fields_provided += 1 - _validate_voting_public_key(parameters.voting_public_key) + vote_key_fields_provided = 0 + if parameters.vote_public_key is not None: + vote_key_fields_provided += 1 + _validate_vote_public_key(parameters.vote_public_key) if parameters.delegations: - voting_key_fields_provided += 1 + vote_key_fields_provided += 1 assert_cond(parameters.format == CardanoCVoteRegistrationFormat.CIP36) _validate_delegations(parameters.delegations) - assert_cond(voting_key_fields_provided == 1) + assert_cond(vote_key_fields_provided == 1) assert_cond(SCHEMA_STAKING_ANY_ACCOUNT.match(parameters.staking_path)) @@ -92,7 +92,7 @@ def _validate_cvote_registration_parameters( assert_cond(parameters.format == CardanoCVoteRegistrationFormat.CIP36) -def _validate_voting_public_key(key: bytes) -> None: +def _validate_vote_public_key(key: bytes) -> None: assert_cond(len(key) == _CVOTE_PUBLIC_KEY_LENGTH) @@ -101,7 +101,7 @@ def _validate_delegations( ) -> None: assert_cond(len(delegations) <= _MAX_DELEGATION_COUNT) for delegation in delegations: - _validate_voting_public_key(delegation.voting_public_key) + _validate_vote_public_key(delegation.vote_public_key) def _get_voting_purpose_to_serialize( @@ -158,7 +158,7 @@ async def _show_cvote_registration( for delegation in parameters.delegations: encoded_public_key = bech32.encode( - bech32.HRP_CVOTE_PUBLIC_KEY, delegation.voting_public_key + bech32.HRP_CVOTE_PUBLIC_KEY, delegation.vote_public_key ) await layout.confirm_cvote_registration_delegation( ctx, encoded_public_key, delegation.weight @@ -187,9 +187,9 @@ async def _show_cvote_registration( ) encoded_public_key: str | None = None - if parameters.voting_public_key: + if parameters.vote_public_key: encoded_public_key = bech32.encode( - bech32.HRP_CVOTE_PUBLIC_KEY, parameters.voting_public_key + bech32.HRP_CVOTE_PUBLIC_KEY, parameters.vote_public_key ) voting_purpose: int | None = ( @@ -271,11 +271,11 @@ def _get_signed_cvote_registration_payload( delegations_or_key: Delegations | bytes if len(parameters.delegations) > 0: delegations_or_key = [ - (delegation.voting_public_key, delegation.weight) + (delegation.vote_public_key, delegation.weight) for delegation in parameters.delegations ] - elif parameters.voting_public_key: - delegations_or_key = parameters.voting_public_key + elif parameters.vote_public_key: + delegations_or_key = parameters.vote_public_key else: raise RuntimeError # should not be reached - _validate_cvote_registration_parameters diff --git a/core/src/apps/cardano/layout.py b/core/src/apps/cardano/layout.py index 98c31a66a..7763ac866 100644 --- a/core/src/apps/cardano/layout.py +++ b/core/src/apps/cardano/layout.py @@ -818,14 +818,14 @@ async def confirm_cvote_registration_payment_address( async def confirm_cvote_registration( ctx: Context, - public_key: str | None, + vote_public_key: str | None, staking_path: list[int], nonce: int, voting_purpose: int | None, ) -> None: props: list[PropertyType] = [("Vote key registration (CIP-36)", None)] - if public_key is not None: - props.append(("Voting public key:", public_key)) + if vote_public_key is not None: + props.append(("Vote public key:", vote_public_key)) props.extend( [ ( diff --git a/core/src/trezor/messages.py b/core/src/trezor/messages.py index a3f12637a..943a032ff 100644 --- a/core/src/trezor/messages.py +++ b/core/src/trezor/messages.py @@ -1639,13 +1639,13 @@ if TYPE_CHECKING: return isinstance(msg, cls) class CardanoCVoteRegistrationDelegation(protobuf.MessageType): - voting_public_key: "bytes" + vote_public_key: "bytes" weight: "int" def __init__( self, *, - voting_public_key: "bytes", + vote_public_key: "bytes", weight: "int", ) -> None: pass @@ -1655,7 +1655,7 @@ if TYPE_CHECKING: return isinstance(msg, cls) class CardanoCVoteRegistrationParametersType(protobuf.MessageType): - voting_public_key: "bytes | None" + vote_public_key: "bytes | None" staking_path: "list[int]" payment_address_parameters: "CardanoAddressParametersType | None" nonce: "int" @@ -1670,7 +1670,7 @@ if TYPE_CHECKING: nonce: "int", staking_path: "list[int] | None" = None, delegations: "list[CardanoCVoteRegistrationDelegation] | None" = None, - voting_public_key: "bytes | None" = None, + vote_public_key: "bytes | None" = None, payment_address_parameters: "CardanoAddressParametersType | None" = None, format: "CardanoCVoteRegistrationFormat | None" = None, voting_purpose: "int | None" = None, diff --git a/python/src/trezorlib/cardano.py b/python/src/trezorlib/cardano.py index 75ca7ee75..4ec36b5a3 100644 --- a/python/src/trezorlib/cardano.py +++ b/python/src/trezorlib/cardano.py @@ -65,7 +65,7 @@ REQUIRED_FIELDS_CVOTE_REGISTRATION = ( "staking_path", "nonce", ) -REQUIRED_FIELDS_CVOTE_DELEGATION = ("voting_public_key", "weight") +REQUIRED_FIELDS_CVOTE_DELEGATION = ("vote_public_key", "weight") INCOMPLETE_OUTPUT_ERROR_MESSAGE = "The output is missing some fields" @@ -576,7 +576,7 @@ def parse_auxiliary_data( raise AUXILIARY_DATA_MISSING_FIELDS_ERROR delegations.append( messages.CardanoCVoteRegistrationDelegation( - voting_public_key=bytes.fromhex(delegation["voting_public_key"]), + vote_public_key=bytes.fromhex(delegation["vote_public_key"]), weight=int(delegation["weight"]), ) ) @@ -586,8 +586,8 @@ def parse_auxiliary_data( voting_purpose = cvote_registration.get("voting_purpose") cvote_registration_parameters = messages.CardanoCVoteRegistrationParametersType( - voting_public_key=parse_optional_bytes( - cvote_registration.get("voting_public_key") + vote_public_key=parse_optional_bytes( + cvote_registration.get("vote_public_key") ), staking_path=tools.parse_path(cvote_registration["staking_path"]), nonce=cvote_registration["nonce"], diff --git a/python/src/trezorlib/messages.py b/python/src/trezorlib/messages.py index abf4b4541..a9ecc2810 100644 --- a/python/src/trezorlib/messages.py +++ b/python/src/trezorlib/messages.py @@ -2639,24 +2639,24 @@ class CardanoTxWithdrawal(protobuf.MessageType): class CardanoCVoteRegistrationDelegation(protobuf.MessageType): MESSAGE_WIRE_TYPE = None FIELDS = { - 1: protobuf.Field("voting_public_key", "bytes", repeated=False, required=True), + 1: protobuf.Field("vote_public_key", "bytes", repeated=False, required=True), 2: protobuf.Field("weight", "uint32", repeated=False, required=True), } def __init__( self, *, - voting_public_key: "bytes", + vote_public_key: "bytes", weight: "int", ) -> None: - self.voting_public_key = voting_public_key + self.vote_public_key = vote_public_key self.weight = weight class CardanoCVoteRegistrationParametersType(protobuf.MessageType): MESSAGE_WIRE_TYPE = None FIELDS = { - 1: protobuf.Field("voting_public_key", "bytes", repeated=False, required=False, default=None), + 1: protobuf.Field("vote_public_key", "bytes", repeated=False, required=False, default=None), 2: protobuf.Field("staking_path", "uint32", repeated=True, required=False, default=None), 3: protobuf.Field("payment_address_parameters", "CardanoAddressParametersType", repeated=False, required=False, default=None), 4: protobuf.Field("nonce", "uint64", repeated=False, required=True), @@ -2672,7 +2672,7 @@ class CardanoCVoteRegistrationParametersType(protobuf.MessageType): nonce: "int", staking_path: Optional[Sequence["int"]] = None, delegations: Optional[Sequence["CardanoCVoteRegistrationDelegation"]] = None, - voting_public_key: Optional["bytes"] = None, + vote_public_key: Optional["bytes"] = None, payment_address_parameters: Optional["CardanoAddressParametersType"] = None, format: Optional["CardanoCVoteRegistrationFormat"] = CardanoCVoteRegistrationFormat.CIP15, voting_purpose: Optional["int"] = None, @@ -2681,7 +2681,7 @@ class CardanoCVoteRegistrationParametersType(protobuf.MessageType): self.staking_path: Sequence["int"] = staking_path if staking_path is not None else [] self.delegations: Sequence["CardanoCVoteRegistrationDelegation"] = delegations if delegations is not None else [] self.nonce = nonce - self.voting_public_key = voting_public_key + self.vote_public_key = vote_public_key self.payment_address_parameters = payment_address_parameters self.format = format self.voting_purpose = voting_purpose