Skip to content

Commit 1cbcd14

Browse files
committed
add tests
1 parent 048325e commit 1cbcd14

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/test_all_functions.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import time
22

3+
import pytest
34
import bittensor_drand as btcr
45

56

@@ -154,3 +155,27 @@ def test_get_encrypted_commit():
154155
)
155156
assert isinstance(encrypted, bytes)
156157
assert isinstance(round_, int)
158+
159+
160+
def test_encrypt_mlkem768():
161+
"""Test ML-KEM-768 encryption."""
162+
try:
163+
from ml_kem import Keypair, MlKem768Params
164+
165+
# Generate test keypair
166+
keypair = Keypair.generate(MlKem768Params)
167+
pk_bytes = bytes(keypair.public_key())
168+
plaintext = b"test message"
169+
170+
ciphertext = btcr.encrypt_mlkem768(pk_bytes, plaintext)
171+
assert isinstance(ciphertext, bytes)
172+
assert len(ciphertext) > 0
173+
# Verify blob format: [u16 kem_len][kem_ct][nonce24][aead_ct]
174+
assert len(ciphertext) >= 2 + 24 # At least kem_len (2) + nonce (24)
175+
176+
# Test KDF ID
177+
kdf_id = btcr.mlkem_kdf_id()
178+
assert isinstance(kdf_id, bytes)
179+
assert kdf_id == b"v1"
180+
except ImportError:
181+
pytest.skip("ml-kem Python package not available for testing")

0 commit comments

Comments
 (0)