demo
Class Client

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--demo.Client
All Implemented Interfaces:
java.lang.Runnable

public class Client
extends java.lang.Thread

The client class is a thread that sports a JFrame window. The purpose of the thread is to act like an independent client, without actually being a truly independent client. The "dealer" remains in control of each client, but only communicates with each client by creating the same kinds of messages that would be used by networked clients.

The only JFrame component is the ClientDisplay class, an extension of JPanel. All GUI changes are made via the ClientDisplay class. There is also a hook for the one button, "corrupt", in the display to the share.corrupt() method.

Version:
.4
Author:
Brice Daniels

Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Client(int numBits, int shareNumber, java.security.PrivateKey privateKey, java.security.PublicKey[] publicKeys)
          Creates a new instance of Client
 
Method Summary
protected  void corruptShare()
          Instructs the client to corrupt its share.
protected  byte[] genMessage(java.util.LinkedList data)
          Takes the data for the message as a LinkedList and turns it into a byte array along with a digital signature for the data bytes.
protected  byte[] genRecoverSecretMessage(int recovererShareNumber)
          This method is used by clients to generate a message for the recoverer.
protected  java.lang.String getCommitment()
          Gets the commitment value as a string for display on the client window.
protected  RSACryptoManager getCryptoManager()
          Returns a reference to the client's RSACryptoManager.
protected  java.lang.String getOriginalCommitment()
          Gets the original commitment value as a string for display on the client window.
protected  java.lang.String getOriginalSecret()
          Gets the original secret as a string for display on the client window.
protected  int getRound()
          The current round number.
protected  java.lang.String getSecret()
          Gets the secret as a string for display on the client window.
 int getShareNumber()
          Returns the share number of the current client.
protected  void incrementRound()
          Increments the current round number for this share.
protected  java.util.LinkedList processMessage(byte[] message, int senderShareNumber)
          Performs the opposite operation as genMessage().
protected  void receiveShare(byte[] input, int senderShareNumber)
          This method is used by the dealer to initially give the client its share.
protected  java.math.BigInteger recoverSecret(byte[][] messages)
          The method called by the recoverer to recover the secret from the data contained in the array of messages.
protected  void recoverShare(byte[][] messages)
          The second of two methods used by invalid clients in share recovery.
protected  byte[] recoverShareFinal(byte[][] messages)
          The second of two methods used by valid shares in share recovery.
protected  byte[][] recoverShareInit(int recoverShareNumber)
          Performs the first of two steps for share recovery for valid shares.
protected  void recoverShareListen(byte[][] messages)
          The first of two methods used by invalid clients in share recovery.
protected  void renewalFinal(byte[][] messages)
          The second of two methods used for share renewal.
protected  byte[][] renewalInit()
          The first of two functions involved in share renewal.
 void run()
          Overrides the run method of class Thread.
protected  boolean validate()
          Validate the client's share.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Client

public Client(int numBits,
              int shareNumber,
              java.security.PrivateKey privateKey,
              java.security.PublicKey[] publicKeys)
Creates a new instance of Client

Parameters:
numBits - The minimum number of bits in the BigInteger.
shareNumber - The share number of the current client.
privateKey - The RSA private key for the current client.
publicKeys - The array of RSA public keys for all of the clients.
Method Detail

getCryptoManager

protected RSACryptoManager getCryptoManager()

Returns a reference to the client's RSACryptoManager.

Returns:
The RSACryptoManager for the current client.

getShareNumber

public int getShareNumber()

Returns the share number of the current client. As it is public information, this is available outside of the package.

Returns:
The share number as an int.

getRound

protected int getRound()

The current round number. This is needed by the dealer and a few other methods. The round number is maintained by the client and is not part of the secret share.

Returns:
The round number as an int.

incrementRound

protected void incrementRound()

Increments the current round number for this share.


run

public void run()

Overrides the run method of class Thread. It starts up the GUI component of the client.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

receiveShare

protected void receiveShare(byte[] input,
                            int senderShareNumber)
                     throws ClientException

This method is used by the dealer to initially give the client its share. The share is in a "message" for and includes a signature.

The first task of the client is to verify the signature and then decrypt the secret share and commitment values.

Provided all goes well with the verification and the decryption, the share is added to the client.

Parameters:
input - A byte encoded version of the message from the dealer.
senderShareNumber - The share number of the dealer.
Throws:
ClientException - Indication of an error processing the message.

corruptShare

protected void corruptShare()
                     throws ClientException

Instructs the client to corrupt its share.

Throws:
ClientException - Indication of an error corrupting the client.

getSecret

