
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import java.security.*;
import java.security.spec.RSAPrivateKeySpec;
import java.math.BigInteger;
import java.util.Calendar;
import java.util.StringTokenizer;

/**
 * Created by IntelliJ IDEA.
 * User: Johnson Gong
 * Date: 2006-3-8
 * Time: 16:13:15
 * To change this template use File | Settings | File Templates.
 */
public class Blah {
    public static void main(String args[]){
        try{


            //Here we generate public and private keys for redactive signatures
            Message message = new Message("Alice", "Bob", "You owe me ten thousand dollars", Calendar.getInstance());
            SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
            BigInteger p = BigInteger.probablePrime(512, sr);
            System.out.println("p=" + p.toString(16)) ;
            BigInteger q = BigInteger.probablePrime(512, sr);
            System.out.println("q=" + q.toString(16));
            BigInteger N = p.multiply(q);
            System.out.println("N=" + N.toString(16));
            sr = SecureRandom.getInstance("SHA1PRNG");

            //Here we specify a as a 64 bytes number
            //byte[] rawA = new byte[64];
            //sr.nextBytes(rawA);
            BigInteger a = BigInteger.probablePrime(512,sr);
            System.out.println("a=" + a.toString(16));


            SignedObject_RD sord = new SignedObject_RD(message,p,q,a);

            System.out.println(sord.verify(N,a));

            //RSAPrivateKeySpec bla = new RSAPrivateKeySpec

        }
        catch(Exception e){
            e.printStackTrace();
        }
    }
}
