Skip to content

Generate Evolu keys #5220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions common/protob/messages-evolu.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

syntax = "proto2";
package hw.trezor.messages.evolu;

// Sugar for easier handling in Java
option java_package = "com.satoshilabs.trezor.lib.protobuf";
option java_outer_classname = "TrezorMessageEvolu";

/**
* Request: Ask the device for the SLIP-21 node for Evolu, a local first storage
* framework. See https://github.com/evoluhq/evolu
* @start
* @next EvoluNode
*/
message EvoluGetNode {
}

/**
* Response: Evolu SLIP-21 node
* @end
*/
message EvoluNode {
required bytes data = 1;
}
4 changes: 4 additions & 0 deletions common/protob/messages.proto
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,10 @@ enum MessageType {
MessageType_NostrSignEvent = 2003 [(wire_in) = true];
MessageType_NostrEventSignature = 2004 [(wire_out) = true];

// Evolu
MessageType_EvoluGetNode = 2100 [(wire_in) = true];
MessageType_EvoluNode = 2101 [(wire_out) = true];

// Benchmark
MessageType_BenchmarkListNames = 9100 [(bitcoin_only) = true];
MessageType_BenchmarkNames = 9101 [(bitcoin_only) = true];
Expand Down
1 change: 1 addition & 0 deletions core/.changelog.d/5220.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Generation of SLIP-21 node for a new way of storing labels (using Evolu).
2 changes: 2 additions & 0 deletions core/embed/upymod/qstrdefsport.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ Q(apps.misc)
Q(apps.misc.cipher_key_value)
Q(apps.misc.get_ecdh_session_key)
Q(apps.misc.get_entropy)
Q(apps.misc.get_evolu_node)
Q(apps.misc.get_firmware_hash)
Q(apps.misc.payment_notification)
Q(apps.misc.sign_identity)
Expand Down Expand Up @@ -218,6 +219,7 @@ Q(fido2)
Q(get_address)
Q(get_ecdh_session_key)
Q(get_entropy)
Q(get_evolu_node)
Q(get_firmware_hash)
Q(get_next_u2f_counter)
Q(get_nonce)
Expand Down
31 changes: 31 additions & 0 deletions core/src/apps/misc/get_evolu_node.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from trezor.messages import EvoluGetNode, EvoluNode

_EVOLU_KEY_PATH_PREFIX = [b"TREZOR", b"Evolu"]


async def get_evolu_node(_msg: EvoluGetNode) -> EvoluNode:
from storage.device import is_initialized
from trezor.messages import EvoluNode
from trezor.ui.layouts import confirm_action
from trezor.wire import NotInitialized

from apps.common.seed import Slip21Node, get_seed

if not is_initialized():
raise NotInitialized("Device is not initialized")

# TODO: use translated strings when exposing this to production
await confirm_action(
"get_evolu_keys",
"Evolu node",
action="Derive SLIP-21 node for Evolu?",
prompt_screen=True,
)
seed = await get_seed()
node = Slip21Node(seed)
node.derive_path(_EVOLU_KEY_PATH_PREFIX)

return EvoluNode(data=node.data)
2 changes: 2 additions & 0 deletions core/src/apps/workflow_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ def _find_message_handler_module(msg_type: int) -> str:
return "apps.misc.cipher_key_value"
if msg_type == MessageType.GetFirmwareHash:
return "apps.misc.get_firmware_hash"
if msg_type == MessageType.EvoluGetNode:
return "apps.misc.get_evolu_node"

if not utils.BITCOIN_ONLY:
# When promoting the Nostr app to production-level
Expand Down
2 changes: 2 additions & 0 deletions core/src/trezor/enums/MessageType.py

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

2 changes: 2 additions & 0 deletions core/src/trezor/enums/__init__.py

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

20 changes: 20 additions & 0 deletions core/src/trezor/messages.py

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

2 changes: 1 addition & 1 deletion legacy/firmware/protob/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SKIPPED_MESSAGES := Cardano DebugMonero Eos Monero Ontology Ripple SdProtect Tez
SetBrightness DebugLinkOptigaSetSecMax \
BenchmarkListNames BenchmarkRun BenchmarkNames BenchmarkResult \
NostrGetPubkey NostrPubkey NostrSignEvent NostrEventSignature \
BleUnpair PaymentNotification
BleUnpair PaymentNotification EvoluGetNode EvoluNode

ifeq ($(BITCOIN_ONLY), 1)
SKIPPED_MESSAGES += Ethereum NEM Stellar
Expand Down
47 changes: 47 additions & 0 deletions python/src/trezorlib/cli/evolu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2025 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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>.

from __future__ import annotations

import typing as t

import click

from .. import evolu, messages
from . import with_session

if t.TYPE_CHECKING:
from ..transport.session import Session


@click.group(name="evolu")
def cli() -> None:
"""Evolu commands. Evolu is a local first storage framework. See https://github.com/evoluhq/evolu"""


@cli.command()
@with_session
def get_node(
session: "Session",
) -> dict[str, str]:
"""Return the SLIP-21 node for Evolu."""

node: messages.EvoluNode = evolu.get_evolu_node(
session,
)
return {
"data": node.data.hex(),
}
2 changes: 2 additions & 0 deletions python/src/trezorlib/cli/trezorctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
device,
eos,
ethereum,
evolu,
fido,
firmware,
monero,
Expand Down Expand Up @@ -410,6 +411,7 @@ def wait_for_emulator(obj: TrezorConnection, timeout: float) -> None:
cli.add_command(device.cli)
cli.add_command(eos.cli)
cli.add_command(ethereum.cli)
cli.add_command(evolu.cli)
cli.add_command(fido.cli)
cli.add_command(monero.cli)
cli.add_command(nem.cli)
Expand Down
30 changes: 30 additions & 0 deletions python/src/trezorlib/evolu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file is part of the Trezor project.
#
# Copyright (C) 2012-2025 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# 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>.


from typing import TYPE_CHECKING

from . import messages

if TYPE_CHECKING:
from .transport.session import Session


def get_evolu_node(session: "Session") -> messages.EvoluNode:
return session.call(
messages.EvoluGetNode(),
expect=messages.EvoluNode,
)
20 changes: 20 additions & 0 deletions python/src/trezorlib/messages.py

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

1 change: 1 addition & 0 deletions rust/trezor-client/scripts/build_messages
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ FEATURES = {
#
"Cardano": "cardano",
"EOS": "eos",
"Evolu": "evolu",
"Monero": "monero",
"NEM": "nem",
"Nostr": "nostr",
Expand Down
6 changes: 6 additions & 0 deletions rust/trezor-client/src/messages/generated.rs

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

24 changes: 19 additions & 5 deletions rust/trezor-client/src/protos/generated/messages.rs

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

Loading
Loading