Skip to content

Commit a067793

Browse files
authored
Merge pull request #1687 from andrewtoth/silent-payments-psbt
BIP375: Sending Silent Payments in PSBTs
2 parents 1f41c17 + eb10cdb commit a067793

File tree

3 files changed

+337
-3
lines changed

3 files changed

+337
-3
lines changed

README.mediawiki

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,6 +1198,13 @@ Those proposing changes should consider that ultimately consent may rest with th
11981198
| Standard
11991199
| Draft
12001200
|-
1201+
| [[bip-0375.mediawiki|375]]
1202+
| Applications
1203+
| Sending Silent Payments with PSBTs
1204+
| Andrew Toth, Ava Chow, josibake
1205+
| Standard
1206+
| Draft
1207+
|-
12011208
| [[bip-0379.md|379]]
12021209
| Applications
12031210
| Miniscript

bip-0174.mediawiki

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,28 @@ The currently defined global types are as follows:
171171
| 2
172172
| [[bip-0370.mediawiki|370]]
173173
|-
174+
| Silent Payment Global ECDH Share
175+
| <tt>PSBT_GLOBAL_SP_ECDH_SHARE = 0x07</tt>
176+
| <tt><33 byte scan key></tt>
177+
| The scan key that this ECDH share is for.
178+
| <tt><33 byte share></tt>
179+
| An ECDH share for a scan key. The ECDH shared is computed with ''a * B_scan'', where ''a'' is the sum of all private keys of all eligible inputs, and ''B_scan'' is the scan key of a recipient.
180+
|
181+
| 0
182+
| 2
183+
| [[bip-0375.mediawiki|375]]
184+
|-
185+
| Silent Payment Global DLEQ Proof
186+
| <tt>PSBT_GLOBAL_SP_DLEQ = 0x08</tt>
187+
| <tt><33 byte scan key></tt>
188+
| The scan key that this proof covers.
189+
| <tt><64-byte proof></tt>
190+
| A BIP374 DLEQ proof computed for the matching ECDH share.
191+
|
192+
| 0
193+
| 2
194+
| [[bip-0375.mediawiki|375]]
195+
|-
174196
| PSBT Version Number
175197
| <tt>PSBT_GLOBAL_VERSION = 0xFB</tt>
176198
| None
@@ -529,6 +551,28 @@ derived from an aggregate key.
529551
| 0, 2
530552
| [[bip-0373.mediawiki|373]]
531553
|-
554+
| Silent Payment Input ECDH Share
555+
| <tt>PSBT_IN_SP_ECDH_SHARE = 0x1d</tt>
556+
| <tt><33 byte scan key></tt>
557+
| The scan key that this ECDH share is for.
558+
| <tt><33 byte share></tt>
559+
| An ECDH share for a scan key. The ECDH shared is computed with ''a * B_scan'', where ''a'' is the private key of the corresponding prevout public key, and ''B_scan'' is the scan key of a recipient.
560+
|
561+
| 0
562+
| 2
563+
| [[bip-0375.mediawiki|375]]
564+
|-
565+
| Silent Payment Input DLEQ Proof
566+
| <tt>PSBT_IN_SP_DLEQ = 0x1e</tt>
567+
| <tt><33 byte scan key></tt>
568+
| The scan key that this proof covers.
569+
| <tt><64-byte proof></tt>
570+
| A BIP374 DLEQ proof computed for the matching ECDH share.
571+
|
572+
| 0
573+
| 2
574+
| [[bip-0375.mediawiki|375]]
575+
|-
532576
| Proprietary Use Type
533577
| <tt>PSBT_IN_PROPRIETARY = 0xFC</tt>
534578
| <tt><compact size uint identifier length> <bytes identifier> <compact size uint subtype> <bytes subkeydata></tt>
@@ -606,11 +650,11 @@ determine which outputs are change outputs and verify that the change is returni
606650
| None
607651
| No key data
608652
| <tt><bytes script></tt>
609-
| The script for this output, also known as the scriptPubKey. Must be omitted in PSBTv0. Must be provided in PSBTv2.
610-
| 2
653+
| The script for this output, also known as the scriptPubKey. Must be omitted in PSBTv0. Must be provided in PSBTv2 if not sending to a BIP352 silent payment address, otherwise may be omitted.
654+
|
611655
| 0
612656
| 2
613-
| [[bip-0370.mediawiki|370]]
657+
| [[bip-0370.mediawiki|370]], [[bip-0375.mediawiki|375]]
614658
|-
615659
| Taproot Internal Key
616660
| <tt>PSBT_OUT_TAP_INTERNAL_KEY = 0x05</tt>
@@ -659,6 +703,28 @@ required for aggregation. If sorting was done, then the keys must be in the sort
659703
| 0, 2
660704
| [[bip-0373.mediawiki|373]]
661705
|-
706+
| Silent Payment Data
707+
| <tt>PSBT_OUT_SP_V0_INFO = 0x09</tt>
708+
| None
709+
| No key data
710+
| <tt><33 byte scan key> <33 byte spend key></tt>
711+
| The scan and spend public keys from the silent payments address.
712+
|
713+
| 0
714+
| 2
715+
| [[bip-0375.mediawiki|375]]
716+
|-
717+
| Silent Payment Label
718+
| <tt>PSBT_OUT_SP_V0_LABEL = 0x10</tt>
719+
| None
720+
| No key data
721+
| <tt><32-bit little endian uint label></tt>
722+
| The label to use to compute the spend key of the silent payments address to verify change.
723+
|
724+
| 0
725+
| 2
726+
| [[bip-0375.mediawiki|375]]
727+
|-
662728
| BIP 353 DNSSEC proof
663729
| <tt>PSBT_OUT_DNSSEC_PROOF = 0x35</tt>
664730
| None

