Repository navigation
feat: Silent Payments (BIP-352) — address, descriptor and signing - #925
notTanveer wants to merge 11 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #925 +/- ##
===========================================
- Coverage 97.60% 97.56% -0.05%
===========================================
Files 84 85 +1
Lines 10994 11218 +224
===========================================
+ Hits 10731 10945 +214
- Misses 263 273 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
48aeeaf to
d8b3c47
Compare
|
Thxs @notTanveer/@odudex i will do a proper check on my side and LYN. |
47182e1 to
6fc2bb0
Compare
42925c9 to
2ddb821
Compare
|
all LGTM with sparrow against git submodule update --recursive
uv sync --frozen --reinstall-package=uUR
uv run poe secp256k1-build
uv run poe secp256k1-check
uv run poe pre-commit
./krux build-releaseAnd tested with Amigo only for now. |
|
Wow, this is so neat! The commonly used krux-devs' "gramps" wallet on signet now has a silent-payment tx: Continuing with testing, another tx exists in the same wallet sending 50k sats back to gramps native-segwit and collecting the rest into a different SP address as change: All working for me up to this point as-of commit 2ddb821, even though this PR is still in draft. Problem when paying to self (is that even something one would try?) I did provoke an error along the way, which is an odd-case (not a real use-case, or would it be de-consolidating?), |
had exact same error in a first try with other @notTanveer SP PR, with same context reported by you. |
this goes away once drongo#50 lands. it's a spec issue more than a sparrow one. bip-375's text says to sort the silent krux follows the text, so nothing changes on our side. drongo#50 moves sparrow to it only shows up when a tx has two or more sp outputs sharing a scan key, so paying |
thxs for feedback @notTanveer. I will give more check on those PRs. |
7bc9fa4 to
df03845
Compare
|
rebased |
I confirm that with Sparrow 2.5.4 and no changes (except for your rebase) to krux solves the issue where Sparrow errored upon scanning the signed SP input paying to an external address, its own SP address and one SP change address, is resolved. I had errors broadcasting but I suspect it is some new problem between Sparrow 2.5.4 and frigate 2.5.3. I was able to view the updated (extracted) tx and broadcast it via bitcoin-cli. Sparrow 2.5.4 had no problem identifying the new utxos while in mempool and once confirmed. Thank you! |
qlrd
left a comment
There was a problem hiding this comment.
just nit/doubt. IMP htis could be less (not too much) diff
b116bee to
0b2fda2
Compare
53bb486 to
cf49505
Compare
Pulls in the embit work the Silent Payments feature depends on: BIP-352 silent payment address generation and scanning BIP-370 PSBTv2 BIP-374 DLEQ proofs BIP-375 SP output derivation and PSBT fields BIP-376 spending from SP outputs BIP-392 sp() descriptor Also carries a bech32 fix for larger payloads and secp256k1 fixes for mutable keys in tweak functions plus ec_pubkey_tweak_mul/combine fallbacks. bech32_decode now raises Bech32DecodeError instead of returning a sentinel, so the Datum Tool is adapted in the same commit: every encoding probe against a non-bech32 payload would otherwise propagate out of _analyze_contents rather than simply ruling that encoding out. Catching it and treating it as "not bech32" is what the old sentinel return meant. Co-authored-by: odudex <odudex@proton.me>
Introduces TYPE_SILENT_PAYMENT alongside single-sig, multisig and
miniscript, wired through key derivation, the wallet model, settings and
the wallet-creation flow.
- Key derives the BIP-352 scan and spend keys from m/352h/<coin>h/<n>h
("/1h/0" scan, "/0h/0" spend) and exposes sp_address() and
sp_scan_key() for the sp() descriptor key expression.
- The policy always uses P2TR, so script_type is forced regardless of
what the caller passes.
- Wallet accepts an sp() descriptor and reports the new policy.
No UI for showing or exporting the address yet; that follows.
Adds the user-facing side of the Silent Payments policy.
- The address screen renders the sp1/tsp1 address as a Text/QR menu
with block highlighting, so the long address can be read out in
chunks and compared reliably.
- The public-key screen exports the BIP-352 scan key with its
[fingerprint/derivation] origin prefix on both the QR and the
SD/text paths, and exports the wallet as an sp(...) descriptor
rather than a bare key.
- The descriptor screen accepts and displays sp() descriptors.
display_addr_highlighted() grows a bg_color argument so the highlighted
blocks can be drawn against the address screen's background.
Co-authored-by: odudex <odudex@proton.me>
Krux acts as the BIP-375 Signer: it derives the Taproot output scripts,
attaches the global ECDH shares and DLEQ proofs, and hands back an
*unfinalized* PSBT so the coordinator can verify the outputs before
finalizing. embit finalizes taproot key-path inputs on signing, so the
inputs are explicitly cleared afterwards; leaving them finalized makes
coordinators skip the merge that picks up the derived output scripts.
Eligibility and ownership are checked while loading, not after review:
a PSBT this seed cannot sign is rejected up front. Only the BIP32 half
of the ownership check runs there -- the ECDH/DLEQ work happens once,
inside sign_with().
Also:
- P2PKH, P2SH-P2WPKH, P2WPKH and P2TR inputs are all supported.
- DLEQ aux_rand is hedged from the seed and the PSBT rather than the
K210 RNG. BIP-374 binds the proof nonce to the statement, so the
near-deterministic input is safe.
- The trimmed QR artifact keeps the SP outputs, ECDH shares and DLEQ
proofs but drops the coordinator-authored BIP-376 sp_tweak fields,
which would add ~70 bytes per input to the animated QR.
- Validation is now a single point for every load path; a validation
failure must never fall back to another encoding, which would
re-read the PSBT with CompressMode.CLEAR_ALL and strip the SP fields.
- Signing warns that the sp1/tsp1 address must be verified with the
recipient, never the derived P2TR shown on-chain.
Own SP change is not recognised yet, so SP outputs classify as spends;
that follows.
Co-authored-by: odudex <odudex@proton.me>
An SP output pays a derived P2TR that nobody but the recipient can link back to the SP address, so change sent to our own SP address would otherwise render as a spend to a stranger. Key.sp_detection_keys() derives the BIP-352 scan/spend keys from the seed for *any* wallet, not only ones loaded with the Silent Payments policy, so SP change is recognised even when the same seed was loaded as plain single-sig. A wallet using a non-default SP account simply fails the ownership check and the output stays a spend, which is the safe direction. own_sp_output_type() matches the output's scan key and then its spend key, applying the BIP-352 label tweak when the output carries one: label 0 is change, any other label is a self-transfer. The keys are derived once per PSBT and cached on the signer, since _classify_output needs them for every SP output and each derivation is two 5-level hardened BIP32 paths. de duplicated own_sp_output_type which was an identical copy of embit's apply_label and check_sighash() restored. Co-authored-by: odudex <odudex@proton.me>
Registers the new Silent Payments strings across the locale files and the baked translation modules. The ja-JP and zh-CN strings are worded to stay inside the glyph set the device fonts already carry, so no font rebuild is needed: they end in an ASCII period like the surrounding translations rather than U+3002, and avoid characters no other translation uses. `poe missing-glyphs` reports nothing missing, as on develop.
df84181 to
0ee9ac5
Compare
chore: bump embit - Bump vendor/embit to pick up strict SP network names, the DLEQ challenge fix and sp_output_scripts
- Derive the SP output scripts while loading the PSBT with embit's sp_output_scripts, replacing the hand-rolled ownership check - Add a review page after each SP output with the taproot address it lands on - Refuse to sign when a derived script differs from the one shown for review - Add the "Taproot address:" label to all translations - Add tests for the review page, the changed-after-review refusal and the foreign-input rejection at load
- Drop the sp() wallet descriptor and derive SP scan and spend keys from the account node - Warn only on SP outputs that pay someone else and treat only unlabeled and label 0 outputs as own - Clear only BIP-352 eligible inputs on sign so other signers' witnesses are kept - Repair zero fingerprints at PSBT load for every policy, including taproot odd-y and BIP-376 spend keys - Validate SD PSBTs on the first read and refuse the compressed fallback for SP PSBTs with foreign inputs - Stream the PSBT into the DLEQ nonce hash and dedupe the key text view and default derivation code - Add regression tests for odd-y taproot keys, labels, SD fallback paths and wallet settings
0ee9ac5 to
f13f76d
Compare
|
Currently tested on device and working! 👯 More proper review after. |

