diff --git a/common/protob/messages-crypto.proto b/common/protob/messages-crypto.proto index f33f9609e..4953e6159 100644 --- a/common/protob/messages-crypto.proto +++ b/common/protob/messages-crypto.proto @@ -106,8 +106,8 @@ message CosiCommit { * @end */ message CosiCommitment { - required bytes commitment = 1; // Commitment - required bytes pubkey = 2; // Public key + optional bytes commitment = 1; // Commitment + optional bytes pubkey = 2; // Public key } /** @@ -118,9 +118,9 @@ message CosiCommitment { */ message CosiSign { repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node - required bytes data = 2; // Data to be signed - required bytes global_commitment = 3; // Aggregated commitment - required bytes global_pubkey = 4; // Aggregated public key + optional bytes data = 2; // Data to be signed + optional bytes global_commitment = 3; // Aggregated commitment + optional bytes global_pubkey = 4; // Aggregated public key } /** diff --git a/core/src/trezor/messages.py b/core/src/trezor/messages.py index 0d6e7327b..eef91ff02 100644 --- a/core/src/trezor/messages.py +++ b/core/src/trezor/messages.py @@ -1993,14 +1993,14 @@ if TYPE_CHECKING: return isinstance(msg, cls) class CosiCommitment(protobuf.MessageType): - commitment: "bytes" - pubkey: "bytes" + commitment: "bytes | None" + pubkey: "bytes | None" def __init__( self, *, - commitment: "bytes", - pubkey: "bytes", + commitment: "bytes | None" = None, + pubkey: "bytes | None" = None, ) -> None: pass @@ -2010,17 +2010,17 @@ if TYPE_CHECKING: class CosiSign(protobuf.MessageType): address_n: "list[int]" - data: "bytes" - global_commitment: "bytes" - global_pubkey: "bytes" + data: "bytes | None" + global_commitment: "bytes | None" + global_pubkey: "bytes | None" def __init__( self, *, - data: "bytes", - global_commitment: "bytes", - global_pubkey: "bytes", address_n: "list[int] | None" = None, + data: "bytes | None" = None, + global_commitment: "bytes | None" = None, + global_pubkey: "bytes | None" = None, ) -> None: pass diff --git a/legacy/firmware/fsm_msg_crypto.h b/legacy/firmware/fsm_msg_crypto.h index 3aa52dd95..72f2cdb28 100644 --- a/legacy/firmware/fsm_msg_crypto.h +++ b/legacy/firmware/fsm_msg_crypto.h @@ -276,6 +276,8 @@ void fsm_msgCosiCommit(const CosiCommit *msg) { cosi_nonce_is_set = true; } + resp->has_commitment = true; + resp->has_pubkey = true; resp->commitment.size = 32; resp->pubkey.size = 32; @@ -291,9 +293,11 @@ void fsm_msgCosiSign(const CosiSign *msg) { CHECK_INITIALIZED - CHECK_PARAM(msg->global_commitment.size == 32, + CHECK_PARAM(msg->has_data, _("No data provided")); + CHECK_PARAM(msg->has_global_commitment && msg->global_commitment.size == 32, _("Invalid global commitment")); - CHECK_PARAM(msg->global_pubkey.size == 32, _("Invalid global pubkey")); + CHECK_PARAM(msg->has_global_pubkey && msg->global_pubkey.size == 32, + _("Invalid global pubkey")); if (!cosi_nonce_is_set) { fsm_sendFailure(FailureType_Failure_ProcessError, _("CoSi nonce not set")); diff --git a/python/src/trezorlib/messages.py b/python/src/trezorlib/messages.py index 480614241..cbb4846fd 100644 --- a/python/src/trezorlib/messages.py +++ b/python/src/trezorlib/messages.py @@ -3027,15 +3027,15 @@ class CosiCommit(protobuf.MessageType): class CosiCommitment(protobuf.MessageType): MESSAGE_WIRE_TYPE = 72 FIELDS = { - 1: protobuf.Field("commitment", "bytes", repeated=False, required=True), - 2: protobuf.Field("pubkey", "bytes", repeated=False, required=True), + 1: protobuf.Field("commitment", "bytes", repeated=False, required=False, default=None), + 2: protobuf.Field("pubkey", "bytes", repeated=False, required=False, default=None), } def __init__( self, *, - commitment: "bytes", - pubkey: "bytes", + commitment: Optional["bytes"] = None, + pubkey: Optional["bytes"] = None, ) -> None: self.commitment = commitment self.pubkey = pubkey @@ -3045,18 +3045,18 @@ class CosiSign(protobuf.MessageType): MESSAGE_WIRE_TYPE = 73 FIELDS = { 1: protobuf.Field("address_n", "uint32", repeated=True, required=False, default=None), - 2: protobuf.Field("data", "bytes", repeated=False, required=True), - 3: protobuf.Field("global_commitment", "bytes", repeated=False, required=True), - 4: protobuf.Field("global_pubkey", "bytes", repeated=False, required=True), + 2: protobuf.Field("data", "bytes", repeated=False, required=False, default=None), + 3: protobuf.Field("global_commitment", "bytes", repeated=False, required=False, default=None), + 4: protobuf.Field("global_pubkey", "bytes", repeated=False, required=False, default=None), } def __init__( self, *, - data: "bytes", - global_commitment: "bytes", - global_pubkey: "bytes", address_n: Optional[Sequence["int"]] = None, + data: Optional["bytes"] = None, + global_commitment: Optional["bytes"] = None, + global_pubkey: Optional["bytes"] = None, ) -> None: self.address_n: Sequence["int"] = address_n if address_n is not None else [] self.data = data