You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 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)
82
84
83
85
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".
84
86
@@ -104,19 +106,19 @@ While payment codes use 2-byte bitflag arrays, notifications use ordinal values
104
106
105
107
===Notifications===
106
108
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:
* ''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)
113
115
* ''N<sub>x</sub>'' is the unique public key a sender is using for a particular recipient (33 bytes)
114
116
* ''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.
115
117
116
118
When Alice wants to notify Bob that he will receive future payments from her, she performs the following procedure:
117
119
118
120
# 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)''
# 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.
121
123
# Constructs a notification payload by concatenating the above values according to the formula.
122
124
# 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
126
128
127
129
# Breaks down the payload into its four constituent parts.
128
130
# 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''.
131
133
# If this process fails for any reason, Bob assumes a spurious notification or one not addressed to himself and gives up.
132
134
133
135
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.
134
136
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
+
135
145
===Transacting===
136
146
137
147
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
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