1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-17 13:12:05 +00:00

feat(common): mark CoSi fields as required

[no changelog]
This commit is contained in:
matejcik 2022-10-20 15:51:16 +02:00 committed by matejcik
parent 1afc78e368
commit ce307c9484
4 changed files with 27 additions and 31 deletions

View File

@ -106,8 +106,8 @@ message CosiCommit {
* @end
*/
message CosiCommitment {
optional bytes commitment = 1; // Commitment
optional bytes pubkey = 2; // Public key
required bytes commitment = 1; // Commitment
required 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
optional bytes data = 2; // Data to be signed
optional bytes global_commitment = 3; // Aggregated commitment
optional bytes global_pubkey = 4; // Aggregated public key
required bytes data = 2; // Data to be signed
required bytes global_commitment = 3; // Aggregated commitment
required bytes global_pubkey = 4; // Aggregated public key
}
/**

View File

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

View File

@ -276,8 +276,6 @@ 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;
@ -293,11 +291,9 @@ void fsm_msgCosiSign(const CosiSign *msg) {
CHECK_INITIALIZED
CHECK_PARAM(msg->has_data, _("No data provided"));
CHECK_PARAM(msg->has_global_commitment && msg->global_commitment.size == 32,
CHECK_PARAM(msg->global_commitment.size == 32,
_("Invalid global commitment"));
CHECK_PARAM(msg->has_global_pubkey && msg->global_pubkey.size == 32,
_("Invalid global pubkey"));
CHECK_PARAM(msg->global_pubkey.size == 32, _("Invalid global pubkey"));
if (!cosi_nonce_is_set) {
fsm_sendFailure(FailureType_Failure_ProcessError, _("CoSi nonce not set"));

View File

@ -3020,15 +3020,15 @@ class CosiCommit(protobuf.MessageType):
class CosiCommitment(protobuf.MessageType):
MESSAGE_WIRE_TYPE = 72
FIELDS = {
1: protobuf.Field("commitment", "bytes", repeated=False, required=False, default=None),
2: protobuf.Field("pubkey", "bytes", repeated=False, required=False, default=None),
1: protobuf.Field("commitment", "bytes", repeated=False, required=True),
2: protobuf.Field("pubkey", "bytes", repeated=False, required=True),
}
def __init__(
self,
*,
commitment: Optional["bytes"] = None,
pubkey: Optional["bytes"] = None,
commitment: "bytes",
pubkey: "bytes",
) -> None:
self.commitment = commitment
self.pubkey = pubkey
@ -3038,18 +3038,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=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),
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),
}
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