Skip to content

Commit 7330484

Browse files
committed
Incorporate feedback
1 parent 063d702 commit 7330484

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

bip-alfredhodler-privatepayments.mediawiki

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
Title: Private Payments
55
Author: Alfred Hodler <[email protected]>
66
Clark Moody <[email protected]>
7+
Ruben Somsen <[email protected]>
78
Status: Draft
89
Type: Informational
910
Created: 2022-07-10
@@ -60,6 +61,7 @@ When Alice wants to start paying Bob in private, she imports his payment code in
6061
* ''*'': EC multiplication
6162
* ''+'': EC addition
6263
* ''|'': string concatenation
64+
* ''[a..b]'': string slicing (inclusive of ''a'', exclusive of ''b'')
6365
6466
===Public Key Derivation Path===
6567

@@ -77,8 +79,8 @@ m / purpose' / coin_type' / account'
7779

7880
===Payment Code Structure and Encoding===
7981

80-
* bytes <code>[0..1]</code>: address type flags (2 bytes, inclusive)
81-
* bytes <code>[2..35]</code>: compressed public key P (33 bytes, inclusive)
82+
* bytes <code>[0..2]</code>: address type flags (2 bytes)
83+
* bytes <code>[2..36]</code>: compressed public key P (33 bytes)
8284
8385
Payment codes are encoded in bech32m and the human readable part is "pay" for mainnet and "payt" for testnet (all types), resulting in payment codes that look like "pay1cqqq8d29g0a7m8ghmycqk5yv24mfh3xg8ptzqcn8xz6d2tjl8ccdnfkpjl7p84".
8486

@@ -104,19 +106,19 @@ While payment codes use 2-byte bitflag arrays, notifications use ordinal values
104106

105107
===Notifications===
106108

107-
Notifications are performed by publishing transactions that contain a 72-byte <code>OP_RETURN</code> output. The value of the <code>OP_RETURN</code> is constructed using the following formula:
109+
Notifications are performed by publishing transactions that contain a 44-byte <code>OP_RETURN</code> output. The value of the <code>OP_RETURN</code> is constructed using the following formula:
108110

109111
''search_key | notification_code | N<sub>x</sub> | address_type''
110112

111113
* ''search_key'' equals "BIP999" and is a static ASCII-encoded string (6 bytes)
112-
* ''notification_code'' is ''H(n<sub>x</sub> * P)'' (32 bytes)
114+
* ''notification_code'' is ''H(n<sub>x</sub> * P)[0..4]'' (4 bytes)
113115
* ''N<sub>x</sub>'' is the unique public key a sender is using for a particular recipient (33 bytes)
114116
* ''address_type'' is the '''ordinal''' value of a single address type that a sender wants to send to (1 byte). This must be selected from the recepient's accepted address types.
115117
116118
When Alice wants to notify Bob that he will receive future payments from her, she performs the following procedure:
117119

118120
# Assigns an unused, unique index ''x'' to Bob (''0'' if Bob is the first party she is notifying).
119-
# Calculates a notification code: ''notification_code = H(n<sub>x</sub> * P)''
121+
# Calculates a 4-byte notification code: ''notification_code = H(n<sub>x</sub> * P)[0..4]''
120122
# Commits to one of Bob's accepted address types by choosing its ordinal value. Going forward Alice must not send to address types other than the one she committed to in the notification.
121123
# Constructs a notification payload by concatenating the above values according to the formula.
122124
# Selects any UTXO in her wallet, preferably not associated with her.
@@ -126,12 +128,20 @@ When Bob notices an <code>OP_RETURN</code> starting with the search key, he perf
126128

127129
# Breaks down the payload into its four constituent parts.
128130
# Discards the ''search_key'' (item #0).
129-
# Selects ''N<sub>x</sub>'' (item #2) and performs ''H(N<sub>x</sub> * p)'' (Bob does not know the value of ''x'').
130-
# If the above value matches the notification value (item #1), Bob found a notification addressed to himself and stores ''N<sub>x</sub>'' together with ''address_type''.
131+
# Selects ''N<sub>x</sub>'' (item #2) and performs ''H(N<sub>x</sub> * p)'' (Bob does not know the value of ''x''). Bob takes the first four bytes of the calculated value.
132+
# If the four bytes match the notification value (item #1), Bob found a notification addressed to himself and stores ''N<sub>x</sub>'' together with ''address_type''.
131133
# If this process fails for any reason, Bob assumes a spurious notification or one not addressed to himself and gives up.
132134
133135
Since changing ''x'' yields a completely different sender identity, Alice can always re-notify Bob from a different index when she does not want to be associated with her previous identity. Alice can also re-notify Bob when she wants to start sending to a different address type. Bob must be able to update his watchlist in that case and he can stop watching addresses associated with the old address type.
134136

137+
===Allowing Notification Collisions===
138+
139+
Since ''notification_code'' is a 4-byte truncation of the full value, Bob has a 1 in ~4.3 billion chance of detecting a spurious notification. This is considered acceptable because the cost of doing so is adding a few more addresses to Bob's watchlist. The benefit of this approach is that is saves 28 bytes per notification.
140+
141+
===Scanning Requirement===
142+
143+
There is a scanning requirement on the recipient side in that the recipient must have access to full blocks in order to be able to search them for OP_RETURN outputs containing notifications. For more information on how light clients can get around this limitation and still use the standard, see Appendix B.
144+
135145
===Transacting===
136146

137147
Alice initializes counter ''c'' which is unique to Bob and increments with each transaction. ''c'' is a 64-bit integer and must be inputted into a hasher as a big-endian encoded array of 8 bytes.
@@ -194,11 +204,11 @@ When Bob wants to spend from such addresses, he calculates his private keys in t
194204
===Alice notifying Bob===
195205
'''S:''' 0x0295ac9a667d7077def44b11104811e5d91d164dd60cb08275b313a33691320cb3
196206

197-
'''Notification code:''' 0xfbe8d683683023aaa066ba13cf79c9f8a7d3c69a4705025f3f4f4887a61eb975
207+
'''Notification code:''' 0xfbe8d683
198208

199209
'''Address type commitment:''' 1 (segwit)
200210

201-
'''Notification output script:''' OP_RETURN OP_PUSHBYTES_72 424950393939fbe8d683683023aaa066ba13cf79c9f8a7d3c69a4705025f3f4f4887a61eb975039d138aaf5bc2e27a9740541576eceb90a5f20b4799dbfda48e5c7ca24050575301
211+
'''Notification output script:''' OP_RETURN OP_PUSHBYTES_44 424950393939fbe8d683039d138aaf5bc2e27a9740541576eceb90a5f20b4799dbfda48e5c7ca24050575301
202212

203213

204214
===Alice sending to Bob===
@@ -218,6 +228,7 @@ When Bob wants to spend from such addresses, he calculates his private keys in t
218228

219229
'''p<sub>c</sub>:''' 0xf2f9c44c15a0b9f3590ab36e6324ab781b12e3f40abc745611d06a46894aab88
220230

231+
221232
==Appendix B: Potential OP_RETURN Services==
222233

223234
Compact Block Filters, as formulated in BIP-0158, do not cover <code>OP_RETURN</code> data payloads. In support of light wallets, an external service could publish transaction proofs for all transactions that include the tagged notification payload. Light wallets would download all such transactions, filter for matches against their payment code, then verify the transaction proofs against the block headers obtained over the P2P network.

0 commit comments

Comments
 (0)