|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectds.ov2.test.Exponent_perf_host
public class Exponent_perf_host
Correctness check and performance measurement for all
multi-exponent variants in Vector
.
Nested Class Summary | |
---|---|
private class |
Exponent_perf_host.Exp_call_result
Result record of the Vector_exp protocol. |
static class |
Exponent_perf_host.Vector_exponent_variant
Enumeration for the different multi-power implementations. |
Field Summary | |
---|---|
private CardChannel |
card_channel
Channel to the applet. |
private Misc_protocols_host |
misc_host
Misc protocols instance for the resize protocol. |
private PrintWriter |
out
Debug and progress channel. |
private Exponent_perf_stubs |
stubs
Stubs for the Vector_exp protocol. |
private Test_protocols |
test_protocols
Protocol array instance to set the result sizes after changing the vector length. |
Constructor Summary | |
---|---|
Exponent_perf_host(Test_protocols test_protocols,
CardChannel card_channel)
Constructor. |
Method Summary | |
---|---|
Exponent_perf_host.Exp_call_result |
card_vector_exp(Host_vector base,
Host_vector exponent,
Host_modulus modulus,
int base_factor_size,
Host_vector base_factors,
BigInteger one_or_correction,
Exponent_perf_host.Vector_exponent_variant variant,
boolean keep_modulus)
Run the complete vector exponent protocol. |
private void |
change_vector_length(int new_length,
int new_factors_length)
Run the Vector_length protocol to resize base, exponents and base factors vectors. |
void |
run_vector_exp_check(Exponent_perf_host.Vector_exponent_variant variant)
Exception wrapper for vector_exp_check . |
void |
run_vector_exp_perf(Exponent_perf_host.Vector_exponent_variant variant)
Exception wrapper for vector_exp_measure . |
void |
vector_exp_check(Exponent_perf_host.Vector_exponent_variant variant)
Check State.rounds rounds the multi-power computation
on the card. |
void |
vector_exp_measure_size(BigInteger mod,
Random rand,
int short_bit_size,
int short_byte_size,
int effective_byte_size,
int long_byte_size,
int pre_computed_factors,
Exponent_perf_host.Vector_exponent_variant variant,
boolean keep_modulus)
Measure one round of multi-power and print the timings in gnuplot friendly way. |
void |
vector_exp_measure(Exponent_perf_host.Vector_exponent_variant variant)
Measure multi-power with increasing number sizes. |
Exponent_perf_host.Exp_call_result |
vector_exp_once(BigInteger mod,
Random rand,
int short_bit_size,
int short_byte_size,
int effective_byte_size,
int long_byte_size,
int pre_computed_factors,
Exponent_perf_host.Vector_exponent_variant variant,
boolean keep_modulus)
Generate input data, run the vector exponent protocol once and check the result. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Test_protocols test_protocols
private PrintWriter out
private Misc_protocols_host misc_host
private Exponent_perf_stubs stubs
private CardChannel card_channel
Constructor Detail |
---|
public Exponent_perf_host(Test_protocols test_protocols, CardChannel card_channel)
test_protocols
- protocol array instancecard_channel
- channel to the appletMethod Detail |
---|
private void change_vector_length(int new_length, int new_factors_length) throws CardException
new_length
- new length for bases and exponentsnew_factors_length
- number of factors the factor array
gets, the real array size will then be 2^new_factors_length -1
CardException
- for communication errorspublic Exponent_perf_host.Exp_call_result card_vector_exp(Host_vector base, Host_vector exponent, Host_modulus modulus, int base_factor_size, Host_vector base_factors, BigInteger one_or_correction, Exponent_perf_host.Vector_exponent_variant variant, boolean keep_modulus) throws CardException
base[0]^exponent[0] * base[1]^exponent[1] * ... mod modulus
on
the card and returns the result and the performance timings.
Depending on the implementation selected with variant
,
different extra data is necessary.
To reduce card communication errors the method performs a garbage collection and sleeps some time before each step. The sleep time is hardwired in the method (currently 400 milliseconds).
base
- base vector, Montgomerized for Exponent_perf_host.Vector_exponent_variant.PURE_JAVA
,
normal otherwiseexponent
- exponent vector, always normalmodulus
- modulusbase_factor_size
- only necessary for the Exponent_perf_host.Vector_exponent_variant.PURE_JAVA
variant: number of factors
whose products are precomputed in base_factors
base_factors
- array of all possible products of the first
base_factor_size
bases, see Vector.exponent_mod
; Only
needed for Exponent_perf_host.Vector_exponent_variant.PURE_JAVA
, must
otherwise contain at least one (arbitrary) element, because the
protocol layer does not support empty objectsone_or_correction
- for Exponent_perf_host.Vector_exponent_variant.PURE_JAVA
montgomerized 1, for Exponent_perf_host.Vector_exponent_variant.MONT_RSA
Montgomery correction factor,
not used for Exponent_perf_host.Vector_exponent_variant.SQUARED_RSA
variant
- chosen implementation variantkeep_modulus
- whether the modulus is the same as in the
last test and should thus not be installed
CardException
- on communiction errorspublic Exponent_perf_host.Exp_call_result vector_exp_once(BigInteger mod, Random rand, int short_bit_size, int short_byte_size, int effective_byte_size, int long_byte_size, int pre_computed_factors, Exponent_perf_host.Vector_exponent_variant variant, boolean keep_modulus) throws CardException
variant
. For the RSA
variants, where changing the modulus costs some time, the same
modulus (passed as mod
argument) can be used for a
number of successive test.
mod
- modulus if non-null, if null generate modulus randomlyrand
- randomness sourceshort_bit_size
- exponent size in bitsshort_byte_size
- exponent size in byteseffective_byte_size
- base size in bytes, excluding the
Montgomery digits for those variants that use themlong_byte_size
- base size in bytes, including the
Montgomery digits for those variants that use thempre_computed_factors
- number of bases for which their
products are precomputed on the host side; must be at least 1,
even for the RSA variants that do not use precomputed productsvariant
- the muli-power implementation to use on the card
CardException
- on communication errorspublic void vector_exp_check(Exponent_perf_host.Vector_exponent_variant variant) throws CardException
State.rounds
rounds the multi-power computation
on the card. On any error the program is terminated and the
involved numbers are printed.
variant
- multi-power implementation to use on the card
CardException
- on communication errorspublic void vector_exp_measure_size(BigInteger mod, Random rand, int short_bit_size, int short_byte_size, int effective_byte_size, int long_byte_size, int pre_computed_factors, Exponent_perf_host.Vector_exponent_variant variant, boolean keep_modulus) throws CardException
vector_exp_once
. Terminate
the program if the card result is wrong. The multi-power method
to be used on the card is determined by the argument variant
. For the RSA variants, where changing the modulus
costs some time, the same modulus (passed as mod
argument) can be used for a number of successive test.
mod
- modulus if non-null, if null generate modulus randomlyrand
- randomness sourceshort_bit_size
- exponent size in bitsshort_byte_size
- exponent size in byteseffective_byte_size
- base size in bytes, excluding the
Montgomery digits for those variants that use themlong_byte_size
- base size in bytes, including the
Montgomery digits for those variants that use thempre_computed_factors
- number of bases for which their
products are precomputed on the host side; must be at least 1,
even for the RSA variants that do not use precomputed productsvariant
- the muli-power implementation to use on the cardkeep_modulus
- whether the modulus is the same as in the
last test and should thus not be installed
CardException
- on communication errorspublic void vector_exp_measure(Exponent_perf_host.Vector_exponent_variant variant) throws CardException
State.rounds
measurements for each size between State.start_size
and State.long_bignat_max_size
. If
State.start_size
has not been set, a very small start
size is used. Each size is measured and printed with vector_exp_measure_size
. The program
is terminated if the card computes anything wrong. If State.keep_modulus
is set, the same modulus is used for all
measurements of one size.
variant
- the multi-power variant to measure
CardException
- on communication errorspublic void run_vector_exp_check(Exponent_perf_host.Vector_exponent_variant variant)
vector_exp_check
. Checks the given multi-power method and
prints traces for all escaping exceptions. If one check fails
the program is immediately terminated.
variant
- the multi-power variant to checkpublic void run_vector_exp_perf(Exponent_perf_host.Vector_exponent_variant variant)
vector_exp_measure
. Measures the given multi-power
implementation over a range of sizes and prints traces for
escaping exceptions. If one computation on the card yields a
wrong result, the program is terminated.
variant
- the multi-power variant to measure
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |