byte[] x = new byte[10];
byte[] y =new byte[10];
for (int i = 0; i < y.length; i++) {
x[i] = (byte)i;
y[i] = (byte)i;
}
BigInteger i = new BigInteger(x) ,t = new BigInteger(y);
BigInteger r = Constant.TWO.multiply( i ).multiply( t );
我这样写是没错的,编译通过的,但是我这样写的时候却挂掉Gordon g=new Gordon();构造函数如下 public Gordon() {
this( 10, 16, new Random(), Gordon.RANDOM_INT, Gordon.RANDOM_INT );
}
public Gordon( int bitLength, int certainty, Random rnd, BigInteger i,
BigInteger j ) {
if( bitLength <= 0 ) {
throw new IllegalArgumentException(
"bitLength must be greater than zero" );
}
if( certainty <= 0 ) {
throw new IllegalArgumentException(
"certainty must be greater than zero" );
}
if( rnd == null ) {
throw new NullPointerException( "rnd cannot be null" );
}
if( i == null ) {
throw new NullPointerException( "i cannot be null" );
}
if( i.compareTo( BigInteger.ZERO ) <= 0 ) {
throw new IllegalArgumentException( "i must be greater than zero" );
}
if( j == null ) {
throw new NullPointerException( "j cannot be null" );
}
if( j.compareTo( BigInteger.ZERO ) <= 0 ) {
throw new IllegalArgumentException( "j must be greater than zero" );
}
BigInteger s = new BigInteger( bitLength, certainty, rnd );
BigInteger t = new BigInteger( bitLength, certainty, rnd );
/**
* Select an integer i0. Find the first prime in the sequence 2it + 1,
* for i = i0, i0 + 1, i0 + 2,... Denote this prime by r = 2it + 1.
* 2(i0)t + 1 = 2it + 1
* 2(i0 + 1)t + 1 = 2it + 2t + 1
* 2(i0 + 2)t + 1 = 2it + 4t + 1 = 2it + 2t + 1 + 2t =
* 2(i0 + 1)t + 1 + 2t = previous result + 2t
*/
BigInteger r = Constant.TWO.multiply(i).multiply(t);
r = r.add( BigInteger.ONE );
while( !( r.isProbablePrime( 10 ) ) ) {
r = r.add( Constant.TWO.multiply( t ) );
} // Compute p0 = 2( s^(r - 2) mod r )s - 1
BigInteger p0 = s.modPow( r.subtract( Constant.TWO ), r );
p0 = p0.multiply( s.multiply( Constant.TWO ) );
p0 = p0.subtract( BigInteger.ONE ); /**
* Select an integer j0. Find the first prime in the sequence p0 + 2jrs,
* for j = j0, j0 + 1, j0 + 2,... Denote this prime by p = p0 + 2jrs.
* p0 + 2(j0)rs = p0 + 2jrs
* p0 + 2(j0 + 1)rs = p0 + 2jrs + 2rs
* p0 + 2(j0 + 2)rs = p0 + 2jrs + 4rs = p0 + 2jrs + 2rs + 2rs =
* previous step + 2rs
*/
BigInteger p = Constant.TWO.multiply( j ).multiply( r ).multiply( s );
p = p.add( p0 ); while( !( p.isProbablePrime( 10 ) ) ) {
p = p.add( Constant.TWO.multiply( r ).multiply( s ) );
}
set( p, r, s, t );
}错误代码是:
Exception in thread "main" java.lang.NoClassDefFoundError: nuim/cs/crypto/blitz/constants/Constant
at nuim.cs.crypto.primality.Gordon.<init>(Gordon.java:72)
at nuim.cs.crypto.primality.Gordon.<init>(Gordon.java:28)
at test.test2.main(test2.java:22)
Caused by: java.lang.ClassNotFoundException: nuim.cs.crypto.blitz.constants.Constant
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 3 more
这个目录下面找不到 那个class 的文件