-
-
Notifications
You must be signed in to change notification settings - Fork 710
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
base: main
Are you sure you want to change the base?
Generate Evolu keys #5220
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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; | ||
} |
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). |
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) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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(), | ||
} |
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, | ||
) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.