protected java.lang.String getSecret()

Gets the secret as a string for display on the client window.

Returns:
A string with the secret or zero if the secret is null.

getCommitment

protected java.lang.String getCommitment()

Gets the commitment value as a string for display on the client window.

Returns:
A string with the commitment value or zero if the commitment value is null.

getOriginalSecret

protected java.lang.String getOriginalSecret()

Gets the original secret as a string for display on the client window.

Returns:
A string with original secret or zero if the original secret is null.

getOriginalCommitment

protected java.lang.String getOriginalCommitment()

Gets the original commitment value as a string for display on the client window.

Returns:
A string with the original commitment value or zero if the original commitment value is null.

genMessage

protected byte[] genMessage(java.util.LinkedList data)
                     throws ClientException

Takes the data for the message as a LinkedList and turns it into a byte array along with a digital signature for the data bytes.

Parameters:
data - A LinkedList containing all of the data for the message.
Returns:
A byte array with the serialized data and a digital signature.
Throws:
ClientException - Indication of an error creating the message.

processMessage

protected java.util.LinkedList processMessage(byte[] message,
                                              int senderShareNumber)
                                       throws ClientException

Performs the opposite operation as genMessage(). It takes the byte array and the share number of the sender and verifies the digital signature and then returns the data as a LinkedList.

Parameters:
message - The serialized message created by genMessage()
senderShareNumber - The share number of the sender. Used to identify the proper public key to use.
Returns:
A LinkedList with the data from the message.
Throws:
ClientException - Indication of an error processing the message.

validate

protected boolean validate()

Validate the client's share.

Returns:
True if the client is valid.

recoverShareInit

protected byte[][] recoverShareInit(int recoverShareNumber)
                             throws ClientException

Performs the first of two steps for share recovery for valid shares.

This method creates a message that contains the subshares such that f(r) = g(r) = 0.

Parameters:
recoverShareNumber - The share number of client that you are trying to recover.
Returns:
An array of digitally signed messages, one for each client.
Throws:
ClientException - Indication of an error creating the message.

recoverShareFinal

protected byte[] recoverShareFinal(byte[][] messages)
                            throws ClientException

The second of two methods used by valid shares in share recovery. It creates shares of the bad share.

The function creates a message for the invalid share that contains the share of the invalid share.

Parameters:
messages - The messages from the other valid servers.
Returns:
A digitally signed message for the invalid client.
Throws:
ClientException - An indication of an error creating the message for the invalid client.

recoverShareListen

protected void recoverShareListen(byte[][] messages)
                           throws ClientException

The first of two methods used by invalid clients in share recovery.

This method looks at all of the messages from the valid clients and uses the commitment arrays to create public versions for the shares that it will receive later.

Parameters:
messages - The messages from the valid clients.
Throws:
ClientException - An indication of an error gathering the commitment array values.

recoverShare

protected void recoverShare(byte[][] messages)
                     throws ClientException

The second of two methods used by invalid clients in share recovery.

This method is used by the particular invalid client to recover its share from the shares given to it by the valid clients. It verifies those shares using the information that it collected in recoverShareListen().

Parameters:
messages - The messages from the valid clients containing the shares of this client's share.
Throws:
ClientException - An indication of an error recovering the share.

genRecoverSecretMessage

protected byte[] genRecoverSecretMessage(int recovererShareNumber)
                                  throws ClientException

This method is used by clients to generate a message for the recoverer. The message contains the secret share and commitment value held by this client.

Parameters:
recovererShareNumber - The share number of the recoverer.
Returns:
A digitally signed message for the recoverer.
Throws:
ClientException - An indication of an error creating the message.

recoverSecret

protected java.math.BigInteger recoverSecret(byte[][] messages)
                                      throws ClientException

The method called by the recoverer to recover the secret from the data contained in the array of messages.

Parameters:
messages - An array of messages from all clients containing their secret share and commitment value.
Returns:
The secret as a BigInteger.
Throws:
ClientException - An indication of an error recovering the secret.

renewalInit

protected byte[][] renewalInit()
                        throws ClientException

The first of two functions involved in share renewal. It creates a share of zero and then a message to each client with that client's share of zero.

Returns:
An array of digitally signed messages containing the renewal information.
Throws:
ClientException - An indication of an error creating the array of messages.

renewalFinal

protected void renewalFinal(byte[][] messages)
                     throws ClientException

The second of two methods used for share renewal. It takes all messages from the other clients and adds each share of zero to its own share.

Parameters:
messages - An array of digitally signed messages from the other shares for this client.
Throws:
ClientException - An indication of an error renewing the local share.