cryptix.math
Class BigInteger

java.lang.Object
  extended bycryptix.math.BigNum
      extended bycryptix.math.BigInteger
All Implemented Interfaces:
java.lang.Cloneable

public class BigInteger
extends BigNum

A class implementing arbitrary-length integers. java.math.BigInteger is preferred for new code.

Copyright © 1995-1997 Systemics Ltd on behalf of the Cryptix Development Team.
All rights reserved.

$Revision: 1.5 $

Since:
Cryptix 2.2
Author:
unattributed

Field Summary
static BigInteger one
           
static BigInteger zero
           
 
Fields inherited from class cryptix.math.BigNum
BITS, LBITS, LMASK, LRADIX, MASK, RADIX
 
Constructor Summary
BigInteger()
           
BigInteger(BigInteger from)
           
BigInteger(byte[] buffer)
           
BigInteger(int from)
           
BigInteger(java.lang.String hexString)
           
 
Method Summary
 BigInteger add(BigInteger a, BigInteger b)
           
 BigInteger add(int a)
           
 BigInteger assign(BigInteger n)
           
 BigInteger assign(int n)
           
 int bitLength()
           
 java.lang.Object clone()
           
 int cmp(BigInteger a)
           
 void copy(java.lang.Object src)
           
 BigInteger dec()
           
 BigInteger div(BigInteger a, BigInteger b)
           
 boolean equals(java.lang.Object o)
          Tests whether another object is equal to this one.
protected  void finalize()
           
 void fromByteArray(byte[] buf)
           
static BigInteger fromJavaMathBigInteger(java.math.BigInteger from)
          Convert from a java.math.BigInteger to a cryptix.math.BigInteger.
 void fromString(java.lang.String inHex)
           
 BigInteger gcd(BigNum a, BigNum b)
           
 BigInteger inc()
           
 BigInteger inverseModN(BigInteger a, BigInteger n)
           
static void main(java.lang.String[] args)
           
 BigInteger mod(BigInteger a, BigInteger b)
           
 BigInteger modExp(BigInteger power, BigInteger modulo)
           
 BigInteger mul(BigInteger a, BigInteger b)
           
protected static byte[] newBuffer(int bitLen)
          An internal function to create a buffer big enough in which to store a number.
static void self_test(java.io.PrintWriter out)
           
 BigInteger shiftLeft(int n)
           
 BigInteger shiftRight(int n)
           
 BigInteger sub(BigInteger a, BigInteger b)
           
 byte[] toByteArray()
          Convert a number into a byte array.
 java.math.BigInteger toJavaMathBigInteger()
          Convert this cryptix.math.BigInteger to a java.math.BigInteger.
 java.lang.String toString()
           
static BigInteger zero()
           
 
Methods inherited from class cryptix.math.BigNum
add_unsigned, add_unsigned, add, add, assign, bignum_hashCode, bit, bitLength, byteLength, check_state, cmp, copy, dec, display, display, div, div, euclid, even, extended_euclid, fromBinary, gcd, grow, inc, intoBinary, inverseModN, isOne, isZero, mod, modExp, modMul, modMulRecip, mul, odd, one, recip, shiftLeft, shiftLeft, shiftLeftOnce, shiftRight, shiftRight, shiftRightOnce, sub_unsigned, sub_unsigned, sub, sub, ucmp, zero
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

zero

public static final BigInteger zero

one

public static final BigInteger one
Constructor Detail

BigInteger

public BigInteger()

BigInteger

public BigInteger(int from)

BigInteger

public BigInteger(BigInteger from)

BigInteger

public BigInteger(java.lang.String hexString)

BigInteger

public BigInteger(byte[] buffer)
Method Detail

bitLength

public int bitLength()

clone

public java.lang.Object clone()
Overrides:
clone in class BigNum

copy

public void copy(java.lang.Object src)
Overrides:
copy in class BigNum

assign

public BigInteger assign(BigInteger n)

assign

public BigInteger assign(int n)

fromString

public void fromString(java.lang.String inHex)

toString

public java.lang.String toString()

finalize

protected void finalize()
Overrides:
finalize in class BigNum

modExp

public BigInteger modExp(BigInteger power,
                         BigInteger modulo)

inverseModN

public BigInteger inverseModN(BigInteger a,
                              BigInteger n)

mod

public BigInteger mod(BigInteger a,
                      BigInteger b)

mul

public BigInteger mul(BigInteger a,
                      BigInteger b)

div

public BigInteger div(BigInteger a,
                      BigInteger b)

add

public BigInteger add(BigInteger a,
                      BigInteger b)

add

public BigInteger add(int a)

sub

public BigInteger sub(BigInteger a,
                      BigInteger b)

gcd

public BigInteger gcd(BigNum a,
                      BigNum b)

cmp

public int cmp(BigInteger a)

equals

public boolean equals(java.lang.Object o)
Tests whether another object is equal to this one.

Note: since BigIntegers are mutable, it was a mistake to override equals. Also, equals and hashCode should always be overridden together.

Returns:
true if the object is equal, otherwise false.

inc

public BigInteger inc()

dec

public BigInteger dec()

shiftLeft

public BigInteger shiftLeft(int n)

shiftRight

public BigInteger shiftRight(int n)

zero

public static BigInteger zero()

newBuffer

protected static byte[] newBuffer(int bitLen)
An internal function to create a buffer big enough in which to store a number.

Parameters:
bitLen - The number of bits in the number.
Returns:
a buffer in which to store a number.

toByteArray

public byte[] toByteArray()
Convert a number into a byte array.

Returns:
a byte array.

fromByteArray

public void fromByteArray(byte[] buf)

toJavaMathBigInteger

public java.math.BigInteger toJavaMathBigInteger()
Convert this cryptix.math.BigInteger to a java.math.BigInteger.

Returns:
the java.math.BigInteger

fromJavaMathBigInteger

public static BigInteger fromJavaMathBigInteger(java.math.BigInteger from)
Convert from a java.math.BigInteger to a cryptix.math.BigInteger.

Parameters:
from - the java.math.BigInteger
Returns:
the cryptix.math.BigInteger

main

public static void main(java.lang.String[] args)

self_test

public static void self_test(java.io.PrintWriter out)
                      throws java.lang.Exception
Throws:
java.lang.Exception