Skip to content

Commit 53fb9f4

Browse files
PandaXadnaPclaude
andcommitted
docs(keystore): document default-account-only limitation of sealed signing
TWStoredKeySign / Keystore::sealedSign derive at the coin's DEFAULT derivation and DEFAULT account only. A custom derivation path or a non-default account is not yet supported — such a wallet would be signed with the default account's key and would not match its address. Record this as an explicit follow-up: - TWStoredKey.h: \note on the TWStoredKeySign contract - SealedSigner.cpp: TODO(S2.1 follow-up) at the derivation site Also add tools/run-sealed-tests to build + run the sealed-signing tests locally. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent e3c5c9b commit 53fb9f4

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

include/TrustWalletCore/TWStoredKey.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ struct TWPrivateKey* _Nullable TWStoredKeyPrivateKey(struct TWStoredKey* _Nonnul
362362
/// \param password Non-null block of data, password of the stored key
363363
/// \param input Non-null block of data, serialized SigningInput protobuf (without a private key)
364364
/// \note Returned object needs to be deleted with \TWDataDelete
365+
/// \note LIMITATION (S2.1): the key is derived at the coin's DEFAULT derivation and DEFAULT account.
366+
/// A custom derivation path or a non-default account is NOT yet supported — signing such a
367+
/// wallet here uses the default account's key and will not match its address. Passing the
368+
/// derivation/path through to wallet-core is a planned S2.1 follow-up.
365369
/// \return Null pointer on failure or if the coin is not supported by the sealed path; serialized SigningOutput otherwise
366370
TW_EXPORT_METHOD
367371
TWData* _Nullable TWStoredKeySign(struct TWStoredKey* _Nonnull key, enum TWCoinType coin, TWData* _Nonnull password, TWData* _Nonnull input);

src/Keystore/SealedSigner.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ Data sealedSign(StoredKey& storedKey, TWCoinType coin, const Data& password, con
4242
// (1) Decrypt + derive the signing key ONCE, inside the library.
4343
// (Account-based coins need a single key; the UTXO multi-key path — decrypt once, derive
4444
// many from the in-memory HDWallet — is added in a later increment.)
45+
//
46+
// TODO(S2.1 follow-up): this derives at the coin's DEFAULT derivation and DEFAULT account only.
47+
// A custom derivation path or a non-default account is not yet threaded through, so signing
48+
// such a wallet uses the default account's key and won't match its address. Add a
49+
// derivation/path parameter (see claude-handoff-S2-UTXO-sealed-sign-findings.md) so callers on
50+
// custom paths / multi-account wallets are supported.
4551
PrivateKey privateKey = storedKey.privateKey(coin, password);
4652

4753
// (2) Inject the key into the coin's SigningInput proto.

tools/run-sealed-tests

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Build the C++ tests and run the sealed-signing (Security Layer S2.1) tests.
4+
#
5+
# Usage:
6+
# tools/run-sealed-tests # run *SealedSigner* + *TWStoredKeySign*
7+
# tools/run-sealed-tests "*Ethereum*" # custom gtest filter
8+
#
9+
set -e
10+
11+
cd "$(dirname "$0")/.."
12+
13+
# cmake needs BOOST_ROOT (brew boost) on macOS; make rust/protoc reachable for fresh shells.
14+
if command -v brew >/dev/null 2>&1; then
15+
export BOOST_ROOT="${BOOST_ROOT:-$(brew --prefix boost 2>/dev/null)}"
16+
fi
17+
export PATH="/opt/homebrew/opt/rustup/bin:$HOME/.cargo/bin:$PWD/build/local/bin:$PATH"
18+
19+
FILTER="${1:-*SealedSigner*:*TWStoredKeySign*}"
20+
21+
# Configure once if the build tree isn't there yet.
22+
if [ ! -f build/CMakeCache.txt ]; then
23+
cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
24+
fi
25+
26+
make -Cbuild -j12 tests
27+
./build/tests/tests --gtest_filter="$FILTER"

0 commit comments

Comments
 (0)