//   Course Number: COSC 645 Applied Cryptography
//      Class Name: ShamirMessage           
//         Authors: Brian Hoffman
//                  Derek Waby
//                  Kypros Ioannou
//                  Harsha V. Reddy
//    Description: This class implements the serializable interfaces and is 
//                 used to encapsulate all the information passed between the
//                 client and server. A Shamir message constis of a string 
//                 type field that indicates the purpose of the message and
//                 three BigIntegerFields that are used to hold information 
//                 about a single secret share. However, in some cases, these
//                 fields may contain no information or numerial data depending 
//                 on the type field. For a summary of message types, see below.


// Listing of Message Types
// TYPE             Purpose
//
// terminate        Sent by the client to terminate connection
// requestShare     Sent by client to ask for a single share 
// requestDeny      Sent by server to indicate that it refuses to send a share
// share            Sent by client or server to communicate a share
// invalidShare     Sent by server to indicate a faulty share sent by client
// key              Sent by server to indicate successful recovery. Puts key in 
//                  X field
// numRemain        Sent by server to indicate the mumber of shares that remain 
//                  to complete key. Stores value in x field

// Java Core Packages
import java.io.*;
import java.net.*;
import java.math.BigInteger;

public class ShamirMsg implements Serializable
{ 
    private String type;
    private BigInteger x;
    private BigInteger y;
    private BigInteger prime;
    
    // ------------------------------------------------------------------------
    // default constructor
    //------------------------------------------------------------------------- 
    public ShamirMsg()
    {
        type = "";
        x = BigInteger.ONE;
        y = BigInteger.ONE;
        prime = BigInteger.ONE;
    }
    
    // ------------------------------------------------------------------------
    // constructor - type only 
    //------------------------------------------------------------------------- 
    public ShamirMsg(String t)
    {
        type = t;
        x = BigInteger.ONE;
        y = BigInteger.ONE;
        prime = BigInteger.ONE;
    }

    // ------------------------------------------------------------------------
    // constructor - full share
    //------------------------------------------------------------------------- 
    public ShamirMsg(String t, BigInteger inX, BigInteger inY, BigInteger p)
    {
        type = t;
        x = inX;
        y = inY;
        prime = p;
    }
    
    // ------------------------------------------------------------------------
    // get functions 
    //------------------------------------------------------------------------- 
    public String getType() { return type; }
    public BigInteger getX() { return x; }
    public BigInteger getY() { return y; }
    public BigInteger getPrime() { return prime; }
    
    // ------------------------------------------------------------------------
    // set functions 
    //------------------------------------------------------------------------- 
    public void setType(String t) { type = t; }
    public void setX(BigInteger inX) { x = inX; }
    public void setY(BigInteger inY) { y = inY; }
    public void setPrime(BigInteger p) { prime = p;}
}