fix: point multiplication
This commit is contained in:
parent
9c00adbf2d
commit
966e8bd6c1
1 changed files with 4 additions and 1 deletions
|
|
@ -10,8 +10,11 @@ from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
||||||
def get_shared_secret(privkey: str, pubkey: str):
|
def get_shared_secret(privkey: str, pubkey: str):
|
||||||
pk = coincurve.PublicKey(bytes.fromhex("02" + pubkey))
|
pk = coincurve.PublicKey(bytes.fromhex("02" + pubkey))
|
||||||
sk = coincurve.PrivateKey(bytes.fromhex(privkey))
|
sk = coincurve.PrivateKey(bytes.fromhex(privkey))
|
||||||
return sk.ecdh(pk.format())
|
shared_point = pk.multiply(sk.secret)
|
||||||
|
|
||||||
|
shared_point_bytes = shared_point.format(compressed=False)
|
||||||
|
x_coord = shared_point_bytes[1:33]
|
||||||
|
return x_coord
|
||||||
|
|
||||||
def decrypt_message(encoded_message: str, encryption_key) -> str:
|
def decrypt_message(encoded_message: str, encryption_key) -> str:
|
||||||
encoded_data = encoded_message.split("?iv=")
|
encoded_data = encoded_message.split("?iv=")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue