diff options
Diffstat (limited to 'moon-abe/pbc-0.5.14/benchmark')
-rw-r--r-- | moon-abe/pbc-0.5.14/benchmark/.dirstamp | 0 | ||||
-rwxr-xr-x | moon-abe/pbc-0.5.14/benchmark/.libs/benchmark | bin | 0 -> 14815 bytes | |||
-rwxr-xr-x | moon-abe/pbc-0.5.14/benchmark/.libs/ellnet | bin | 0 -> 14802 bytes | |||
-rwxr-xr-x | moon-abe/pbc-0.5.14/benchmark/.libs/timersa | bin | 0 -> 14812 bytes | |||
-rw-r--r-- | moon-abe/pbc-0.5.14/benchmark/REPORT.BAT | 18 | ||||
-rwxr-xr-x | moon-abe/pbc-0.5.14/benchmark/benchmark | 228 | ||||
-rw-r--r-- | moon-abe/pbc-0.5.14/benchmark/benchmark.c | 109 | ||||
-rwxr-xr-x | moon-abe/pbc-0.5.14/benchmark/ellnet | 228 | ||||
-rw-r--r-- | moon-abe/pbc-0.5.14/benchmark/ellnet.c | 65 | ||||
-rw-r--r-- | moon-abe/pbc-0.5.14/benchmark/multipairing.c | 62 | ||||
-rw-r--r-- | moon-abe/pbc-0.5.14/benchmark/report_times | 7 | ||||
-rwxr-xr-x | moon-abe/pbc-0.5.14/benchmark/timersa | 228 | ||||
-rw-r--r-- | moon-abe/pbc-0.5.14/benchmark/timersa.c | 83 |
13 files changed, 1028 insertions, 0 deletions
diff --git a/moon-abe/pbc-0.5.14/benchmark/.dirstamp b/moon-abe/pbc-0.5.14/benchmark/.dirstamp new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/moon-abe/pbc-0.5.14/benchmark/.dirstamp diff --git a/moon-abe/pbc-0.5.14/benchmark/.libs/benchmark b/moon-abe/pbc-0.5.14/benchmark/.libs/benchmark Binary files differnew file mode 100755 index 00000000..b4e2f922 --- /dev/null +++ b/moon-abe/pbc-0.5.14/benchmark/.libs/benchmark diff --git a/moon-abe/pbc-0.5.14/benchmark/.libs/ellnet b/moon-abe/pbc-0.5.14/benchmark/.libs/ellnet Binary files differnew file mode 100755 index 00000000..8645e28a --- /dev/null +++ b/moon-abe/pbc-0.5.14/benchmark/.libs/ellnet diff --git a/moon-abe/pbc-0.5.14/benchmark/.libs/timersa b/moon-abe/pbc-0.5.14/benchmark/.libs/timersa Binary files differnew file mode 100755 index 00000000..d8f1be71 --- /dev/null +++ b/moon-abe/pbc-0.5.14/benchmark/.libs/timersa diff --git a/moon-abe/pbc-0.5.14/benchmark/REPORT.BAT b/moon-abe/pbc-0.5.14/benchmark/REPORT.BAT new file mode 100644 index 00000000..c617b436 --- /dev/null +++ b/moon-abe/pbc-0.5.14/benchmark/REPORT.BAT @@ -0,0 +1,18 @@ +@echo off
+rem Batch file for timing various pairings
+echo A
+benchmark < a.param | find "average"
+echo D159
+benchmark < d159.param | find "average"
+echo D201
+benchmark < d201.param | find "average"
+echo D224
+benchmark < d224.param | find "average"
+echo E
+benchmark < e.param | find "average"
+echo F
+benchmark < f.param | find "average"
+echo G
+benchmark < g149.param | find "average"
+echo A1
+benchmark < a1.param | find "average"
diff --git a/moon-abe/pbc-0.5.14/benchmark/benchmark b/moon-abe/pbc-0.5.14/benchmark/benchmark new file mode 100755 index 00000000..c1cdadf3 --- /dev/null +++ b/moon-abe/pbc-0.5.14/benchmark/benchmark @@ -0,0 +1,228 @@ +#! /bin/sh + +# benchmark/benchmark - temporary wrapper script for .libs/benchmark +# Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1 +# +# The benchmark/benchmark program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s/\([`"$\\]\)/\\\1/g' + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="(cd /home/wukong/Dropbox/04_Workspace/opnfv-moon/moon-abe/pbc-0.5.14; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=/sbin:/usr/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin; export PATH; gcc -Wall -W -Wfloat-equal -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wredundant-decls -Wendif-labels -Wshadow -pipe -ffast-math -U__STRICT_ANSI__ -std=gnu99 -fomit-frame-pointer -O3 -o \$progdir/\$file benchmark_benchmark-benchmark.o ./.libs/libpbc.so -lgmp -lm -Wl,-rpath -Wl,/home/wukong/Dropbox/04_Workspace/opnfv-moon/moon-abe/pbc-0.5.14/.libs)" + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variables: + generated_by_libtool_version='2.4.2' + notinst_deplibs=' libpbc.la' +else + # When we are sourced in execute mode, $file and $ECHO are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + file="$0" + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' +} + ECHO="printf %s\\n" + fi + +# Very basic option parsing. These options are (a) specific to +# the libtool wrapper, (b) are identical between the wrapper +# /script/ and the wrapper /executable/ which is used only on +# windows platforms, and (c) all begin with the string --lt- +# (application programs are unlikely to have options which match +# this pattern). +# +# There are only two supported options: --lt-debug and +# --lt-dump-script. There is, deliberately, no --lt-help. +# +# The first argument to this parsing function should be the +# script's ./libtool value, followed by no. +lt_option_debug= +func_parse_lt_options () +{ + lt_script_arg0=$0 + shift + for lt_opt + do + case "$lt_opt" in + --lt-debug) lt_option_debug=1 ;; + --lt-dump-script) + lt_dump_D=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%/[^/]*$%%'` + test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=. + lt_dump_F=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%^.*/%%'` + cat "$lt_dump_D/$lt_dump_F" + exit 0 + ;; + --lt-*) + $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2 + exit 1 + ;; + esac + done + + # Print the debug banner immediately: + if test -n "$lt_option_debug"; then + echo "benchmark:benchmark/benchmark:${LINENO}: libtool wrapper (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1" 1>&2 + fi +} + +# Used when --lt-debug. Prints its arguments to stdout +# (redirection is the responsibility of the caller) +func_lt_dump_args () +{ + lt_dump_args_N=1; + for lt_arg + do + $ECHO "benchmark:benchmark/benchmark:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg" + lt_dump_args_N=`expr $lt_dump_args_N + 1` + done +} + +# Core function for launching the target application +func_exec_program_core () +{ + + if test -n "$lt_option_debug"; then + $ECHO "benchmark:benchmark/benchmark:${LINENO}: newargv[0]: $progdir/$program" 1>&2 + func_lt_dump_args ${1+"$@"} 1>&2 + fi + exec "$progdir/$program" ${1+"$@"} + + $ECHO "$0: cannot exec $program $*" 1>&2 + exit 1 +} + +# A function to encapsulate launching the target application +# Strips options in the --lt-* namespace from $@ and +# launches target application with the remaining arguments. +func_exec_program () +{ + case " $* " in + *\ --lt-*) + for lt_wr_arg + do + case $lt_wr_arg in + --lt-*) ;; + *) set x "$@" "$lt_wr_arg"; shift;; + esac + shift + done ;; + esac + func_exec_program_core ${1+"$@"} +} + + # Parse options + func_parse_lt_options "$0" ${1+"$@"} + + # Find the directory that this script lives in. + thisdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$ECHO "$file" | /bin/sed 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` + done + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no + if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then + # special case for '.' + if test "$thisdir" = "."; then + thisdir=`pwd` + fi + # remove .libs from thisdir + case "$thisdir" in + *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /bin/sed 's%[\\/][^\\/]*$%%'` ;; + .libs ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program=lt-'benchmark' + progdir="$thisdir/.libs" + + if test ! -f "$progdir/$program" || + { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ + test "X$file" != "X$progdir/$program"; }; then + + file="$$-$program" + + if test ! -d "$progdir"; then + mkdir "$progdir" + else + rm -f "$progdir/$file" + fi + + # relink executable if necessary + if test -n "$relink_command"; then + if relink_command_output=`eval $relink_command 2>&1`; then : + else + printf %s\n "$relink_command_output" >&2 + rm -f "$progdir/$file" + exit 1 + fi + fi + + mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || + { rm -f "$progdir/$program"; + mv -f "$progdir/$file" "$progdir/$program"; } + rm -f "$progdir/$file" + fi + + if test -f "$progdir/$program"; then + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + func_exec_program ${1+"$@"} + fi + else + # The program doesn't exist. + $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2 + $ECHO "This script is just a wrapper for $program." 1>&2 + $ECHO "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi diff --git a/moon-abe/pbc-0.5.14/benchmark/benchmark.c b/moon-abe/pbc-0.5.14/benchmark/benchmark.c new file mode 100644 index 00000000..b80c1554 --- /dev/null +++ b/moon-abe/pbc-0.5.14/benchmark/benchmark.c @@ -0,0 +1,109 @@ +#include <stdint.h> // for intptr_t +#include "pbc.h" +#include "pbc_test.h" + +/* I've heard that sometimes automatic garbage collection can outperform + * manual collection, so I briefly tried using the Boehm-Demers-Weiser GC + * library. Both GMP and PBC support custom memory allocation routines so + * incorporating the GC library is trivial. + * + * Automatic garbage collection appears to slow this program down a little, + * even if only PBC collects automatically. (The case where PBC collects + * manually but GMP collects automatically cannot be achieved with the GC + * library because PBC objects point at GMP objects.) + * + * Perhaps specially-tailored memory allocation routines could shave off + * some time, but one would have to thoroughly analyze PBC and GMP memory usage + * patterns. + * + * Below is the commented-out code that collects garbage for PBC. Of course, + * if you want to use it you must also tell the build system where to find + * gc.h and to link with the GC library. + * + * Also, you may wish to write similar code for GMP (which I unfortunately + * deleted before thinking that it might be useful for others). + * Note GC_MALLOC_ATOMIC may be used for GMP since the mpz_t type does not + * store pointers in the memory it allocates. + * + * The malloc and realloc functions should exit on failure but I didn't + * bother since I was only seeing if GC could speed up this program. + +#include <gc.h> +#include <pbc_utils.h> + +void *gc_alloc(size_t size) { + return GC_MALLOC(size); +} + +void *gc_realloc(void *ptr, size_t size) { + return GC_REALLOC(ptr, size); +} + +void gc_free(void *ptr) { + UNUSED_VAR(ptr); +} + + * The following should be the first two statements in main() + +GC_INIT(); +pbc_set_memory_functions(gc_alloc, gc_realloc, gc_free); + + */ + +int main(int argc, char **argv) { + pairing_t pairing; + element_t x, y, r, r2; + int i, n; + double t0, t1, ttotal, ttotalpp; + pairing_pp_t pp; + + // Cheat for slightly faster times: + // pbc_set_memory_functions(malloc, realloc, free); + + pbc_demo_pairing_init(pairing, argc, argv); + + element_init_G1(x, pairing); + element_init_G2(y, pairing); + element_init_GT(r, pairing); + element_init_GT(r2, pairing); + + n = 10; + ttotal = 0.0; + ttotalpp = 0.0; + for (i=0; i<n; i++) { + element_random(x); + element_random(y); + + pairing_pp_init(pp, x, pairing); + t0 = pbc_get_time(); + pairing_pp_apply(r, y, pp); + t1 = pbc_get_time(); + ttotalpp += t1 - t0; + pairing_pp_clear(pp); + + t0 = pbc_get_time(); + + element_pairing(r2, x, y); + t1 = pbc_get_time(); + ttotal += t1 - t0; + + element_printf("x = %B\n", x); + element_printf("y = %B\n", y); + element_printf("e(x,y) = %B\n", r); + if (element_cmp(r, r2)) { + printf("BUG!\n"); + exit(1); + } + } + printf("average pairing time = %f\n", ttotal / n); + printf("average pairing time (preprocessed) = %f\n", ttotalpp / n); + + element_clear(x); + element_clear(y); + element_clear(r); + element_clear(r2); + + pairing_clear(pairing); + + return 0; +} diff --git a/moon-abe/pbc-0.5.14/benchmark/ellnet b/moon-abe/pbc-0.5.14/benchmark/ellnet new file mode 100755 index 00000000..d864bd97 --- /dev/null +++ b/moon-abe/pbc-0.5.14/benchmark/ellnet @@ -0,0 +1,228 @@ +#! /bin/sh + +# benchmark/ellnet - temporary wrapper script for .libs/ellnet +# Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1 +# +# The benchmark/ellnet program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s/\([`"$\\]\)/\\\1/g' + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="(cd /home/wukong/Dropbox/04_Workspace/opnfv-moon/moon-abe/pbc-0.5.14; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=/sbin:/usr/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin; export PATH; gcc -Wall -W -Wfloat-equal -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wredundant-decls -Wendif-labels -Wshadow -pipe -ffast-math -U__STRICT_ANSI__ -std=gnu99 -fomit-frame-pointer -O3 -o \$progdir/\$file benchmark_ellnet-ellnet.o ./.libs/libpbc.so -lgmp -lm -Wl,-rpath -Wl,/home/wukong/Dropbox/04_Workspace/opnfv-moon/moon-abe/pbc-0.5.14/.libs)" + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variables: + generated_by_libtool_version='2.4.2' + notinst_deplibs=' libpbc.la' +else + # When we are sourced in execute mode, $file and $ECHO are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + file="$0" + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' +} + ECHO="printf %s\\n" + fi + +# Very basic option parsing. These options are (a) specific to +# the libtool wrapper, (b) are identical between the wrapper +# /script/ and the wrapper /executable/ which is used only on +# windows platforms, and (c) all begin with the string --lt- +# (application programs are unlikely to have options which match +# this pattern). +# +# There are only two supported options: --lt-debug and +# --lt-dump-script. There is, deliberately, no --lt-help. +# +# The first argument to this parsing function should be the +# script's ./libtool value, followed by no. +lt_option_debug= +func_parse_lt_options () +{ + lt_script_arg0=$0 + shift + for lt_opt + do + case "$lt_opt" in + --lt-debug) lt_option_debug=1 ;; + --lt-dump-script) + lt_dump_D=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%/[^/]*$%%'` + test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=. + lt_dump_F=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%^.*/%%'` + cat "$lt_dump_D/$lt_dump_F" + exit 0 + ;; + --lt-*) + $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2 + exit 1 + ;; + esac + done + + # Print the debug banner immediately: + if test -n "$lt_option_debug"; then + echo "ellnet:benchmark/ellnet:${LINENO}: libtool wrapper (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1" 1>&2 + fi +} + +# Used when --lt-debug. Prints its arguments to stdout +# (redirection is the responsibility of the caller) +func_lt_dump_args () +{ + lt_dump_args_N=1; + for lt_arg + do + $ECHO "ellnet:benchmark/ellnet:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg" + lt_dump_args_N=`expr $lt_dump_args_N + 1` + done +} + +# Core function for launching the target application +func_exec_program_core () +{ + + if test -n "$lt_option_debug"; then + $ECHO "ellnet:benchmark/ellnet:${LINENO}: newargv[0]: $progdir/$program" 1>&2 + func_lt_dump_args ${1+"$@"} 1>&2 + fi + exec "$progdir/$program" ${1+"$@"} + + $ECHO "$0: cannot exec $program $*" 1>&2 + exit 1 +} + +# A function to encapsulate launching the target application +# Strips options in the --lt-* namespace from $@ and +# launches target application with the remaining arguments. +func_exec_program () +{ + case " $* " in + *\ --lt-*) + for lt_wr_arg + do + case $lt_wr_arg in + --lt-*) ;; + *) set x "$@" "$lt_wr_arg"; shift;; + esac + shift + done ;; + esac + func_exec_program_core ${1+"$@"} +} + + # Parse options + func_parse_lt_options "$0" ${1+"$@"} + + # Find the directory that this script lives in. + thisdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$ECHO "$file" | /bin/sed 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` + done + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no + if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then + # special case for '.' + if test "$thisdir" = "."; then + thisdir=`pwd` + fi + # remove .libs from thisdir + case "$thisdir" in + *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /bin/sed 's%[\\/][^\\/]*$%%'` ;; + .libs ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program=lt-'ellnet' + progdir="$thisdir/.libs" + + if test ! -f "$progdir/$program" || + { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ + test "X$file" != "X$progdir/$program"; }; then + + file="$$-$program" + + if test ! -d "$progdir"; then + mkdir "$progdir" + else + rm -f "$progdir/$file" + fi + + # relink executable if necessary + if test -n "$relink_command"; then + if relink_command_output=`eval $relink_command 2>&1`; then : + else + printf %s\n "$relink_command_output" >&2 + rm -f "$progdir/$file" + exit 1 + fi + fi + + mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || + { rm -f "$progdir/$program"; + mv -f "$progdir/$file" "$progdir/$program"; } + rm -f "$progdir/$file" + fi + + if test -f "$progdir/$program"; then + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + func_exec_program ${1+"$@"} + fi + else + # The program doesn't exist. + $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2 + $ECHO "This script is just a wrapper for $program." 1>&2 + $ECHO "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi diff --git a/moon-abe/pbc-0.5.14/benchmark/ellnet.c b/moon-abe/pbc-0.5.14/benchmark/ellnet.c new file mode 100644 index 00000000..8a866a65 --- /dev/null +++ b/moon-abe/pbc-0.5.14/benchmark/ellnet.c @@ -0,0 +1,65 @@ +#include <pbc.h> +#include "pbc_test.h" + +void time_pairing(pairing_ptr pairing) { + int i, n; + double t0, t1, ttotal, ttotalpp; + pairing_pp_t pp; + element_t x, y, r, r2; + element_init_G1(x, pairing); + element_init_G2(y, pairing); + element_init_GT(r, pairing); + element_init_GT(r2, pairing); + + n = 10; + ttotal = 0.0; + ttotalpp = 0.0; + for (i=0; i<n; i++) { + element_random(x); + element_random(y); + + pairing_pp_init(pp, x, pairing); + t0 = pbc_get_time(); + pairing_pp_apply(r, y, pp); + t1 = pbc_get_time(); + ttotalpp += t1 - t0; + pairing_pp_clear(pp); + + t0 = pbc_get_time(); + element_pairing(r2, x, y); + t1 = pbc_get_time(); + ttotal += t1 - t0; + + //element_printf("x = %B\n", x); + //element_printf("y = %B\n", y); + //element_printf("e(x,y) = %B\n", r); + if (element_cmp(r, r2)) { + printf("BUG!\n"); + exit(1); + } + } + printf("average pairing time = %f\n", ttotal / n); + printf("average pairing time (preprocessed) = %f\n", ttotalpp / n); + + element_clear(x); + element_clear(y); + element_clear(r); + element_clear(r2); +} + +int main(int argc, char **argv) { + pairing_t pairing; + + pbc_demo_pairing_init(pairing, argc, argv); + + printf("Miller's algorithm\n"); + time_pairing(pairing); + + pairing_option_set(pairing, "method", "shipsey-stange"); + printf("Shipsey-Stange algorithm\n"); + time_pairing(pairing); + + pairing_clear(pairing); + + return 0; +} diff --git a/moon-abe/pbc-0.5.14/benchmark/multipairing.c b/moon-abe/pbc-0.5.14/benchmark/multipairing.c new file mode 100644 index 00000000..39c9ce77 --- /dev/null +++ b/moon-abe/pbc-0.5.14/benchmark/multipairing.c @@ -0,0 +1,62 @@ +// Compares dedicated multipairing (product of pairings) routine with naive +// method. +#include <pbc.h> +#include "pbc_test.h" + +int main(int argc, char **argv) { + enum { K = 5 }; + pairing_t pairing; + element_t x[K], y[K], r, r2, tmp; + int i, n; + double t0, t1, ttotal, ttotalm; + + pbc_demo_pairing_init(pairing, argc, argv); + + for(i = 0; i < K; i++) { + element_init_G1(x[i], pairing); + element_init_G2(y[i], pairing); + } + element_init_GT(r, pairing); + element_init_GT(r2, pairing); + element_init_GT(tmp, pairing); + + n = 10; + ttotal = 0.0; + ttotalm = 0.0; + for (i=0; i<n; i++) { + int j; + for(j = 0; j < K; j++) { + element_random(x[j]); + element_random(y[j]); + } + + t0 = pbc_get_time(); + element_prod_pairing(r, x, y, K); + t1 = pbc_get_time(); + ttotalm += t1 - t0; + + t0 = pbc_get_time(); + element_pairing(r2, x[0], y[0]); + for(j = 1; j < K; j++) { + element_pairing(tmp, x[j], y[j]); + element_mul(r2, r2, tmp); + } + t1 = pbc_get_time(); + ttotal += t1 - t0; + + element_printf("e(x,y) = %B\n", r); + EXPECT(!element_cmp(r, r2)); + } + printf("average pairing time = %f\n", ttotal / n); + printf("average multi-pairing time = %f\n", ttotalm / n); + + for(i = 0; i < K; i++) { + element_clear(x[i]); + element_clear(y[i]); + } + element_clear(r); + element_clear(r2); + + pairing_clear(pairing); + return 0; +} diff --git a/moon-abe/pbc-0.5.14/benchmark/report_times b/moon-abe/pbc-0.5.14/benchmark/report_times new file mode 100644 index 00000000..d296efd4 --- /dev/null +++ b/moon-abe/pbc-0.5.14/benchmark/report_times @@ -0,0 +1,7 @@ +#!/bin/bash +#report pairing times for each type of parameter +for p in a d159 d201 d224 e f g149 a1 +do + echo -en $p'\t' + benchmark/benchmark < param/$p.param | awk '/time =/ {printf "%s", $5 "\t" } /prepro/ {print $6}' +done diff --git a/moon-abe/pbc-0.5.14/benchmark/timersa b/moon-abe/pbc-0.5.14/benchmark/timersa new file mode 100755 index 00000000..b4769a4a --- /dev/null +++ b/moon-abe/pbc-0.5.14/benchmark/timersa @@ -0,0 +1,228 @@ +#! /bin/sh + +# benchmark/timersa - temporary wrapper script for .libs/timersa +# Generated by libtool (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1 +# +# The benchmark/timersa program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +sed_quote_subst='s/\([`"$\\]\)/\\\1/g' + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac +fi +BIN_SH=xpg4; export BIN_SH # for Tru64 +DUALCASE=1; export DUALCASE # for MKS sh + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +relink_command="(cd /home/wukong/Dropbox/04_Workspace/opnfv-moon/moon-abe/pbc-0.5.14; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=/sbin:/usr/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin; export PATH; gcc -Wall -W -Wfloat-equal -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wredundant-decls -Wendif-labels -Wshadow -pipe -ffast-math -U__STRICT_ANSI__ -std=gnu99 -fomit-frame-pointer -O3 -o \$progdir/\$file benchmark_timersa-timersa.o ./.libs/libpbc.so -lgmp -lm -Wl,-rpath -Wl,/home/wukong/Dropbox/04_Workspace/opnfv-moon/moon-abe/pbc-0.5.14/.libs)" + +# This environment variable determines our operation mode. +if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then + # install mode needs the following variables: + generated_by_libtool_version='2.4.2' + notinst_deplibs=' libpbc.la' +else + # When we are sourced in execute mode, $file and $ECHO are already set. + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + file="$0" + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +$1 +_LTECHO_EOF' +} + ECHO="printf %s\\n" + fi + +# Very basic option parsing. These options are (a) specific to +# the libtool wrapper, (b) are identical between the wrapper +# /script/ and the wrapper /executable/ which is used only on +# windows platforms, and (c) all begin with the string --lt- +# (application programs are unlikely to have options which match +# this pattern). +# +# There are only two supported options: --lt-debug and +# --lt-dump-script. There is, deliberately, no --lt-help. +# +# The first argument to this parsing function should be the +# script's ./libtool value, followed by no. +lt_option_debug= +func_parse_lt_options () +{ + lt_script_arg0=$0 + shift + for lt_opt + do + case "$lt_opt" in + --lt-debug) lt_option_debug=1 ;; + --lt-dump-script) + lt_dump_D=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%/[^/]*$%%'` + test "X$lt_dump_D" = "X$lt_script_arg0" && lt_dump_D=. + lt_dump_F=`$ECHO "X$lt_script_arg0" | /bin/sed -e 's/^X//' -e 's%^.*/%%'` + cat "$lt_dump_D/$lt_dump_F" + exit 0 + ;; + --lt-*) + $ECHO "Unrecognized --lt- option: '$lt_opt'" 1>&2 + exit 1 + ;; + esac + done + + # Print the debug banner immediately: + if test -n "$lt_option_debug"; then + echo "timersa:benchmark/timersa:${LINENO}: libtool wrapper (GNU libtool) 2.4.2 Debian-2.4.2-1ubuntu1" 1>&2 + fi +} + +# Used when --lt-debug. Prints its arguments to stdout +# (redirection is the responsibility of the caller) +func_lt_dump_args () +{ + lt_dump_args_N=1; + for lt_arg + do + $ECHO "timersa:benchmark/timersa:${LINENO}: newargv[$lt_dump_args_N]: $lt_arg" + lt_dump_args_N=`expr $lt_dump_args_N + 1` + done +} + +# Core function for launching the target application +func_exec_program_core () +{ + + if test -n "$lt_option_debug"; then + $ECHO "timersa:benchmark/timersa:${LINENO}: newargv[0]: $progdir/$program" 1>&2 + func_lt_dump_args ${1+"$@"} 1>&2 + fi + exec "$progdir/$program" ${1+"$@"} + + $ECHO "$0: cannot exec $program $*" 1>&2 + exit 1 +} + +# A function to encapsulate launching the target application +# Strips options in the --lt-* namespace from $@ and +# launches target application with the remaining arguments. +func_exec_program () +{ + case " $* " in + *\ --lt-*) + for lt_wr_arg + do + case $lt_wr_arg in + --lt-*) ;; + *) set x "$@" "$lt_wr_arg"; shift;; + esac + shift + done ;; + esac + func_exec_program_core ${1+"$@"} +} + + # Parse options + func_parse_lt_options "$0" ${1+"$@"} + + # Find the directory that this script lives in. + thisdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` + test "x$thisdir" = "x$file" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=`ls -ld "$file" | /bin/sed -n 's/.*-> //p'` + while test -n "$file"; do + destdir=`$ECHO "$file" | /bin/sed 's%/[^/]*$%%'` + + # If there was a directory component, then change thisdir. + if test "x$destdir" != "x$file"; then + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir="$destdir" ;; + *) thisdir="$thisdir/$destdir" ;; + esac + fi + + file=`$ECHO "$file" | /bin/sed 's%^.*/%%'` + file=`ls -ld "$thisdir/$file" | /bin/sed -n 's/.*-> //p'` + done + + # Usually 'no', except on cygwin/mingw when embedded into + # the cwrapper. + WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=no + if test "$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR" = "yes"; then + # special case for '.' + if test "$thisdir" = "."; then + thisdir=`pwd` + fi + # remove .libs from thisdir + case "$thisdir" in + *[\\/].libs ) thisdir=`$ECHO "$thisdir" | /bin/sed 's%[\\/][^\\/]*$%%'` ;; + .libs ) thisdir=. ;; + esac + fi + + # Try to get the absolute directory name. + absdir=`cd "$thisdir" && pwd` + test -n "$absdir" && thisdir="$absdir" + + program=lt-'timersa' + progdir="$thisdir/.libs" + + if test ! -f "$progdir/$program" || + { file=`ls -1dt "$progdir/$program" "$progdir/../$program" 2>/dev/null | /bin/sed 1q`; \ + test "X$file" != "X$progdir/$program"; }; then + + file="$$-$program" + + if test ! -d "$progdir"; then + mkdir "$progdir" + else + rm -f "$progdir/$file" + fi + + # relink executable if necessary + if test -n "$relink_command"; then + if relink_command_output=`eval $relink_command 2>&1`; then : + else + printf %s\n "$relink_command_output" >&2 + rm -f "$progdir/$file" + exit 1 + fi + fi + + mv -f "$progdir/$file" "$progdir/$program" 2>/dev/null || + { rm -f "$progdir/$program"; + mv -f "$progdir/$file" "$progdir/$program"; } + rm -f "$progdir/$file" + fi + + if test -f "$progdir/$program"; then + if test "$libtool_execute_magic" != "%%%MAGIC variable%%%"; then + # Run the actual program with our arguments. + func_exec_program ${1+"$@"} + fi + else + # The program doesn't exist. + $ECHO "$0: error: \`$progdir/$program' does not exist" 1>&2 + $ECHO "This script is just a wrapper for $program." 1>&2 + $ECHO "See the libtool documentation for more information." 1>&2 + exit 1 + fi +fi diff --git a/moon-abe/pbc-0.5.14/benchmark/timersa.c b/moon-abe/pbc-0.5.14/benchmark/timersa.c new file mode 100644 index 00000000..53a64cfb --- /dev/null +++ b/moon-abe/pbc-0.5.14/benchmark/timersa.c @@ -0,0 +1,83 @@ +#include <pbc.h> +#include "pbc_fp.h" +#include "pbc_test.h" + +int main(void) { + mpz_t p, q, N, d; + mpz_t dmp1, dmq1; + mpz_t ipmq, iqmp; + mpz_t adq, adp; + + field_t f; + element_t a, b; + double t0, t1, tnaive = 0, tcrt=0; + int i, n; + + mpz_init(p); + mpz_init(q); + mpz_init(N); + mpz_init(d); + mpz_init(dmp1); + mpz_init(dmq1); + mpz_init(ipmq); + mpz_init(iqmp); + mpz_init(adp); + mpz_init(adq); + pbc_mpz_randomb(p, 512); + pbc_mpz_randomb(q, 512); + mpz_nextprime(p, p); + mpz_nextprime(q, q); + mpz_mul(N, p, q); + mpz_invert(ipmq, p, q); + mpz_invert(iqmp, q, p); + + field_init_fp(f, N); + element_init(a, f); + element_init(b, f); + n = 10; + for (i=0; i<n; i++) { + pbc_mpz_random(d, N); + element_random(a); + t0 = pbc_get_time(); + element_pow_mpz(b, a, d); + t1 = pbc_get_time(); + tnaive += t1 - t0; + + mpz_sub_ui(p, p, 1); + mpz_sub_ui(q, q, 1); + + mpz_mod(dmp1, d, p); + mpz_mod(dmq1, d, q); + + mpz_add_ui(p, p, 1); + mpz_add_ui(q, q, 1); + + element_to_mpz(adq, a); + element_to_mpz(adp, a); + + t0 = pbc_get_time(); + mpz_powm(adp, adp, d, p); + mpz_powm(adq, adq, d, q); + + /* textbook CRT + mpz_mul(adp, adp, q); + mpz_mul(adp, adp, iqmp); + mpz_mul(adq, adq, p); + mpz_mul(adq, adq, ipmq); + mpz_add(adp, adp, adq); + */ + // Garner's algorithm + mpz_sub(adq, adq, adp); + mpz_mul(adq, adq, ipmq); + mpz_mod(adq, adq, q); + mpz_mul(adq, adq, p); + mpz_add(adp, adp, adq); + + t1 = pbc_get_time(); + tcrt += t1 - t0; + element_set_mpz(b, adp); + } + printf("average RSA exp time = %lf\n", tnaive / n); + printf("average RSA exp time (CRT) = %lf\n", tcrt / n); + return 0; +} |