Skip to content

Commit 893813e

Browse files
committed
values method of SupportedAlgos class now supports filtering by PQAType
1 parent 3d5b42b commit 893813e

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

quantcrypt/internal/constants.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,11 @@ def items(cls) -> list[tuple[str, AlgoSpec]]:
116116
return [(k, v) for k, v in vars(cls).items() if isinstance(v, AlgoSpec)]
117117

118118
@classmethod
119-
def values(cls) -> list[AlgoSpec]:
120-
return [v for v in vars(cls).values() if isinstance(v, AlgoSpec)]
119+
def values(cls, pqa_type: PQAType | None = None) -> list[AlgoSpec]:
120+
return [
121+
v for v in vars(cls).values() if isinstance(v, AlgoSpec)
122+
and (not pqa_type or pqa_type == v.type)
123+
]
121124

122125

123126
KDFContext = b"quantcrypt"

tests/test_constants.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ def test_supported_algos():
112112
assert isinstance(item[1], const.AlgoSpec)
113113
for item in const.SupportedAlgos.values():
114114
assert isinstance(item, const.AlgoSpec)
115+
for pqa_type in const.PQAType.members():
116+
for item in const.SupportedAlgos.values(pqa_type):
117+
assert item.type == pqa_type
115118

116119

117120
def test_pqclean_repo_archive_url():

0 commit comments

Comments
 (0)