implememnt identity property

This commit is contained in:
2024-07-04 09:13:48 -05:00
parent e2b6ca014e
commit 5e3164feea
2 changed files with 25 additions and 2 deletions

View File

@@ -116,6 +116,14 @@ class OuterKey(DarcKey):
matrix=matrix,
)
@classmethod
def init_identity_matrix(cls, height: int):
""" originally buildRandom """
matrix = [list(range(height))]
return OuterKey(
matrix=matrix,
)
class InnerKey(DarcKey):
key_type: DarcKeyType = DarcKeyType.inner_shuffle
@@ -128,6 +136,14 @@ class InnerKey(DarcKey):
matrix=matrix,
)
@classmethod
def init_identity_matrix(cls, width: int, height: int):
""" originally buildRandom """
matrix = [list(range(width)) for _ in range(height)]
return InnerKey(
matrix=matrix,
)
class SubstitutionKey(DarcKey):
key_type: DarcKeyType = DarcKeyType.substitution
@@ -138,7 +154,14 @@ class SubstitutionKey(DarcKey):
matrix = [cls._random_mask(width, max_value) for _ in range(height)]
return SubstitutionKey(
matrix=matrix,
max_value=max_value
)
@classmethod
def init_identity_matrix(cls, width: int, height: int):
""" originally buildScramble """
matrix = [[0 for _ in range(width)] for _ in range(height)]
return SubstitutionKey(
matrix=matrix,
)