Split F4Jumble hashed test vectors into another file (`f4jumble_long.py`).
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
parent
bdf4c9ff9b
commit
cbaca139a7
25
f4jumble.py
25
f4jumble.py
|
@ -92,7 +92,6 @@ def main():
|
|||
rand = Rand(randbytes)
|
||||
|
||||
plain_test_vectors = []
|
||||
hashed_test_vectors = []
|
||||
|
||||
# Generate test vectors with various lengths:
|
||||
for l_M in [
|
||||
|
@ -115,20 +114,6 @@ def main():
|
|||
'jumbled': jumbled,
|
||||
})
|
||||
|
||||
for l_M in [
|
||||
(rand.u32() % (MAX_l_M - MIN_l_M)) + MIN_l_M,
|
||||
MAX_l_M,
|
||||
]:
|
||||
M = bytes([i & 0xFF for i in range(l_M)])
|
||||
jumbled = f4jumble(M)
|
||||
assert len(jumbled) == len(M)
|
||||
assert f4jumble_inv(jumbled) == M
|
||||
|
||||
hashed_test_vectors.append({
|
||||
'length': l_M,
|
||||
'jumbled_hash': blake2b(jumbled).digest()
|
||||
})
|
||||
|
||||
render_tv(
|
||||
args,
|
||||
'f4jumble',
|
||||
|
@ -138,16 +123,6 @@ def main():
|
|||
),
|
||||
plain_test_vectors,
|
||||
)
|
||||
print()
|
||||
render_tv(
|
||||
args,
|
||||
'f4jumble',
|
||||
(
|
||||
('length', 'usize'),
|
||||
('jumbled_hash', 'Vec<u8>'),
|
||||
),
|
||||
hashed_test_vectors,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env python3
|
||||
import sys; assert sys.version_info[0] >= 3, "Python 3 required."
|
||||
|
||||
from pyblake2 import blake2b
|
||||
|
||||
from tv_output import render_args, render_tv
|
||||
from f4jumble import f4jumble, f4jumble_inv, MAX_l_M
|
||||
|
||||
|
||||
def main():
|
||||
args = render_args()
|
||||
|
||||
hashed_test_vectors = []
|
||||
|
||||
for l_M in [
|
||||
3246395,
|
||||
MAX_l_M,
|
||||
]:
|
||||
M = bytes([i & 0xFF for i in range(l_M)])
|
||||
jumbled = f4jumble(M)
|
||||
assert len(jumbled) == len(M)
|
||||
assert f4jumble_inv(jumbled) == M
|
||||
|
||||
hashed_test_vectors.append({
|
||||
'length': l_M,
|
||||
'jumbled_hash': blake2b(jumbled).digest()
|
||||
})
|
||||
|
||||
render_tv(
|
||||
args,
|
||||
'f4jumble_long',
|
||||
(
|
||||
('length', 'usize'),
|
||||
('jumbled_hash', 'Vec<u8>'),
|
||||
),
|
||||
hashed_test_vectors,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in New Issue