-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_compatibility.sh
executable file
·47 lines (40 loc) · 1.33 KB
/
test_compatibility.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
make -C ref {test/sign,test/open,test/keypair,test/mq}
make -C avx2 {test/sign,test/open,test/keypair,test/mq}
N=48
SEED_BYTES=16
keyfile=$(mktemp)
mfile=$(mktemp)
smfile=$(mktemp)
for keygen in {"ref","avx2"}; do
for signer in {"ref","avx2"}; do
for verifier in {"ref","avx2"}; do
echo -n "Testing with keygen: ${keygen}, signer: ${signer}, verifier: ${verifier}.. "
${keygen}/test/keypair > ${keyfile}
head -c 32 /dev/urandom > ${mfile}
tail -c ${SEED_BYTES} ${keyfile} | cat - ${mfile} | ${signer}/test/sign > ${smfile}
head -c $((SEED_BYTES + N * 5 / 8)) ${keyfile} | cat - ${smfile} | ${verifier}/test/open
if [ $? -eq 0 ]
then
echo "succeeded!"
else
echo "failed!"
fi
done
done
done
rm ${keyfile}
rm ${mfile}
rm ${smfile}
mqfile_in=$(mktemp)
mqfile_ref=$(mktemp)
mqfile_avx2=$(mktemp)
# input is 40 bytes of packed x, 32 bytes of Fseed
head -c $((SEED_BYTES + N * 5 / 8)) /dev/urandom > ${mqfile_in}
ref/test/mq < ${mqfile_in} > ${mqfile_ref}
avx2/test/mq < ${mqfile_in} > ${mqfile_avx2}
echo -n "Testing if ref/mq and avx2/mq are identical.. "
cmp --silent ${mqfile_ref} ${mqfile_avx2} && echo "succeeded!" || echo "failed!"
rm ${mqfile_in}
rm ${mqfile_ref}
rm ${mqfile_avx2}