Skip to content

Commit fb18d17

Browse files
clarkmoodyalfred-hodler
authored andcommitted
Italic symbol notation instead of <code>
1 parent 1341201 commit fb18d17

File tree

1 file changed

+44
-53
lines changed

1 file changed

+44
-53
lines changed

bip-alfredhodler-privatepayments.mediawiki

Lines changed: 44 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,21 @@ When Alice wants to start paying Bob in private, she imports his payment code in
4444
* Alice: sender
4545
* Bob: recipient
4646
* Payment code: static string that Bob generates and shares with others so that he can receive payments
47-
* P: public key contained in Bob's payment code
48-
* p: private key associated with Bob's public key P
49-
* N: extended public key used by Alice to derive child keys for each Bob she wants to transact with
50-
* n: private key associated with Alice's public key N
51-
* x: Alice's secret recipient index, unique for each Bob
52-
* N_x: child public key derived from N at index x (non-hardened)
53-
* n_x: private key associated with N_x
54-
* c: Alice's transaction count toward Bob
55-
* p_c: Bob's private key at index c
56-
* P_c: Bob's public key at index c
57-
* A_c: Bob's receive address at index c
58-
* *: EC multiplication
59-
* +: EC addition
60-
* |: string concatenation
47+
* ''P'': public key contained in Bob's payment code
48+
* ''p'': private key associated with Bob's public key ''P''
49+
* ''N'': extended public key used by Alice to derive child keys for each Bob she wants to transact with
50+
* ''n'': private key associated with Alice's public key ''N''
51+
* ''x'': Alice's secret recipient index, unique for each Bob
52+
* ''N<sub>x</sub>'': child public key derived from ''N'' at index ''x'' (non-hardened)
53+
* ''n<sub>x</sub>'': private key associated with ''N<sub>x</sub>''
54+
* ''c'': Alice's transaction count toward Bob
55+
* ''P<sub>c</sub>'': Bob's public key at index ''c''
56+
* ''p<sub>c</sub>'': Bob's private key at index ''c''
57+
* ''A<sub>c</sub>'': Bob's receive address at index ''c''
58+
* ''H'': SHA256 hash function
59+
* ''*'': EC multiplication
60+
* ''+'': EC addition
61+
* ''|'': string concatenation
6162
6263
===Public Key Derivation Path===
6364

@@ -69,9 +70,9 @@ m / purpose' / coin_type' / account'
6970

7071
<code>purpose</code> is set to 999.
7172

72-
<code>(p, P)</code> and <code>(n, N)</code> are keys associated with the above path, depending on which side is performing the calculation.
73+
''(p, P)'' and ''(n, N)'' are keys associated with the above path, depending on which side is performing the calculation.
7374

74-
N_x keys are the direct non-hardened children of N. For instance, the path of <code>N_0</code> from <code>N</code> is <code>m / 0</code>.
75+
''N<sub>x</sub>'' keys are the direct non-hardened children of ''N''. For instance, the path of ''N<sub>0</sub>'' from ''N'' is ''m / 0''.
7576

7677
===Payment Code Structure and Encoding===
7778

@@ -102,69 +103,59 @@ While payment codes use 2-byte bitflag arrays, notifications use ordinal values
102103

103104
===Notifications===
104105

105-
Notifications are performed by publishing transactions that contain a single 72-byte OP_RETURN output. The value of the OP_RETURN is constructed using the following formula:
106+
Notifications are performed by publishing transactions that contain a single 72-byte <code>OP_RETURN</code> output. The value of the <code>OP_RETURN</code> is constructed using the following formula:
106107

107-
<code>search_key | notification_code | N_x | address_type</code>
108+
''search_key | notification_code | N<sub>x</sub> | address_type''
108109

109-
* <code>search_key</code> equals <code>BIP999</code> and is a static ASCII-encoded string (6 bytes)
110-
* <code>notification_code</code> is <code>SHA256(n_x * P)</code> (32 bytes)
111-
* <code>N_x</code> is the unique public key a sender is using for a particular recipient (33 bytes)
112-
* <code>address_type</code> 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.
110+
* ''search_key'' equals "BIP999" and is a static ASCII-encoded string (6 bytes)
111+
* ''notification_code'' is ''H(n<sub>x</sub> * P)'' (32 bytes)
112+
* ''N<sub>x</sub>'' is the unique public key a sender is using for a particular recipient (33 bytes)
113+
* ''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.
113114
114115
When Alice wants to notify Bob that he will receive future payments from her, she performs the following procedure:
115116

116-
# Assigns an unused, unique index <code>x</code> to Bob (0 if Bob is the first party she is notifying).
117-
# Calculates a notification code: <code>notification_code = SHA256(n_x * P)</code>
117+
# Assigns an unused, unique index ''x'' to Bob (''0'' if Bob is the first party she is notifying).
118+
# Calculates a notification code: ''notification_code = H(n<sub>x</sub> * P)''
118119
# 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.
119120
# Constructs a notification payload by concatenating the above values according to the formula.
120121
# Selects any UTXO in her wallet, preferably not associated with her.
121-
# Sends a transaction with a single OP_RETURN output whose value is set to the constructed payload.
122+
# Sends a transaction with a single <code>OP_RETURN</code> output whose value is set to the constructed payload.
122123
123-
When Bob notices an OP_RETURN starting with the search key, he performs the following procedure:
124+
When Bob notices an <code>OP_RETURN</code> starting with the search key, he performs the following procedure:
124125

