Skip to content

Commit

Permalink
minors
Browse files Browse the repository at this point in the history
  • Loading branch information
hadielyakhni committed Feb 29, 2024
1 parent 9d54251 commit 0f35267
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions Standalone/KangarooTwelve/Python/K12-SIMD-simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ def KT128(inputMessage, customizationString, outputByteLen):
+ right_encode(n) + b'\xFF\xFF'
return TurboSHAKE128(NodeStar, 0x06, outputByteLen)


def KT256(inputMessage, customizationString, outputByteLen):
c = 512
# Concatenate the input message, the customization string and the length of the latter
Expand Down Expand Up @@ -328,7 +329,6 @@ def KT256(inputMessage, customizationString, outputByteLen):
return TurboSHAKE256(NodeStar, 0x06, outputByteLen)



# Test that KeccakP1600timesN_SIMD does what it is supposed to
def Test_KeccakP1600timesN_SIMD():
for N in range(1, 5):
Expand Down Expand Up @@ -377,17 +377,20 @@ def printK12TestVectors():
print("KangarooTwelve(M={0:d} times byte 0xFF, C=pattern 0x00 to 0xFA for 41^{1:d} bytes, 32 output bytes):".format(2**i-1, i))
outputHex(KT128(M, C, 32))


# for testing reasons, inspired by the test vectors of the update KangarooTwelve draft
# https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-kangarootwelve
def ptn(n):
pattern = bytes(range(0xFA + 1)) # Include 0xFA
repetitions = n // len(pattern)
remainder = n % len(pattern)
repeated_pattern = pattern * repetitions + pattern[:remainder]
return repeated_pattern


# outputHex(KT256(b'', b'', 64))
# print()
# outputHex(KT256(b'', b'', 128))

# outputHex(KT256(ptn(17), b'', 64))
# print()
# outputHex(KT256(ptn(17**2), b'', 64))
Expand All @@ -411,6 +414,6 @@ def ptn(n):
# outputHex(KT256(ptn(8192), ptn(8190), 64))


# Test_KeccakP1600timesN_SIMD()
# Test_KangarooTwelve_ProcessLeaves_128()
# printK12TestVectors()
Test_KeccakP1600timesN_SIMD()
Test_KangarooTwelve_ProcessLeaves_128()
printK12TestVectors()

0 comments on commit 0f35267

Please sign in to comment.