@@ -153,10 +153,28 @@ The following functions will also be referenced:
153
153
- Calls ` MixHash(ciphertext) `
154
154
- returns ` plaintext `
155
155
156
- - ` ellswift_ecdh_xonly (k, rk)` : performs an Elliptic-Curve Diffie-Hellman operation
156
+ - ` ECDH (k, rk)` : performs an Elliptic-Curve Diffie-Hellman operation
157
157
using ` k ` , which is a valid ` secp256k1 ` private key, and ` rk ` , which is a EllSwift
158
158
encoded public key
159
159
- The output is 32 bytes
160
+ - It is a shortcut for performing operation ` v2_ecdh ` defined in BIP324<sup >[ 7] ( #reference-7 ) </sup >:
161
+ - let ` k, ellswift_k ` be key pair created by ` ellswift_create() ` function
162
+ - let ` rk ` be remote public key ** encoded as ellswift** .
163
+ - let ` initiator ` be bool flag that is ** true** if the party performing ECDH initiated the handshake
164
+ - then ` ECDH(k, rk) = v2_ecdh(k, ellswift_k, rk, initiator) `
165
+
166
+ - ` v2_ecdh(k, ellswift_k, rk, initiator) ` :
167
+ - let ` ecdh_point_x32 ` = ` ellswift_ecdh_xonly(rk, k) `
168
+ - if initiator == true:
169
+ - return ` tagged_hash(ellswift_k, rk, ecdh_point_x32) `
170
+ - else return ` tagged_hash(rk, ellswift_k, ecdh_point_x32) `
171
+ - ** Note that the ecdh result is not commutative with respect to roles! Therefore the initiator flag is needed**
172
+
173
+ - ` ellswift_ecdh_xonly ` - see BIP324<sup >[ 7] ( #reference-7 ) </sup >
174
+ - ` tagged_hash(a, b, c) ` :
175
+ - let tag = ` SHA256("bip324_ellswift_xonly_ecdh") `
176
+ - return ` SHA256(concatenate(tag, tag, a, b, c)) `
177
+
160
178
161
179
162
180
0 commit comments