ds.ov2.bignat
Class Convenience

java.lang.Object
  extended by ds.ov2.bignat.Convenience

public class Convenience
extends Object

BigInteger convenience interface to selected Bignat methods.

For a number of general topics see also the package description.

CPP Preprocessing
no cpp preprocessing needed
Execution Environment:
host
Author:
Hendrik Tews
Version:
$Revision: 1.5 $
Last Commit:
$Date: 2009-02-26 12:23:51 $ by $Author: tews $

Nested Class Summary
static class Convenience.Timed_result
          BigInteger, long tuple for methods that produce such results.
 
Constructor Summary
private Convenience()
          Static class, object creation disabled.
 
Method Summary
static BigInteger bi_from_bn(Bignat bn)
          Convert Bignat into BigInteger.
static Bignat bn_from_bi(int bignat_size, BigInteger bi)
          Convert BigInteger into Bignat.
static Convenience.Timed_result exponent_mod(BigInteger base, BigInteger exponent, BigInteger modulus)
          Convenience interface to Bignat.exponent_mod.
static Convenience.Timed_result vector_exponent_mod(BigInteger[] bases, BigInteger[] exponents, BigInteger modulus)
          Convenience interface to Vector.exponent_mod.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Convenience

private Convenience()
Static class, object creation disabled.

Method Detail

bn_from_bi

public static Bignat bn_from_bi(int bignat_size,
                                BigInteger bi)
                         throws IllegalArgumentException
Convert BigInteger into Bignat. Converts BigInteger bi into a Bignat of size bignat_size, which, of course must be large enough. The BigInteger must be positive or zero, the result is arbitrary.

Parameters:
bignat_size - size of the returned Bignat
bi - source BigInteger
Returns:
a Bignat of the same value
Throws:
IllegalArgumentException - if bignat_size is not a non-zero positive short or if bi does not fit into bignat_size bytes.

bi_from_bn

public static BigInteger bi_from_bn(Bignat bn)
Convert Bignat into BigInteger.

Parameters:
bn - Bignat to convert
Returns:
a BigInteger of the same value

exponent_mod

public static Convenience.Timed_result exponent_mod(BigInteger base,
                                                    BigInteger exponent,
                                                    BigInteger modulus)
                                             throws IllegalArgumentException
Convenience interface to Bignat.exponent_mod. Computes base^exponent (modulo modulus) using Bignat.exponent_mod and returns the result as BigInteger together with the running time of Bignat.exponent_mod.

The sizes for the Bignats are computed internally.

Montgomerization and preparation of the modulus are done with the BigInteger class. Preparation and postprocessing is not contained in the measured time.

Parameters:
base -
exponent -
modulus -
Returns:
base^exponent (modulo modulus) together with the duration of Bignat.exponent_mod in nanoseconds.
Throws:
IllegalArgumentException - if the modulus is even or either base or exponent are longer than Short.MAX_VALUE bytes.

vector_exponent_mod

public static Convenience.Timed_result vector_exponent_mod(BigInteger[] bases,
                                                           BigInteger[] exponents,
                                                           BigInteger modulus)
                                                    throws IllegalArgumentException
Convenience interface to Vector.exponent_mod. Computes bases[0]^exponents[0] * ... * bases[n]^exponents[n] (modulo modulus) using Vector.exponent_mod and returns the result as BigInteger together with the running time of Vector.exponent_mod.

The sizes for the Bignats are computed internally. There are no size constraints on the base and exponent arguments.

Montgomerization and preparation of the modulus are done with the BigInteger class. Preparation and postprocessing is not contained in the measured time.

Parameters:
bases - array of the bases
exponents - array of the exponents
modulus -
Returns:
bases[0]^exponents[0] * ... * bases[n]^exponents[n] (modulo modulus) together with the duration in nonoseconds
Throws:
IllegalArgumentException - if the modulus is even, if bases and exponents have different length, and if either bases or exponents are longer than Short.MAX_VALUE bytes.