Skip to content

Commit 4292f65

Browse files
committed
✅add some tests, 🔖 bump version
1 parent 8352132 commit 4292f65

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "SLH-DSA"
3-
version = "0.1.2"
3+
version = "0.1.3"
44
description = "The pure python impl of the slh-das algorithm(based on fips205)."
55
authors = [
66
{name = "Colinxu2020", email = "colinxu2020@gmail.com"},

slhdsa/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from slhdsa.slhdsa import PublicKey, SecretKey, KeyPair
22
from slhdsa.parameters import * # noqa: F403
3-
from slhdsa.exception import SLHDSAException, SLHDSASignException, SLHDSAVerifyException
3+
from slhdsa.exception import SLHDSAException, SLHDSASignException, SLHDSAVerifyException, SLHDSAKeyException
44

55

6-
__all__ = ["PublicKey", "SecretKey", "KeyPair", "SLHDSAException", "SLHDSASignException", "SLHDSAVerifyException"]
6+
__all__ = ["PublicKey", "SecretKey", "KeyPair", "SLHDSAException", "SLHDSASignException", "SLHDSAVerifyException", "SLHDSAKeyException"]
77
for algo in ["shake", "sha2"]:
88
for size in ["128", "192", "256"]:
99
for suffix in ["s", "f"]:

tests/test_a.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
from random import randbytes, randint
22

3+
from pytest import raises
4+
35
from slhdsa import KeyPair, sha2_128s, sha2_128f, sha2_192s, sha2_192f, sha2_256s, sha2_256f
46
from slhdsa import shake_128s, shake_128f, shake_192s, shake_192f, shake_256s, shake_256f
7+
from slhdsa import SLHDSAKeyException, PublicKey, SecretKey
58

69

710
def _for_all(judger):
@@ -93,4 +96,22 @@ def judge(para):
9396
assert not kp.verify(msg, sig2)
9497
sig3 = randbytes(10) + sig[10:]
9598
assert not kp.verify(msg, sig3)
96-
_for_all(judge)
99+
_for_all(judge)
100+
101+
def test6():
102+
def judge(para):
103+
pk = KeyPair.gen(para).pub.digest()[:-1]
104+
with raises(SLHDSAKeyException):
105+
PublicKey.from_digest(pk, para)
106+
sk = KeyPair.gen(para).sec.digest()[:-1]
107+
with raises(SLHDSAKeyException):
108+
SecretKey.from_digest(sk, para)
109+
with raises(SLHDSAKeyException):
110+
SecretKey.from_digest(sk+b'a', para)
111+
kp = KeyPair.gen(para).digest()[:-1]
112+
with raises(SLHDSAKeyException):
113+
KeyPair.from_digest(kp, para)
114+
with raises(SLHDSAKeyException):
115+
KeyPair.from_digest(kp+b'a', para)
116+
_for_all(judge)
117+

0 commit comments

Comments
 (0)