File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 11import time
22
3+ import pytest
34import 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" )
You can’t perform that action at this time.
0 commit comments