1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-18 20:38:10 +00:00

chore(common): Deprecate data field in CosiCommit message.

This commit is contained in:
Andrew Kozlik 2022-06-23 09:27:48 +02:00 committed by matejcik
parent 70c1b12dff
commit ad5a572b75
6 changed files with 25 additions and 12 deletions

View File

@ -97,8 +97,8 @@ message ECDHSessionKey {
* @next Failure * @next Failure
*/ */
message CosiCommit { message CosiCommit {
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
optional bytes data = 2; // Data to be signed optional bytes data = 2 [deprecated=true]; // Data to be signed. Deprecated in 1.10.2, the field is not needed, since CoSi commitments are no longer deterministic.
} }
/** /**

View File

@ -1928,13 +1928,11 @@ if TYPE_CHECKING:
class CosiCommit(protobuf.MessageType): class CosiCommit(protobuf.MessageType):
address_n: "list[int]" address_n: "list[int]"
data: "bytes | None"
def __init__( def __init__(
self, self,
*, *,
address_n: "list[int] | None" = None, address_n: "list[int] | None" = None,
data: "bytes | None" = None,
) -> None: ) -> None:
pass pass

View File

@ -6,7 +6,7 @@ CipherKeyValue.iv max_size:16
CipheredKeyValue.value max_size:1024 CipheredKeyValue.value max_size:1024
CosiCommit.address_n max_count:8 CosiCommit.address_n max_count:8
CosiCommit.data max_size:32 CosiCommit.data type:FT_IGNORE
CosiCommitment.commitment max_size:32 CosiCommitment.commitment max_size:32
CosiCommitment.pubkey max_size:32 CosiCommitment.pubkey max_size:32

View File

@ -0,0 +1 @@
Remove DATA parameter from trezorctl cosi commit.

View File

@ -14,7 +14,8 @@
# You should have received a copy of the License along with this library. # You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>. # If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
from typing import TYPE_CHECKING import warnings
from typing import TYPE_CHECKING, Optional
import click import click
@ -35,14 +36,17 @@ def cli() -> None:
@cli.command() @cli.command()
@click.option("-n", "--address", required=True, help=PATH_HELP) @click.option("-n", "--address", required=True, help=PATH_HELP)
@click.argument("data") @click.argument("data_deprecated", required=False)
@with_client @with_client
def commit( def commit(
client: "TrezorClient", address: str, data: str client: "TrezorClient", address: str, data_deprecated: Optional[str]
) -> "messages.CosiCommitment": ) -> "messages.CosiCommitment":
"""Ask device to commit to CoSi signing.""" """Ask device to commit to CoSi signing."""
if data_deprecated is not None:
warnings.warn("'data' argument is deprecated")
address_n = tools.parse_path(address) address_n = tools.parse_path(address)
return cosi.commit(client, address_n, bytes.fromhex(data)) return cosi.commit(client, address_n)
@cli.command() @cli.command()

View File

@ -14,8 +14,9 @@
# You should have received a copy of the License along with this library. # You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>. # If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
import warnings
from functools import reduce from functools import reduce
from typing import TYPE_CHECKING, Iterable, List, Tuple from typing import TYPE_CHECKING, Iterable, List, Optional, Tuple
from . import _ed25519, messages from . import _ed25519, messages
from .tools import expect from .tools import expect
@ -141,8 +142,17 @@ def sign_with_privkey(
@expect(messages.CosiCommitment) @expect(messages.CosiCommitment)
def commit(client: "TrezorClient", n: "Address", data: bytes) -> "MessageType": def commit(
return client.call(messages.CosiCommit(address_n=n, data=data)) client: "TrezorClient", n: "Address", data: Optional[bytes] = None
) -> "MessageType":
if data is not None:
warnings.warn(
"'data' argument is deprecated",
DeprecationWarning,
stacklevel=2,
)
return client.call(messages.CosiCommit(address_n=n))
@expect(messages.CosiSignature) @expect(messages.CosiSignature)