File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
test/functional/test_framework Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python3
2
+ # Copyright (c) 2022 The Bitcoin Core developers
3
+ # Distributed under the MIT software license, see the accompanying
4
+ # file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
+ """Class for v2 P2P protocol (see BIP 324)"""
6
+
7
+ from .crypto .ellswift import ellswift_ecdh_xonly
8
+ from .key import TaggedHash
9
+
10
+ class EncryptedP2PState :
11
+ @staticmethod
12
+ def v2_ecdh (priv , ellswift_theirs , ellswift_ours , initiating ):
13
+ """Compute BIP324 shared secret."""
14
+ ecdh_point_x32 = ellswift_ecdh_xonly (ellswift_theirs , priv )
15
+ if initiating :
16
+ # Initiating, place our public key encoding first.
17
+ return TaggedHash ("bip324_ellswift_xonly_ecdh" , ellswift_ours + ellswift_theirs + ecdh_point_x32 )
18
+ else :
19
+ # Responding, place their public key encoding first.
20
+ return TaggedHash ("bip324_ellswift_xonly_ecdh" , ellswift_theirs + ellswift_ours + ecdh_point_x32 )
You can’t perform that action at this time.
0 commit comments