123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- #parse argument
- architecture=$1
- permutation=$2
- matrix_decompressed_file=$3
- matrix_comp_file=$4
- output_dir=$5
- lorem_ipsum_file=$6
- if [ $permutation -eq 0 ] ; then
- permutation_str=""
- else
- permutation_str=" -no-permutation-key "
- fi
- # generate keys
- str="
- xrnlib-cli \
- --encoding-conf -compiled-param -no-password \
- --permutation-conf -arch $architecture $permutation_str \
- --make-monomial-key -monomial-key $output_dir/asym_enc_monomial_key_file.xf
- "
- echo ""; echo $str; echo ""
- eval $str
- str="
- xrnlib-cli \
- --decoding-conf -compiled-param -no-password \
- --encoding-conf -compiled-param -no-password \
- --sequence-conf -xmatrix $matrix_decompressed_file \
- --permutation-conf -arch $architecture $permutation_str \
- --make-start-point -start-point $output_dir/asym_enc_start_point_file.xf
- "
- echo ""; echo $str; echo ""
- eval $str
- str="
- xrnlib-cli \
- --decoding-conf -compiled-param -no-password \
- --encoding-conf -compiled-param -no-password \
- --arithmetic-conf -start-point $output_dir/asym_enc_start_point_file.xf -monomial-key $output_dir/asym_enc_monomial_key_file.xf \
- --sequence-conf -xmatrix $matrix_decompressed_file \
- --permutation-conf -arch $architecture \
- --make-binomial-key -binomial-key $output_dir/asym_enc_binomial_key_file.xf
- "
- echo ""; echo $str; echo ""
- eval $str
- # encrypt
- str="
- xrnlib-cli \
- --decoding-conf -compiled-param -no-password \
- --encoding-conf -compiled-param -no-password \
- --arithmetic-conf -binomial-key $output_dir/asym_enc_binomial_key_file.xf \
- --sequence-conf -xmatrix $matrix_decompressed_file \
- --permutation-conf -arch $architecture \
- --encrypt-asymmetric -plain-text $lorem_ipsum_file -cipher-text $output_dir/asym_enc_lorem_ipsum_file
- "
- echo ""; echo $str; echo ""
- eval $str
- # decrypt
- str="
- xrnlib-cli \
- --decoding-conf -compiled-param -no-password \
- --arithmetic-conf -monomial-key $output_dir/asym_enc_monomial_key_file.xf \
- --sequence-conf -xmatrix $matrix_decompressed_file \
- --permutation-conf -arch $architecture \
- --decipher-asymmetric -plain-text $output_dir/asym_enc_lorem_ipsum_file_decyphered -cipher-text $output_dir/asym_enc_lorem_ipsum_file
- "
- echo ""; echo $str; echo ""
- eval $str
- str="
- cmp --silent $output_dir/asym_enc_lorem_ipsum_file_decyphered $lorem_ipsum_file && echo 'PASS' || echo 'FAIL'
- "
- echo ""; echo $str; echo ""
- eval $str
- # permute cypher
- cat $output_dir/asym_enc_lorem_ipsum_file | sed 's/$/?/' > $output_dir/asym_enc_lorem_ipsum_file_wrong
- # perform decryption
- str="
- xrnlib-cli \
- --decoding-conf -compiled-param -no-password \
- --arithmetic-conf -monomial-key $output_dir/asym_enc_monomial_key_file.xf \
- --sequence-conf -xmatrix $matrix_decompressed_file \
- --permutation-conf -arch $architecture \
- --logging-conf -lib-error-log $output_dir/wrong_lib_info_log_file.xf \
- --decipher-asymmetric -plain-text $output_dir/asym_enc_lorem_ipsum_file_decyphered_wrong -cipher-text $output_dir/asym_enc_lorem_ipsum_file_wrong "
- echo ""; echo $str; echo ""
- eval $str
- str="
- if [ ! -s $output_dir/wrong_lib_info_log_file.xf ] ; then echo 'FAIL' ; exit ; fi
- "
- echo ""; echo $str; echo ""
- eval $str
- str="
- cmp --silent $output_dir/asym_enc_lorem_ipsum_file_decyphered_wrong $lorem_ipsum_file && echo 'FAIL'
- "
- echo ""; echo $str; echo ""
- eval $str
|