package meerkat.crypto.dkg.feldman;

import meerkat.crypto.secretsharing.shamir.Polynomial;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * Created by Tzlil on 3/14/2016.
 *
 * contains all relevant information on specific party during
 * the run of Joint Feldamn protocol
 */
public class Party<T> {
    public final int id;
    public Polynomial.Point share;
    public ArrayList<T> commitments;
    public boolean doneFlag;
    public Protocol.ComplaintState[] complaints;
    public boolean aborted;

    /**
     *
     * @param id party identifier - 1 <= id <= n
     * @param n number of parties in current run protocol
     * @param t protocol's threshold
     */
    public Party(int id, int n, int t) {
        this.id = id;
        this.share = null;
        this.doneFlag = false;
        this.complaints = new Protocol.ComplaintState[n];
        Arrays.fill(this.complaints, Protocol.ComplaintState.OK);
        this.commitments = new ArrayList<T>(t + 1);
        for (int i = 0; i <= t ; i++){
            commitments.add(null);
        }
        this.aborted = false;
    }
}
