1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-18 05:28:40 +00:00

Revert "feat(common): mark CoSi fields as required"

This reverts commit ce307c9484.
This commit is contained in:
tychovrahe 2022-11-08 14:57:43 +01:00
parent 1ea05a0018
commit 1861acaca1
4 changed files with 31 additions and 27 deletions

View File

@ -106,8 +106,8 @@ message CosiCommit {
* @end * @end
*/ */
message CosiCommitment { message CosiCommitment {
required bytes commitment = 1; // Commitment optional bytes commitment = 1; // Commitment
required bytes pubkey = 2; // Public key optional bytes pubkey = 2; // Public key
} }
/** /**
@ -118,9 +118,9 @@ message CosiCommitment {
*/ */
message CosiSign { message CosiSign {
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
required bytes data = 2; // Data to be signed optional bytes data = 2; // Data to be signed
required bytes global_commitment = 3; // Aggregated commitment optional bytes global_commitment = 3; // Aggregated commitment
required bytes global_pubkey = 4; // Aggregated public key optional bytes global_pubkey = 4; // Aggregated public key
} }
/** /**

View File

@ -1993,14 +1993,14 @@ if TYPE_CHECKING:
return isinstance(msg, cls) return isinstance(msg, cls)
class CosiCommitment(protobuf.MessageType): class CosiCommitment(protobuf.MessageType):
commitment: "bytes" commitment: "bytes | None"
pubkey: "bytes" pubkey: "bytes | None"
def __init__( def __init__(
self, self,
*, *,
commitment: "bytes", commitment: "bytes | None" = None,
pubkey: "bytes", pubkey: "bytes | None" = None,
) -> None: ) -> None:
pass pass
@ -2010,17 +2010,17 @@ if TYPE_CHECKING:
class CosiSign(protobuf.MessageType): class CosiSign(protobuf.MessageType):
address_n: "list[int]" address_n: "list[int]"
data: "bytes" data: "bytes | None"
global_commitment: "bytes" global_commitment: "bytes | None"
global_pubkey: "bytes" global_pubkey: "bytes | None"
def __init__( def __init__(
self, self,
*, *,
data: "bytes",
global_commitment: "bytes",
global_pubkey: "bytes",
address_n: "list[int] | None" = None, address_n: "list[int] | None" = None,
data: "bytes | None" = None,
global_commitment: "bytes | None" = None,
global_pubkey: "bytes | None" = None,
) -> None: ) -> None:
pass pass

View File

@ -276,6 +276,8 @@ void fsm_msgCosiCommit(const CosiCommit *msg) {
cosi_nonce_is_set = true; cosi_nonce_is_set = true;
} }
resp->has_commitment = true;
resp->has_pubkey = true;
resp->commitment.size = 32; resp->commitment.size = 32;
resp->pubkey.size = 32; resp->pubkey.size = 32;
@ -291,9 +293,11 @@ void fsm_msgCosiSign(const CosiSign *msg) {
CHECK_INITIALIZED 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")); _("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) { if (!cosi_nonce_is_set) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("CoSi nonce not set")); fsm_sendFailure(FailureType_Failure_ProcessError, _("CoSi nonce not set"));

View File

@ -3027,15 +3027,15 @@ class CosiCommit(protobuf.MessageType):
class CosiCommitment(protobuf.MessageType): class CosiCommitment(protobuf.MessageType):
MESSAGE_WIRE_TYPE = 72 MESSAGE_WIRE_TYPE = 72
FIELDS = { FIELDS = {
1: protobuf.Field("commitment", "bytes", repeated=False, required=True), 1: protobuf.Field("commitment", "bytes", repeated=False, required=False, default=None),
2: protobuf.Field("pubkey", "bytes", repeated=False, required=True), 2: protobuf.Field("pubkey", "bytes", repeated=False, required=False, default=None),
} }
def __init__( def __init__(
self, self,
*, *,
commitment: "bytes", commitment: Optional["bytes"] = None,
pubkey: "bytes", pubkey: Optional["bytes"] = None,
) -> None: ) -> None:
self.commitment = commitment self.commitment = commitment
self.pubkey = pubkey self.pubkey = pubkey
@ -3045,18 +3045,18 @@ class CosiSign(protobuf.MessageType):
MESSAGE_WIRE_TYPE = 73 MESSAGE_WIRE_TYPE = 73
FIELDS = { FIELDS = {
1: protobuf.Field("address_n", "uint32", repeated=True, required=False, default=None), 1: protobuf.Field("address_n", "uint32", repeated=True, required=False, default=None),
2: protobuf.Field("data", "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=True), 3: protobuf.Field("global_commitment", "bytes", repeated=False, required=False, default=None),
4: protobuf.Field("global_pubkey", "bytes", repeated=False, required=True), 4: protobuf.Field("global_pubkey", "bytes", repeated=False, required=False, default=None),
} }
def __init__( def __init__(
self, self,
*, *,
data: "bytes",
global_commitment: "bytes",
global_pubkey: "bytes",
address_n: Optional[Sequence["int"]] = None, address_n: Optional[Sequence["int"]] = None,
data: Optional["bytes"] = None,
global_commitment: Optional["bytes"] = None,
global_pubkey: Optional["bytes"] = None,
) -> None: ) -> None:
self.address_n: Sequence["int"] = address_n if address_n is not None else [] self.address_n: Sequence["int"] = address_n if address_n is not None else []
self.data = data self.data = data