adds Silent Payments (BIP-352) as a fourth single-sig policy ("Single-sig SP"). P2TR only, marked experimental.
sp1/tsp1address (text, QR, SD). the scan key is exported from the xpub screen behind a privacy warning. no output descriptor, SP wallets describe themselvessp1address and the taproot address it lands onaux_randcomes from seed + PSBT hash + ticks, not the K210 RNG. BIP-374 binds the nonce to the statement so this is safesp_tweakfields (~70 bytes per input), SD output keeps thembech32_decoderaisingBech32DecodeErrorsigning warns the user to verify the
sp1address with the recipient, never the derived P2TR.blocked on embit #145
sign flow:
sequenceDiagram participant U as User participant H as home.sign_psbt participant S as PSBTSigner participant E as embit U->>H: Sign > PSBT (QR or SD) H->>S: PSBTSigner(wallet, data) S->>S: validate policy, fees, input amounts S->>S: SP eligibility (no multisig/miniscript, P2PKH/P2WPKH/P2SH-P2WPKH/P2TR only) S->>E: sp_output_scripts(root) E-->>S: taproot script per SP output, or reject if inputs are not all ours H->>S: outputs() S-->>H: sp1 address + taproot address page per SP output H->>U: warnings, then review U->>H: Sign to QR or SD H->>S: sign(trim) S->>E: sign_with(root, aux_rand) E-->>S: sigs + ECDH shares + DLEQ proofs S->>S: scripts must match what was reviewed S->>S: clear final_scriptwitness/final_scriptsig S-->>U: unfinalized PSBT for the coordinator