Skip to content

Commit

Permalink
cardano: allow serialization using 258-tagged sets
Browse files Browse the repository at this point in the history
Since the Conway era, the CBOR serialization of inputs and certificates
can optionally be tagged with the 258-tag. This will become mandatory
in a future hardfork.

- https://github.com/IntersectMBO/cardano-ledger/blob/6e2d37cc0f47bd02e89b4ce9f78b59c35c958e96/eras/conway/impl/cddl-files/extra.cddl#L5
- https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml

The protobuf field is named `tag_cbor_sets` to be consistent with
other tooling that names it the same way: https://github.com/vacuumlabs/ledgerjs-cardano-shelley/blob/4a59d8818402a1d1d4c9939a6a8f606940f51d55/src/types/public.ts#L1874

This change is needed now as some wallets/tools already use this tag,
e.g. delegating to a drep using the https://gov.tools/ DApp.
  • Loading branch information
benma committed Dec 30, 2024
1 parent 57f6795 commit a6bbbc5
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 77 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ customers cannot upgrade their bootloader, its changes are recorded separately.
- Update manufacturer HID descriptor to bitbox.swiss
- Ethereum: remove deprecated Goerli network
- SD card: solve backup bug when sd card is re-inserted
- Cardano: allow serialization using 258-tagged sets

### 9.21.0
- Bitcoin: add support for sending to silent payment (BIP-352) addresses
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ endif()
#
# Versions MUST contain three parts and start with lowercase 'v'.
# Example 'v1.0.0'. They MUST not contain a pre-release label such as '-beta'.
set(FIRMWARE_VERSION "v9.21.0")
set(FIRMWARE_BTC_ONLY_VERSION "v9.21.0")
set(FIRMWARE_VERSION "v9.22.0")
set(FIRMWARE_BTC_ONLY_VERSION "v9.22.0")
set(BOOTLOADER_VERSION "v1.0.7")

find_package(PythonInterp 3.6 REQUIRED)
Expand Down
3 changes: 3 additions & 0 deletions messages/cardano.proto
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ message CardanoSignTransactionRequest {
repeated Withdrawal withdrawals = 7;
uint64 validity_interval_start = 8;
bool allow_zero_ttl = 9; // include ttl even if it is zero
// Tag arrays in the transaction serialization with the 258 tag.
// See https://github.com/IntersectMBO/cardano-ledger/blob/6e2d37cc0f47bd02e89b4ce9f78b59c35c958e96/eras/conway/impl/cddl-files/extra.cddl#L5
bool tag_cbor_sets = 10;
}

message CardanoSignTransactionResponse {
Expand Down
2 changes: 2 additions & 0 deletions py/bitbox02/bitbox02/bitbox02/bitbox02.py
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,8 @@ def cardano_address(self, address: cardano.CardanoAddressRequest) -> str:
def cardano_sign_transaction(
self, transaction: cardano.CardanoSignTransactionRequest
) -> cardano.CardanoSignTransactionResponse:
if transaction.tag_cbor_sets:
self._require_atleast(semver.VersionInfo(9, 22, 0))
request = cardano.CardanoRequest(sign_transaction=transaction)
return self._cardano_msg_query(
request, expected_response="sign_transaction"
Expand Down
60 changes: 30 additions & 30 deletions py/bitbox02/bitbox02/communication/generated/cardano_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion py/bitbox02/bitbox02/communication/generated/cardano_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ class CardanoSignTransactionRequest(google.protobuf.message.Message):
WITHDRAWALS_FIELD_NUMBER: builtins.int
VALIDITY_INTERVAL_START_FIELD_NUMBER: builtins.int
ALLOW_ZERO_TTL_FIELD_NUMBER: builtins.int
TAG_CBOR_SETS_FIELD_NUMBER: builtins.int
network: global___CardanoNetwork.ValueType
@property
def inputs(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___CardanoSignTransactionRequest.Input]: ...
Expand All @@ -297,6 +298,7 @@ class CardanoSignTransactionRequest(google.protobuf.message.Message):
allow_zero_ttl: builtins.bool
"""include ttl even if it is zero"""

tag_cbor_sets: builtins.bool
def __init__(self,
*,
network: global___CardanoNetwork.ValueType = ...,
Expand All @@ -308,8 +310,9 @@ class CardanoSignTransactionRequest(google.protobuf.message.Message):
withdrawals: typing.Optional[typing.Iterable[global___CardanoSignTransactionRequest.Withdrawal]] = ...,
validity_interval_start: builtins.int = ...,
allow_zero_ttl: builtins.bool = ...,
tag_cbor_sets: builtins.bool = ...,
) -> None: ...
def ClearField(self, field_name: typing_extensions.Literal["allow_zero_ttl",b"allow_zero_ttl","certificates",b"certificates","fee",b"fee","inputs",b"inputs","network",b"network","outputs",b"outputs","ttl",b"ttl","validity_interval_start",b"validity_interval_start","withdrawals",b"withdrawals"]) -> None: ...
def ClearField(self, field_name: typing_extensions.Literal["allow_zero_ttl",b"allow_zero_ttl","certificates",b"certificates","fee",b"fee","inputs",b"inputs","network",b"network","outputs",b"outputs","tag_cbor_sets",b"tag_cbor_sets","ttl",b"ttl","validity_interval_start",b"validity_interval_start","withdrawals",b"withdrawals"]) -> None: ...
global___CardanoSignTransactionRequest = CardanoSignTransactionRequest

class CardanoSignTransactionResponse(google.protobuf.message.Message):
Expand Down
Loading

0 comments on commit a6bbbc5

Please sign in to comment.