Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

Commit 10b712c

Browse files
committed
refactor: async messaging support and improved perfect forward secrecy
1 parent 4050171 commit 10b712c

File tree

2 files changed

+1
-38
lines changed

2 files changed

+1
-38
lines changed

core/trad_crypto.py

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
1212
from cryptography.hazmat.primitives.kdf.argon2 import Argon2id
13-
from cryptography.hazmat.primitives import hashes
14-
from cryptography.hazmat.primitives.asymmetric.x448 import X448PrivateKey
15-
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
1613
from core.constants import (
1714
OTP_PAD_SIZE,
1815
AES_GCM_NONCE_LEN,
@@ -27,40 +24,6 @@
2724

2825

2926

30-
def generate_curve448_private_key():
31-
"""
32-
Generates a Curve448 private key.
33-
34-
Returns:
35-
A Curve448 private key of type X448PrivateKey.
36-
"""
37-
return X448PrivateKey.generate()
38-
39-
40-
def curve448_exchange(private_key, public_key, length: int = 56, salt: bytes = None) -> bytes:
41-
"""
42-
Computes a shared secret.
43-
44-
Args:
45-
private_key: The Private key of sender.
46-
public_key: The Public key of receiver.
47-
salt: Optional salt
48-
49-
Returns:
50-
A 56-byte shared secret.
51-
"""
52-
53-
shared_secret = private_key.exchange(peer_public_key)
54-
return HKDF(
55-
algorithm = hashes.SHA3_512(),
56-
length = length,
57-
salt = salt,
58-
info = b"Coldwire Curve448 Shared Secret Key For OTP Pad",
59-
).derive(shared_secret)
60-
61-
62-
63-
6427
def sha3_512(data: bytes) -> bytes:
6528
"""
6629
Compute a SHA3-512 hash of the given data.

logic/pfs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def send_new_ephemeral_keys(user_data, user_data_lock, contact_id, ui_queue) ->
8989
}
9090

9191
user_data["contacts"][contact_id]["ephemeral_keys"]["our_keys"][CLASSIC_MCELIECE_8_F_NAME]["rotation_counter"] = 0
92-
user_data["contacts"][contact_id]["ephemeral_keys"]["our_keys"][CLASSIC_MCELIECE_8_F_NAME]["rotate_at"] = CLASSIC_MCELIECE_8_F_ROTATE_AT
92+
user_data["contacts"][contact_id]["ephemeral_keys"]["our_keys"][CLASSIC_MCELIECE_8_F_NAME]["rotate_at"] = CLASSIC_MCELIECE_8_F_ROTATE_AT
9393

9494

9595

0 commit comments

Comments
 (0)