Skip to content

Commit

Permalink
api: add support for BIP85-derived BIP39 mnemonics
Browse files Browse the repository at this point in the history
See
https://github.com/bitcoin/bips/blob/master/bip-0085.mediawiki#bip39.

Some of the other "apps" (derived secrets) using BIP-85 are not added
with this commit and may be added in the future. For now we add the
app that is probably used the most, which is deriving BIP-39
mnemonics.

The new protobuf messages are empty messages instead of reusing
e.g. the `Success {}` message so they can be extended in the future
without having to return different types of response
messages (e.g. Success OR a custom message).
  • Loading branch information
benma committed May 18, 2023
1 parent 3279c68 commit 18c96cc
Show file tree
Hide file tree
Showing 17 changed files with 315 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ customers cannot upgrade their bootloader, its changes are recorded separately.
### [Unreleased]
- Improved security: keep seed encrypted in RAM

### 9.15.0
- Add support for deriving BIP-39 mnemonics according to BIP-85.

### 9.14.0
- Improved touch button positional accuracy in noisy environments
- Increased performance when signing Bitcoin transactions
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ endif()
#
# Versions MUST contain three parts and start with lowercase 'v'.
# Example 'v1.0.0'. They MUST not contain a pre-release label such as '-beta'.
set(FIRMWARE_VERSION "v9.14.1")
set(FIRMWARE_BTC_ONLY_VERSION "v9.14.1")
set(FIRMWARE_VERSION "v9.15.0")
set(FIRMWARE_BTC_ONLY_VERSION "v9.15.0")
set(BOOTLOADER_VERSION "v1.0.5")

find_package(PythonInterp 3.6 REQUIRED)
Expand Down
2 changes: 2 additions & 0 deletions messages/hww.proto
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ message Request {
BTCRequest btc = 25;
ElectrumEncryptionKeyRequest electrum_encryption_key = 26;
CardanoRequest cardano = 27;
BIP85Request bip85 = 28;
}
}

Expand All @@ -87,5 +88,6 @@ message Response {
BTCResponse btc = 13;
ElectrumEncryptionKeyResponse electrum_encryption_key = 14;
CardanoResponse cardano = 15;
BIP85Response bip85 = 16;
}
}
6 changes: 6 additions & 0 deletions messages/keystore.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ message ElectrumEncryptionKeyRequest {
message ElectrumEncryptionKeyResponse {
string key = 1;
}

message BIP85Request {
}

message BIP85Response {
}
9 changes: 9 additions & 0 deletions py/bitbox02/bitbox02/bitbox02/bitbox02.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,15 @@ def electrum_encryption_key(self, keypath: Sequence[int]) -> str:
)
return self._msg_query(request).electrum_encryption_key.key

def bip85(self) -> None:
"""Invokes the BIP-85 workflow on the device"""
self._require_atleast(semver.VersionInfo(9, 15, 0))

# pylint: disable=no-member
request = hww.Request()
request.bip85.CopyFrom(keystore.BIP85Request())
self._msg_query(request)

def enable_mnemonic_passphrase(self) -> None:
"""
Enable the bip39 passphrase.
Expand Down
8 changes: 4 additions & 4 deletions py/bitbox02/bitbox02/communication/generated/hww_pb2.py

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

Loading

0 comments on commit 18c96cc

Please sign in to comment.