125126
# Breaks down the payload into its four constituent parts.
126-
# Discards the search key (item #0).
127-
# Selects <code>N_x</code> (item #2) and performs <code>SHA256(N_x * p)</code> (Bob does not know the value of <code>x</code>).
128-
# If the above value matches the notification value (item #1), Bob found a notification addressed to himself and stores <code>N_x</code> together with <code>address_type</code>.
127+
# Discards the ''search_key'' (item #0).
128+
# Selects ''N<sub>x</sub>'' (item #2) and performs ''H(N<sub>x</sub> * p)'' (Bob does not know the value of ''x'').
129+
# 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''.
129130
# If this process fails for any reason, Bob assumes a spurious notification or one not addressed to himself and gives up.
130131
131-
Since changing <code>x</code> 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.
132+
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.
132133

133134
===Transacting===
134135

135-
Alice initializes counter <code>c</code> which is unique to Bob and increments with each transaction. <code>c</code> is a 64-bit integer and must be inputted into a hasher as a big-endian encoded array of 8 bytes.
136+
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.
136137

137138
1. Alice calculates a secret point (constant between Alice and Bob):
138139

139-
<code>
140-
S = n_x * P
141-
</code>
140+
''S = n<sub>x</sub> * P''
142141

143142
2. Alice calculates a shared secret:
144143

145-
<code>
146-
s = SHA256(S, c)
147-
</code>
144+
''s = H(S | c)''
148145

149146
3. Alice calculates Bob's ephemeral public key and its associated address where the funds will be sent:
150147

151-
<code>
152-
P_c = P + s*G
153-
</code>
148+
''P<sub>c</sub> = P + s*G''
154149

155-
4. Alice constructs an address using the key <code>P_c</code>, using one of the address types she committed to in the notification transaction.
150+
4. Alice constructs an address using the key ''P<sub>c</sub>'', using one of the address types she committed to in the notification transaction.
156151

157-
Bob constructs his watchlist by mirroring this process on his end, except that his method of calculating S is:
152+
Bob constructs his watchlist by mirroring this process on his end, except that his method of calculating ''S'' is:
158153

159-
<code>
160-
S = N_x * p
161-
</code>
154+
''S = N<sub>x</sub> * p''
162155

163156
When Bob wants to spend from such addresses, he calculates his private keys in the following manner:
164157

165-
<code>
166-
p_c = p + s
167-
</code>
158+
''p<sub>c</sub> = p + s''
168159

169160
==Test Vectors==
170161

@@ -180,9 +171,9 @@ p_c = p + s
180171

181172
'''x:''' 0
182173

183-
'''n_x:''' 011447e7c6426aecd3fb3e76fba39ef3dc1e91dc578e8b535f714234c62675c5
174+
'''n<sub>x</sub>:''' 011447e7c6426aecd3fb3e76fba39ef3dc1e91dc578e8b535f714234c62675c5
184175

185-
'''N_x:''' 039d138aaf5bc2e27a9740541576eceb90a5f20b4799dbfda48e5c7ca240505753
176+
'''N<sub>x</sub>:''' 039d138aaf5bc2e27a9740541576eceb90a5f20b4799dbfda48e5c7ca240505753
186177

187178

188179
===Bob's Wallet===
@@ -216,15 +207,15 @@ p_c = p + s
216207

217208
'''s*G:''' 0x03e99301fb24083590fde78473d55a8435b0aed0dad65c516dfb268586fbe134be
218209

219-
'''P_c:''' 0x03145adc275eda50ea188250f85e729b77b22f9868d024aff00ea61d552373cbba
210+
'''P<sub>c</sub>:''' 0x03145adc275eda50ea188250f85e729b77b22f9868d024aff00ea61d552373cbba
220211

221-
'''A_c:''' bc1q7nmrkdgg3qq3l2ggh46zwv7750q6rjux0nx27a
212+
'''A<sub>c</sub>:''' bc1q7nmrkdgg3qq3l2ggh46zwv7750q6rjux0nx27a
222213

223214

224215
===Bob spending===
225216
'''c:''' 0
226217

227-
'''p_c:''' 0xf2f9c44c15a0b9f3590ab36e6324ab781b12e3f40abc745611d06a46894aab88
218+
'''p<sub>c</sub>:''' 0xf2f9c44c15a0b9f3590ab36e6324ab781b12e3f40abc745611d06a46894aab88
228219

229220
==Reference==
230221
* [[bip-0032.mediawiki|BIP32 - Hierarchical Deterministic Wallets]]

0 commit comments

Comments
 (0)