Skip to content

Commit a4c3a8d

Browse files
committed
refactor: code cleanup
1 parent 193c258 commit a4c3a8d

File tree

12 files changed

+18
-28
lines changed

12 files changed

+18
-28
lines changed

core/crypto.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@
1919
OTP_MAX_RANDOM_PAD,
2020
OTP_SIZE_LENGTH,
2121
OTP_MAX_BUCKET,
22-
ML_KEM_1024_SK_LEN,
23-
ML_KEM_1024_PK_LEN,
2422
ML_DSA_87_NAME,
25-
ML_DSA_87_SK_LEN,
26-
ML_DSA_87_PK_LEN,
27-
ML_DSA_87_SIGN_LEN,
2823
ALGOS_BUFFER_LIMITS
2924
)
3025

core/requests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from urllib import request, error
1+
from urllib import request
22
from core.trad_crypto import (
33
sha3_512
44
)

logic/background_worker.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from core.requests import http_request
2-
from logic.smp import smp_unanswered_questions, smp_data_handler
2+
from logic.smp import smp_data_handler
33
from logic.pfs import pfs_data_handler
44
from logic.message import messages_data_handler
55
from logic.user import validate_identifier
@@ -10,17 +10,15 @@
1010
SMP_TYPES,
1111
PFS_TYPES,
1212
MSG_TYPES,
13-
XCHACHA20POLY1305_NONCE_LEN,
14-
ML_KEM_1024_CT_LEN
13+
XCHACHA20POLY1305_NONCE_LEN
1514
)
1615
from core.crypto import (
17-
random_number_range,
18-
decap_shared_secret
16+
random_number_range
1917
)
2018
from core.trad_crypto import (
2119
decrypt_xchacha20poly1305
2220
)
23-
from base64 import b64decode, urlsafe_b64encode
21+
from base64 import urlsafe_b64encode
2422
import copy
2523
import logging
2624

logic/message.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
XCHACHA20POLY1305_NONCE_LEN
4141

4242
)
43-
from base64 import b64decode, b64encode
4443
import secrets
4544
import logging
4645

@@ -224,7 +223,7 @@ def send_message_processor(user_data, user_data_lock, contact_id: str, message:
224223
headers = session_headers,
225224
auth_token = auth_token
226225
)
227-
except:
226+
except Exception:
228227
ui_queue.put({"type": "showerror", "title": "Error", "message": "Failed to send our message to the server"})
229228
return False
230229

logic/pfs.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
from core.crypto import (
1616
generate_kem_keys,
1717
verify_signature,
18-
create_signature,
19-
random_number_range
18+
create_signature
2019
)
2120
from core.constants import (
2221
PFS_TYPES,
@@ -32,8 +31,7 @@
3231
)
3332
from core.trad_crypto import (
3433
sha3_512,
35-
encrypt_xchacha20poly1305,
36-
decrypt_xchacha20poly1305
34+
encrypt_xchacha20poly1305
3735
)
3836
from base64 import b64encode, b64decode
3937
import secrets

logic/smp.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
SMP_TYPES,
3434
SMP_NONCE_LENGTH,
3535
SMP_PROOF_LENGTH,
36-
SMP_QUESTION_MAX_LEN,
3736
SMP_ANSWER_OUTPUT_LEN,
3837
ARGON2_SALT_LEN,
3938
ML_KEM_1024_NAME,
@@ -398,9 +397,6 @@ def smp_step_4_answer_provided(user_data, user_data_lock, contact_id, answer, ui
398397

399398
def smp_step_5(user_data, user_data_lock, contact_id, smp_plaintext, ui_queue) -> None:
400399
with user_data_lock:
401-
server_url = user_data["server_url"]
402-
auth_token = user_data["token"]
403-
404400
answer = user_data["contacts"][contact_id]["lt_sign_key_smp"]["answer"]
405401

406402
our_signing_public_key = user_data["contacts"][contact_id]["lt_sign_keys"]["our_keys"]["public_key"]

tests/test_crypto.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
CLASSIC_MCELIECE_8_F_CT_LEN
3737

3838
)
39-
from core.trad_crypto import sha3_512
4039

4140

4241
def test_random_number_range():

tests/test_requests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import pytest
1212
import socket
1313
import json
14-
import types
1514
import socks
1615
from urllib import request as urllib_request
1716
from core import requests as core_requests

tests/test_trad_crypto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@ def test_aes_encrypt_decrypt():
4646
tampered_ciphertext[-1] ^= 0xFF # Flip last byte to corrupt data
4747

4848
with pytest.raises(Exception):
49-
decrypt_aes_gcm(key, nonce, bytes(tampered_ciphertext))
49+
decrypt_xchacha20poly1305(key, nonce, bytes(tampered_ciphertext))
5050

ui/add_contact_prompt.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from tkinter import messagebox
2-
from ui.utils import *
2+
from ui.utils import (
3+
enhanced_entry
4+
)
35
from logic.user import validate_identifier
46
from logic.contacts import save_contact
57
from logic.storage import save_account_data

0 commit comments

Comments
 (0)