bip-0375.mediawiki

Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
<pre>
2+
BIP: 375
3+
Layer: Applications
4+
Title: Sending Silent Payments with PSBTs
5+
Author: Andrew Toth <andrewstoth@gmail.com>
6+
Ava Chow <me@achow101.com>
7+
josibake <josibake@protonmail.com>
8+
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0375
9+
Status: Draft
10+
Type: Standards Track
11+
Created: 2025-01-08
12+
License: BSD-2-Clause
13+
Post-History: https://groups.google.com/g/bitcoindev/c/5G5wzqUXyk4
14+
Requires: 352, 370, 374
15+
</pre>
16+
17+
==Introduction==
18+
19+
===Abstract===
20+
21+
This document proposes additional fields and updated role responsibilities for BIP370 PSBTv2
22+
which adds support for sending to silent payments as described in BIP352.
23+
24+
===Copyright===
25+
26+
This BIP is licensed under the 2-clause BSD license.
27+
28+
===Motivation===
29+
30+
Partially Signed Bitcoin Transaction Version 2 as described in BIP370 is not compatible with sending to silent payments as described in BIP352.
31+
In particular, the output script of a silent payment cannot be computed until after all transaction inputs have been added.
32+
Additionally, the silent payment outputs computed by a signer must be verifiable by other entities, otherwise funds could be sent to an incorrect output script.
33+
Therefore, new fields and role responsibilities must be added to carry, compute, and verify the silent payment data.
34+
35+
==Specification==
36+
37+
This document specifies new fields and new field inclusion/exclusion requirements.
38+
39+
The new global types are defined as follows:
40+
41+
{|
42+
! Name
43+
! <tt><keytype></tt>
44+
! <tt><keydata></tt>
45+
! <tt><keydata></tt> Description
46+
! <tt><valuedata></tt>
47+
! <tt><valuedata></tt> Description
48+
! Versions Requiring Inclusion
49+
! Versions Requiring Exclusion
50+
! Versions Allowing Inclusion
51+
|-
52+
| Silent Payment Global ECDH Share
53+
| <tt>PSBT_GLOBAL_SP_ECDH_SHARE = 0x07</tt>
54+
| <tt><33 byte scan key></tt>
55+
| The scan key that this ECDH share is for.
56+
| <tt><33 byte share></tt>
57+
| An ECDH share for a scan key. The ECDH shared is computed with ''a * B_scan'', where ''a'' is the sum of all private keys of all eligible inputs, and ''B_scan'' is the scan key of a recipient.
58+
|
59+
| 0
60+
| 2
61+
|-
62+
| Silent Payment Global DLEQ Proof
63+
| <tt>PSBT_GLOBAL_SP_DLEQ = 0x08</tt>
64+
| <tt><33 byte scan key></tt>
65+
| The scan key that this proof covers.
66+
| <tt><64-byte proof></tt>
67+
| A BIP374 DLEQ proof computed for the matching ECDH share.
68+
|
69+
| 0
70+
| 2
71+
|}
72+
73+
The new per-input types are defined as follows:
74+
75+
{|
76+
! Name
77+
! <tt><keytype></tt>
78+
! <tt><keydata></tt>
79+
! <tt><keydata></tt> Description
80+
! <tt><valuedata></tt>
81+
! <tt><valuedata></tt> Description
82+
! Versions Requiring Inclusion
83+
! Versions Requiring Exclusion
84+
! Versions Allowing Inclusion
85+
|-
86+
| Silent Payment Input ECDH Share
87+
| <tt>PSBT_IN_SP_ECDH_SHARE = 0x1d</tt>
88+
| <tt><33 byte scan key></tt>
89+
| The scan key that this ECDH share is for.
90+
| <tt><33 byte share></tt>
91+
| An ECDH share for a scan key. The ECDH shared is computed with ''a * B_scan'', where ''a'' is the private key of the corresponding prevout public key, and ''B_scan'' is the scan key of a recipient.
92+
|
93+
| 0
94+
| 2
95+
|-
96+
| Silent Payment Input DLEQ Proof
97+
| <tt>PSBT_IN_SP_DLEQ = 0x1e</tt>
98+
| <tt><33 byte scan key></tt>
99+
| The scan key that this proof covers.
100+
| <tt><64-byte proof></tt>
101+
| A BIP374 DLEQ proof computed for the matching ECDH share.
102+
|
103+
| 0
104+
| 2
105+
|}
106+
107+
The new per-output types are defined as follows:
108+
109+
{|
110+
! Name
111+
! <tt><keytype></tt>
112+
! <tt><keydata></tt>
113+
! <tt><keydata></tt> Description
114+
! <tt><valuedata></tt>
115+
! <tt><valuedata></tt> Description
116+
! Versions Requiring Inclusion
117+
! Versions Requiring Exclusion
118+
! Versions Allowing Inclusion
119+
|-
120+
| Silent Payment Data
121+
| <tt>PSBT_OUT_SP_V0_INFO = 0x09</tt>
122+
| None
123+
| No key data
124+
| <tt><33 byte scan key> <33 byte spend key></tt>
125+
| The scan and spend public keys from the silent payments address.
126+
|
127+
| 0
128+
| 2
129+
|-
130+
| Silent Payment Label
131+
| <tt>PSBT_OUT_SP_V0_LABEL = 0x10</tt>
132+
| None
133+
| No key data
134+
| <tt><32-bit little endian uint label></tt>
135+
| The label to use to compute the spend key of the silent payments address to verify change.
136+
|
137+
| 0
138+
| 2
139+
|}
140+
141+
<tt>PSBT_OUT_SCRIPT</tt> is modified to be optional for outputs in silent payments capable PSBTs. If this field is not included in the output, then the field PSBT_OUT_SP_V0_INFO must be included.
142+
If a PSBT_OUT_SCRIPT is not present for an output, then that output is being sent to a silent payment address represented by PSBT_OUT_SP_V0_INFO but the script has not yet been computed.
143+
If both PSBT_OUT_SCRIPT and PSBT_OUT_SP_V0_INFO are present for an output, then the PSBT_OUT_SCRIPT is the computed output script corresponding to the silent payment address in PSBT_OUT_SP_V0_INFO.
144+
If only PSBT_OUT_SCRIPT is present for an output, then the output is not being sent to a silent payment address.
145+
146+
===Unique Identification===
147+
148+
Silent payment capable PSBTs can be uniquely identified the same way as PSBTv2s, except when including silent payment outputs. If an output contains the the PSBT_OUT_SP_V0_INFO field, it must use that field instead of PSBT_OUT_SCRIPT as the output script when creating the unsigned transaction used for unique identification.<ref name="why_use_sp_info_field"> ''' Why use PSBT_OUT_SP_V0_INFO when serializing for a unique identifier?''' Since the same silent payment capable PSBT is valid whether or not a PSBT_OUT_SCRIPT is included in an output that has PSBT_OUT_SP_V0_INFO set, using the PSBT_OUT_SCRIPT if present for the unique identifier will cause malleability. The identifier will be different depending on whether PSBT_OUT_SCRIPT is present, so always using PSBT_OUT_SP_V0_INFO if it exists makes sure the PSBT is always identified uniquely.</ref>
149+
The PSBT_OUT_SP_V0_INFO should be serialized as a zero byte for the version, followed by the 33 bytes of the scan key and then 33 bytes for the spend key.
150+
151+
152+
==Roles==
153+
154+
This document modifies some existing roles.
155+
156+
===Constructor===
157+
158+
All rules must be followed from PSBTv2 for this role, with the following exception:
159+
When an output is added, it must have either PSBT_OUT_SCRIPT or PSBT_OUT_SP_V0_INFO, or both, set.
160+
161+
Additionally to PSBTv2, the Constructor must also follow additional rules:
162+
163+
Inputs spending an output with script using Segwit version > 1 may only be added if there are no outputs with PSBT_OUT_SP_V0_INFO set.
164+
Outputs with PSBT_OUT_SP_V0_INFO set may only be added if there are no inputs spending an output script using Segwit version > 1.
165+
166+
===Updater===
167+
168+
The updater should add a PSBT_IN_BIP32_DERIVATION for any p2wpkh, p2sh-p2wpkh, or p2pkh input so the public key is available for creating the ecdh_shared_secret when the private key is not known. If the updater does not want to reveal the fingerprint or derivation path, it can set the value of the field to zero.
169+
170+
====Change Detection====
171+
172+
Updaters may add two PSBT_OUT_BIP32_DERIVATION key-value-pairs with the corresponding derivation path of both the scan and spend keys. A label can be specified in PSBT_OUT_SP_V0_LABEL. The Signer can then use these fields to verify that the silent payment code is change.
173+
174+
===Signer===
175+
176+
All rules must be followed from PSBTv2 for this role. If there are any outputs with PSBT_OUT_SP_V0_INFO set, then the following additional rules must also be adhered to:
177+
178+
If any input is spending an output with script using Segwit version > 1, the Signer must fail.
179+
180+
For each output with PSBT_OUT_SP_V0_INFO set, the Signer should:
181+
* Compute and set an ECDH share and DLEQ proof for each input it has the private key for, or set a global ECDH share and DLEQ proof if it has private keys for all eligible inputs.
182+
* Verify the DLEQ proofs for all inputs it does not have the private keys for, or the global DLEQ proof if it is set.
183+
* If all eligible inputs have an ECDH share or the global ECDH share is set, compute and set the PSBT_OUT_SCRIPT.
184+
185+
If the Signer sets any missing PSBT_OUT_SCRIPTs, it must set the Inputs Modifiable and Outputs Modifiable flags to False.
186+
187+
If any output does not have PSBT_OUT_SCRIPT set, the Signer must not yet add a signature.
188+
189+
The Signer should additionally compute the silent payment addresses, optionally showing this data to the user instead of the computed segwit v1 addresses.
190+
191+
If a sighash type is provided and there are silent payment outputs present, the signer must fail if the sighash type is not SIGHASH_ALL.
192+
If a sighash type is not provided and there are silent payment outputs present, the signer must sign using SIGHASH_ALL.<ref name="why_use_sighash_all"> ''' Why use only SIGHASH_ALL?''' BIP352 allows signing with SIGHASH_NONE and SIGHASH_SINGLE. However, silent payment capable PSBTs compute the output scripts deterministically based on the number and position of silent payment codes with the same scan key. SIGHASH_NONE and SIGHASH_SINGLE allow changing the amount or position of silent payment codes with the same scan and spend keys, which would invalidate computed output scripts.</ref>
193+
194+
====Computing the ECDH Shares and DLEQ Proofs====
195+
196+
For each output with PSBT_OUT_SP_V0_INFO set, the Signer may generate a proof for other entities to generate the output scripts and verify that the output scripts were generated correctly.
197+
198+
If the Signer has the private keys for all eligible inputs, the Signer should generate a global ECDH share for each scan key ''B<sub>scan</sub>'' as follows:
199+
200+
Using the notation from [https://github.com/bitcoin/bips/blob/master/bip-0352.mediawiki#specification BIP352]
201+
202+
* Let ''a<sub>n</sub>'' be the sum of the private keys ''a'' of all eligible inputs
203+
* Let ''C = a<sub>n</sub>·B<sub>scan</sub>''
204+
205+
Set the key as ''B<sub>scan</sub>'' and the value as ''C'' for the PSBT_GLOBAL_SP_ECDH_SHARE field.
206+
207+
Compute the DLEQ proof for ''C'' using [https://github.com/bitcoin/bips/blob/master/bip-0374.mediawiki#user-content-DLEQ_Proof_Generation BIP374 GenerateProof] and passing ''a<sub>n</sub>'' as ''a'' and ''B<sub>scan</sub>'' as ''B''.
208+
Set the key as ''B<sub>scan</sub>'' and the value as the proof for the PSBT_GLOBAL_SP_DLEQ field.
209+
210+
If the Signer has the private keys for some eligible inputs or does not want to create a global ECDH share, the Signer should generate a per-input ECDH share for each scan key ''B<sub>scan</sub>'' as follows:
211+
212+
Using the notation from [https://github.com/bitcoin/bips/blob/master/bip-0352.mediawiki#specification BIP352], for each eligible input:
213+
214+
* Let ''a'' be the private key of the input
215+
* Let ''C = a·B<sub>scan</sub>''
216+
217+
Set the key as ''B<sub>scan</sub>'' and the value as ''C'' for the PSBT_IN_SP_ECDH_SHARE field of the input.
218+
219+
Compute the DLEQ proof for ''C'' using [https://github.com/bitcoin/bips/blob/master/bip-0374.mediawiki#user-content-DLEQ_Proof_Generation BIP374 GenerateProof] and passing ''B<sub>scan</sub>'' as ''B''.
220+
Set the key as ''B<sub>scan</sub>'' and the value as the proof for the PSBT_IN_SP_DLEQ field of the input.
221+
222+
====Verifying the DLEQ Proof====
223+
224+
For each output with PSBT_OUT_SP_V0_INFO set, the Signer should verify the ECDH shares for all eligible inputs it does not have the private key for using the proofs provided by other Signers.
225+
226+
If PSBT_GLOBAL_SP_ECDH_SHARE and PSBT_GLOBAL_SP_DLEQ are set, verify as follows:
227+
228+
* Let ''A<sub>n</sub>'' be the sum of the public keys ''A'' of all eligible inputs
229+
230+
Using [https://github.com/bitcoin/bips/blob/master/bip-0374.mediawiki#dleq-proof-verification BIP374 VerifyProof] and passing ''A'' as ''A<sub>n</sub>'', ''B'' as ''B<sub>scan</sub>'', ''C'' as the value of PSBT_GLOBAL_SP_ECDH_SHARE, and ''proof'' as the value of PSBT_GLOBAL_SP_DLEQ.
231+
232+
If PSBT_IN_SP_ECDH_SHARE and PSBT_IN_SP_DLEQ are set for a particular input, verify as follows:
233+
234+
Using [https://github.com/bitcoin/bips/blob/master/bip-0374.mediawiki#dleq-proof-verification BIP374 VerifyProof] and passing ''A'' as the public key of the input, ''B'' as ''B<sub>scan</sub>'', ''C'' as the value of PSBT_IN_SP_ECDH_SHARE, and ''proof'' as the value of PSBT_IN_SP_DLEQ.
235+
236+
237+
====Computing the Output Scripts====
238+
239+
Compute the PSBT_OUT_SCRIPT using the procedure in [https://github.com/bitcoin/bips/blob/master/bip-0352.mediawiki#user-content-Creating_outputs BIP352] but substituting ''a·B<sub>scan</sub>'' with the PSBT_GLOBAL_SP_ECDH_SHARE for that scan key if available, or the sum of all PSBT_IN_SP_ECDH_SHAREs for that scan key.
240+
If there are multiple silent payment codes with the same scan key, sort the codes lexicographically in ascending order to determine the ordering of the ''k'' value.
241+
If there are multiple silent payment codes with both the same scan and spend keys, sort the subgroup by output index in ascending order.
242+
243+
===Transaction Extractor===
244+
245+
For silent payment capable PSBTs, the transaction extractor should compute all output scripts for silent payment codes and verify they are correct using the ECDH shares and DLEQ proofs, otherwise fail.
246+
247+
==Backwards Compatibility==
248+
249+
Silent payment capable PSBTs are backwards compatible with PSBTv2 once all outputs have PSBT_OUT_SCRIPT set. Otherwise they are not backwards compatible.
250+
251+
==Test Vectors==
252+
253+
Todo
254+
255+
==Rationale==
256+
257+
<references/>
258+
259+
==Reference implementation==
260+
261+
Todo

0 commit comments

Comments
 (0)