Skip to content

Fix/reduce mem usage in some pytests #335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,30 @@ def test_keccak_invertible_permutation():
'0000000000000000000000', 16)
assert keccak.evaluate([plaintext]) == ciphertext

# Very long test
plaintext = int('0xf1258f7940e1dde784d5ccf933c0478ad598261ea65aa9eebd1547306f80494d8b284e056253d057ff97a42d7f8e6f'
'd490fee5a0a44647c48c5bda0cd6192e76ad30a6f71b19059c30935ab7d08ffc64eb5aa93f2317d635a9a6e6260d7121'
'0381a57c16dbcf555f43b831cd0347c82601f22f1a11a5569f05e5635a21d9ae6164befef28cc970f2613670957bc466'
'11b87c5a554fd00ecb8c3ee88a1ccf32c8940c7922ae3a26141841f924a2c509e416f53526e70465c275f644e97f30a1'
'3beaf1ff7b5ceca249', 16)
ciphertext = int('0x7da852fb04497b0a894ec24cdf6de92aff6e9cb2d9b82c205c8f5ef41367412f9e341a1d45dc7cb9754bd8010a687'
'5ae6bc9e3fde54d0d63680c01bc9e12e891efdcc728724da09aeaf79b1f5e8ebc41d7d9256e50e369d8f98dd4fb0055'
'ee825c090034935bf012b0cb7849e930b86534d6137db0b948f13de547bd2f116f9c22cfbb2cc488de1cabb64b90bfd'
'7f864d035e36e9f592fdbda0c4b9af7eb5a9ff16d4c4ee3b1c1aa41d32b6f26f9e4794d5bac33329974c93d9a2ac3f0'
'3d425e939397161e889b37', 16)
assert keccak.evaluate([plaintext]) == ciphertext

# # Very long test
keccak = KeccakInvertiblePermutation(number_of_rounds=2)
plaintext = int('0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
'000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
'000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
'000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
'000000000000000000', 16)
ciphertext = int('0x808300001000000000000000000000008000000000000000000100001000000080000000000000000000000020000'
'02000000000000000000000000020000000000000000000002000000000000000000002000000000000020000000000'
'00000000000000000000020200000000000000000000000010000400000000000000000000000000000004000000000'
'01000000000000000000000000000010000000000000000000000000000000100000000040000000000000000000000'
'0000000004', 16)
assert keccak.evaluate([plaintext]) == ciphertext
# plaintext = int('0xf1258f7940e1dde784d5ccf933c0478ad598261ea65aa9eebd1547306f80494d8b284e056253d057ff97a42d7f8e6f'
# 'd490fee5a0a44647c48c5bda0cd6192e76ad30a6f71b19059c30935ab7d08ffc64eb5aa93f2317d635a9a6e6260d7121'
# '0381a57c16dbcf555f43b831cd0347c82601f22f1a11a5569f05e5635a21d9ae6164befef28cc970f2613670957bc466'
# '11b87c5a554fd00ecb8c3ee88a1ccf32c8940c7922ae3a26141841f924a2c509e416f53526e70465c275f644e97f30a1'
# '3beaf1ff7b5ceca249', 16)
# ciphertext = int('0x7da852fb04497b0a894ec24cdf6de92aff6e9cb2d9b82c205c8f5ef41367412f9e341a1d45dc7cb9754bd8010a687'
# '5ae6bc9e3fde54d0d63680c01bc9e12e891efdcc728724da09aeaf79b1f5e8ebc41d7d9256e50e369d8f98dd4fb0055'
# 'ee825c090034935bf012b0cb7849e930b86534d6137db0b948f13de547bd2f116f9c22cfbb2cc488de1cabb64b90bfd'
# '7f864d035e36e9f592fdbda0c4b9af7eb5a9ff16d4c4ee3b1c1aa41d32b6f26f9e4794d5bac33329974c93d9a2ac3f0'
# '3d425e939397161e889b37', 16)
# assert keccak.evaluate([plaintext]) == ciphertext
#
# # # Very long test
# keccak = KeccakInvertiblePermutation(number_of_rounds=2)
# plaintext = int('0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
# '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
# '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
# '000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
# '000000000000000000', 16)
# ciphertext = int('0x808300001000000000000000000000008000000000000000000100001000000080000000000000000000000020000'
# '02000000000000000000000000020000000000000000000002000000000000000000002000000000000020000000000'
# '00000000000000000000020200000000000000000000000010000400000000000000000000000000000004000000000'
# '01000000000000000000000000000010000000000000000000000000000000100000000040000000000000000000000'
# '0000000004', 16)
# assert keccak.evaluate([plaintext]) == ciphertext
assert keccak.evaluate_vectorized([plaintext], evaluate_api=True) == ciphertext
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ def test_spongent_pi_fsr_permutation():
assert spongentpi.component_from(3, 0).id == 'fsr_3_0'

# Very long test
spongentpi = SpongentPiFSRPermutation()
# spongentpi = SpongentPiFSRPermutation()
plaintext = 0x0000000000000000000000000000000000000000
ciphertext = 0xcaed745fb9d13ede0ec562a18682cba286000ce8
# ciphertext = 0xcaed745fb9d13ede0ec562a18682cba286000ce8 # ciphertext for default 80 rounds
ciphertext = 0x60a224efe52f9f1febbfe51f7a2dc9564341167
assert spongentpi.evaluate([plaintext]) == ciphertext

# Very long test
spongentpi = SpongentPiFSRPermutation(state_bit_size=176, number_of_rounds=90)
spongentpi = SpongentPiFSRPermutation(state_bit_size=176, number_of_rounds=4)
plaintext = 0x0123456789abcdef0123456789abcdef0123456789ab
ciphertext = 0x04adf4b51546dc10694325ff73b1352f141d8023da08
#ciphertext = 0x04adf4b51546dc10694325ff73b1352f141d8023da08 # ciphertext for 90 rounds
ciphertext = 0x8675478f97cafe723bf668c5e573ae9b582131499660
assert spongentpi.evaluate([plaintext]) == ciphertext
#assert spongentpi.evaluate_vectorized([plaintext], evaluate_api=True) == ciphertext
10 changes: 6 additions & 4 deletions tests/unit/ciphers/permutations/spongent_pi_permutation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ def test_spongent_pi_permutation():
assert spongentpi.component_from(3, 0).id == 'linear_layer_3_0'

# Very long test
spongentpi = SpongentPiPermutation()
#spongentpi = SpongentPiPermutation()
plaintext = 0x0000000000000000000000000000000000000000
ciphertext = 0xcaed745fb9d13ede0ec562a18682cba286000ce8
#ciphertext = 0xcaed745fb9d13ede0ec562a18682cba286000ce8 # ciphertext for default 80 rounds
ciphertext = 0x60a224efe52f9f1febbfe51f7a2dc9564341167
assert spongentpi.evaluate([plaintext]) == ciphertext

# Very long test
spongentpi = SpongentPiPermutation(state_bit_size=176, number_of_rounds=90)
spongentpi = SpongentPiPermutation(state_bit_size=176, number_of_rounds=4)
plaintext = 0x0123456789abcdef0123456789abcdef0123456789ab
ciphertext = 0x04adf4b51546dc10694325ff73b1352f141d8023da08
#ciphertext = 0x04adf4b51546dc10694325ff73b1352f141d8023da08 # ciphertext for 90 rounds
ciphertext = 0x8675478f97cafe723bf668c5e573ae9b582131499660
assert spongentpi.evaluate([plaintext]) == ciphertext
assert spongentpi.evaluate_vectorized([plaintext], evaluate_api=True) == ciphertext
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ def test_spongent_pi_precomputation_permutation():
assert spongentpi.component_from(3, 0).id == 'constant_3_0'

# Very long test
spongentpi = SpongentPiPrecomputationPermutation()
#spongentpi = SpongentPiPrecomputationPermutation()
plaintext = 0x0000000000000000000000000000000000000000
ciphertext = 0xcaed745fb9d13ede0ec562a18682cba286000ce8
#ciphertext = 0xcaed745fb9d13ede0ec562a18682cba286000ce8 # ciphertext for default 80 rounds
ciphertext = 0x60a224efe52f9f1febbfe51f7a2dc9564341167
assert spongentpi.evaluate([plaintext]) == ciphertext

# Very long test
spongentpi = SpongentPiPrecomputationPermutation(state_bit_size=176, number_of_rounds=90)
spongentpi = SpongentPiPrecomputationPermutation(state_bit_size=176, number_of_rounds=4)
plaintext = 0x0123456789abcdef0123456789abcdef0123456789ab
ciphertext = 0x04adf4b51546dc10694325ff73b1352f141d8023da08
#ciphertext = 0x04adf4b51546dc10694325ff73b1352f141d8023da08 # ciphertext for 90 rounds
ciphertext = 0x8675478f97cafe723bf668c5e573ae9b582131499660
assert spongentpi.evaluate([plaintext]) == ciphertext
assert spongentpi.evaluate_vectorized([plaintext], evaluate_api=True) == ciphertext
Loading